Skip to content

Commit

Permalink
Fix TypeError when type is array
Browse files Browse the repository at this point in the history
  • Loading branch information
DjordyKoert committed Nov 24, 2023
1 parent a3e0067 commit d4aab3d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/Processors/AugmentProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ public function __invoke(Analysis $analysis)
if (Generator::isDefault($property->type)) {
$this->augmentType($analysis, $property, $context, $refs, $typeAndDescription['type']);
} else {
$this->mapNativeType($property, $property->type);
if (!is_array($property->type)) {
$this->mapNativeType($property, $property->type);
}
}

if (Generator::isDefault($property->description) && $typeAndDescription['description']) {
Expand Down Expand Up @@ -129,7 +131,7 @@ protected function augmentType(Analysis $analysis, OA\Property $property, Contex
if (Generator::isDefault($property->ref) && array_key_exists($refKey, $refs)) {
$this->applyRef($analysis, $property, $refs[$refKey]);
} else {
if ($typeSchema = $analysis->getSchemaForSource($context->type)) {
if (is_string($context->type) && $typeSchema = $analysis->getSchemaForSource($context->type)) {
if (Generator::isDefault($property->format)) {
$property->ref = OA\Components::ref($typeSchema);
$property->type = Generator::UNDEFINED;
Expand Down
2 changes: 1 addition & 1 deletion src/Processors/AugmentSchemas.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function augmentType(Analysis $analysis, array $schemas): void
$schema->type = 'object';
}
} else {
if ($typeSchema = $analysis->getSchemaForSource($schema->type)) {
if (is_string($schema->type) && $typeSchema = $analysis->getSchemaForSource($schema->type)) {
if (Generator::isDefault($schema->format)) {
$schema->ref = OA\Components::ref($typeSchema);
$schema->type = Generator::UNDEFINED;
Expand Down

0 comments on commit d4aab3d

Please sign in to comment.