Skip to content

Commit b1597cc

Browse files
committed
Add isInitialClass to schema to determine in post processors whether we deal with a nested object or a main entity
1 parent 2cfe6f6 commit b1597cc

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

src/Model/Schema.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Schema
3939
protected $properties = [];
4040
/** @var MethodInterface[] */
4141
protected $methods = [];
42+
/** @var bool */
43+
protected $initialClass = false;
4244

4345
/** @var PropertyValidatorInterface[] A Collection of validators which must be applied
4446
* before adding properties to the model
@@ -61,18 +63,21 @@ class Schema
6163
* @param string $className
6264
* @param JsonSchema $schema
6365
* @param SchemaDefinitionDictionary|null $dictionary
66+
* @param bool $initialClass
6467
*/
6568
public function __construct(
6669
string $classPath,
6770
string $className,
6871
JsonSchema $schema,
69-
SchemaDefinitionDictionary $dictionary = null
72+
SchemaDefinitionDictionary $dictionary = null,
73+
bool $initialClass = false
7074
) {
7175
$this->className = $className;
7276
$this->classPath = $classPath;
7377
$this->jsonSchema = $schema;
7478
$this->schemaDefinitionDictionary = $dictionary ?? new SchemaDefinitionDictionary('');
7579
$this->description = $schema->getJson()['description'] ?? '';
80+
$this->initialClass = $initialClass;
7681

7782
$this->addInterface(JSONModelInterface::class);
7883
}
@@ -330,4 +335,12 @@ public function getSchemaHooks(): array
330335
{
331336
return $this->schemaHooks;
332337
}
338+
339+
/**
340+
* @return bool
341+
*/
342+
public function isInitialClass(): bool
343+
{
344+
return $this->initialClass;
345+
}
333346
}

src/SchemaProcessor/RenderQueue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function addRenderJob(RenderJob $renderJob): self
3333
}
3434

3535
/**
36-
* Render all collected jobs of the RenderProxy and clear the queue
36+
* Render all collected jobs of the RenderQueue and clear the queue
3737
*
3838
* @param string $destination
3939
* @param GeneratorConfiguration $generatorConfiguration

src/SchemaProcessor/SchemaProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ protected function generateModel(
177177
return $this->processedSchema[$schemaSignature];
178178
}
179179

180-
$schema = new Schema($classPath, $className, $jsonSchema, $dictionary);
180+
$schema = new Schema($classPath, $className, $jsonSchema, $dictionary, $initialClass);
181181

182182
$this->processedSchema[$schemaSignature] = $schema;
183183
$json = $jsonSchema->getJson();

0 commit comments

Comments
 (0)