@@ -21,7 +21,7 @@ final class Schema
2121 * @param OpenAPiSchema $schema
2222 * @return iterable<Node>
2323 */
24- public static function generate (string $ name , string $ namespace , string $ className , OpenAPiSchema $ schema , array $ schemaClassNameMap ): iterable
24+ public static function generate (string $ name , string $ namespace , string $ className , OpenAPiSchema $ schema , array $ schemaClassNameMap, string $ rootNamespace ): iterable
2525 {
2626 $ factory = new BuilderFactory ();
2727 $ stmt = $ factory ->namespace ($ namespace );
@@ -80,11 +80,11 @@ public static function generate(string $name, string $namespace, string $classNa
8080 if (is_string ($ property ->type )) {
8181 if ($ property ->type === 'array ' && $ property ->items instanceof OpenAPiSchema) {
8282 if (array_key_exists (spl_object_hash ($ property ->items ), $ schemaClassNameMap )) {
83- $ methodDocBlock [] = '@return array< \\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '> ' ;
84- $ docBlock [] = '@var array< \\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '> ' ;
85- $ docBlock [] = '@\WyriHaximus\Hydrator\Attribute\HydrateArray( \\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '::class) ' ;
83+ $ methodDocBlock [] = '@return array< \\' . $ rootNamespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '> ' ;
84+ $ docBlock [] = '@var array< \\' . $ rootNamespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '> ' ;
85+ $ docBlock [] = '@\WyriHaximus\Hydrator\Attribute\HydrateArray( \\' . $ rootNamespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->items )] . '::class) ' ;
8686 } elseif ($ property ->items ->type === 'object ' ) {
87- yield from self ::generate ($ name . ':: ' . $ propertyName , $ namespace . '\\' . $ className , (new Convert ($ propertyName ))->toPascal (), $ property ->items , $ schemaClassNameMap );
87+ yield from self ::generate ($ name . ':: ' . $ propertyName , $ namespace . '\\' . $ className , (new Convert ($ propertyName ))->toPascal (), $ property ->items , $ schemaClassNameMap, $ rootNamespace );
8888 $ methodDocBlock [] = '@return array< \\' . $ namespace . '\\' . $ className . '\\' . (new Convert ($ propertyName ))->toPascal () . '> ' ;
8989 $ docBlock [] = '@var array< \\' . $ namespace . '\\' . $ className . '\\' . (new Convert ($ propertyName ))->toPascal () . '> ' ;
9090 $ docBlock [] = '@\WyriHaximus\Hydrator\Attribute\HydrateArray( \\' . $ namespace . '\\' . $ className . '\\' . (new Convert ($ propertyName ))->toPascal () . '::class) ' ;
@@ -113,14 +113,14 @@ public static function generate(string $name, string $namespace, string $classNa
113113 }
114114
115115 if (is_array ($ property ->anyOf ) && $ property ->anyOf [0 ] instanceof OpenAPiSchema && array_key_exists (spl_object_hash ($ property ->anyOf [0 ]), $ schemaClassNameMap )) {
116- $ fqcnn = '\\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->anyOf [0 ])];
116+ $ fqcnn = '\\' . $ rootNamespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property ->anyOf [0 ])];
117117 $ propertyStmt ->setType ('? ' . $ fqcnn )->setDefault (null );
118118 $ method ->setReturnType ('? ' . $ fqcnn );
119119 $ propertyDocBlock [] = '@\WyriHaximus\Hydrator\Attribute\Hydrate( ' . $ fqcnn . '::class) ' ;
120120 }
121121
122122 if ($ property ->type === 'object ' && $ property instanceof OpenAPiSchema && array_key_exists (spl_object_hash ($ property ), $ schemaClassNameMap )) {
123- $ fqcnn = '\\' . $ namespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property )];
123+ $ fqcnn = '\\' . $ rootNamespace . '\\' . $ schemaClassNameMap [spl_object_hash ($ property )];
124124 $ propertyStmt ->setType ('? ' . $ fqcnn )->setDefault (null );
125125 $ method ->setReturnType ('? ' . $ fqcnn );
126126 $ propertyDocBlock [] = '@\WyriHaximus\Hydrator\Attribute\Hydrate( ' . $ fqcnn . '::class) ' ;
0 commit comments