Skip to content

Commit 42454eb

Browse files
committed
Fix missing imports
1 parent 239155c commit 42454eb

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

src/Model/SchemaDefinition/SchemaDefinitionDictionary.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ protected function parseExternalFile(
180180

181181
// set up a dummy schema to fetch the definitions from the external file
182182
$schema = new Schema(
183+
$schemaProcessor->getCurrentClassPath(),
183184
'ExternalSchema',
184-
'',
185185
new JsonSchema($jsonSchemaFilePath, $decodedJsonSchema),
186186
new self(dirname($jsonSchemaFilePath))
187187
);

src/PropertyProcessor/Property/ReferenceProcessor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function process(string $propertyName, JsonSchema $propertySchema): Prope
3535
if ($this->schema->getClassPath() !== $definition->getSchema()->getClassPath() ||
3636
$this->schema->getClassName() !== $definition->getSchema()->getClassName() ||
3737
(
38-
$this->schema->getClassPath() === 'ExternalSchema' &&
39-
$definition->getSchema()->getClassPath() === 'ExternalSchema'
38+
$this->schema->getClassName() === 'ExternalSchema' &&
39+
$definition->getSchema()->getClassName() === 'ExternalSchema'
4040
)
4141
) {
4242
$this->schema->addNamespaceTransferDecorator(

src/SchemaProcessor/SchemaProcessor.php

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,24 @@ public function createMergedProperty(
260260

261261
$this->transferPropertiesToMergedSchema($schema, $mergedPropertySchema, $compositionProperties);
262262

263+
// make sure the merged schema knows all imports of the parent schema
264+
$mergedPropertySchema->addNamespaceTransferDecorator(new SchemaNamespaceTransferDecorator($schema));
265+
263266
$this->generateClassFile($this->getCurrentClassPath(), $mergedClassName, $mergedPropertySchema);
264267
}
265268

269+
$mergedSchema = $this->processedMergedProperties[$schemaSignature]->getNestedSchema();
270+
$schema->addUsedClass(
271+
join(
272+
'\\',
273+
array_filter([
274+
$this->generatorConfiguration->getNamespacePrefix(),
275+
$mergedSchema->getClassPath(),
276+
$mergedSchema->getClassName(),
277+
])
278+
)
279+
);
280+
266281
$property->addTypeHintDecorator(
267282
new CompositionTypeHintDecorator($this->processedMergedProperties[$schemaSignature])
268283
);
@@ -322,16 +337,7 @@ function () use ($property, $schema, $mergedPropertySchema): void {
322337
return false;
323338
})
324339
);
325-
326-
// the parent schema needs to know about all imports of the nested classes as all properties
327-
// of the nested classes are available in the parent schema (combined schema merging)
328-
$schema->addNamespaceTransferDecorator(
329-
new SchemaNamespaceTransferDecorator($property->getNestedSchema())
330-
);
331340
}
332-
333-
// make sure the merged schema knows all imports of the parent schema
334-
$mergedPropertySchema->addNamespaceTransferDecorator(new SchemaNamespaceTransferDecorator($schema));
335341
}
336342
);
337343
}

0 commit comments

Comments
 (0)