Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set type: 'object' when moving properties into allOf #1489

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Examples/nesting/nesting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ components:
type: string
actual:
type: string
type: object
AlmostModel:
type: object
allOf:
Expand All @@ -55,6 +56,7 @@ components:
type: string
almost:
type: string
type: object
BaseModel:
properties:
base:
Expand Down
2 changes: 2 additions & 0 deletions Examples/polymorphism/polymorphism-3.1.0.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ components:
type:
type: string
const: Virtual
type: object
FlResponsible:
type: object
allOf:
Expand All @@ -67,6 +68,7 @@ components:
type:
- string
- 'null'
type: object
Request:
properties:
payload:
Expand Down
2 changes: 2 additions & 0 deletions Examples/polymorphism/polymorphism.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ components:
type: string
enum:
- Virtual
type: object
FlResponsible:
type: object
allOf:
Expand All @@ -69,6 +70,7 @@ components:
property3:
type: string
nullable: true
type: object
Request:
properties:
payload:
Expand Down
2 changes: 2 additions & 0 deletions Examples/using-interfaces/using-interfaces.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ components:
color:
description: 'The product color.'
example: blue
type: object
Product:
title: 'Product model'
type: object
Expand All @@ -78,6 +79,7 @@ components:
type: integer
format: int64
example: 1
type: object
ProductInterface:
properties:
name:
Expand Down
1 change: 1 addition & 0 deletions Examples/using-refs/using-refs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ components:
$ref: '#/components/schemas/product_status'
stockLevel:
$ref: '#/components/schemas/StockLevel'
type: object
StockLevel:
type: string
enum:
Expand Down
4 changes: 4 additions & 0 deletions Examples/using-traits/using-traits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ components:
plating:
description: 'The plating.'
example: gold
type: object
CustomName/Blink:
title: 'Blink trait'
properties:
Expand Down Expand Up @@ -103,6 +104,7 @@ components:
bell:
description: 'The product bell.'
example: gong
type: object
SimpleProduct:
title: 'SimpleProduct model'
type: object
Expand All @@ -116,6 +118,7 @@ components:
type: integer
format: int64
example: 1
type: object
TrickyProduct:
title: 'TrickyProduct model'
type: object
Expand All @@ -129,3 +132,4 @@ components:
trick:
description: 'The trick.'
example: 'recite poem'
type: object
1 change: 1 addition & 0 deletions src/Processors/AugmentSchemas.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ protected function mergeAllOf(Analysis $analysis, array $schemas): void
if (!$allOfPropertiesSchema) {
$allOfPropertiesSchema = new OA\Schema([
'properties' => [],
'type' => 'object',
'_context' => new Context(['generated' => true], $schema->_context),
]);
$analysis->addAnnotation($allOfPropertiesSchema, $allOfPropertiesSchema->_context);
Expand Down
13 changes: 7 additions & 6 deletions tests/Fixtures/Apis/basic.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ components:
properties:
quantity:
type: integer
id:
description: 'The id.'
format: int64
example: 1
releasedAt:
type: string
brand:
type:
- string
Expand All @@ -145,16 +151,11 @@ components:
example: null
colour:
$ref: '#/components/schemas/Colour'
releasedAt:
type: string
id:
description: 'The id.'
format: int64
example: 1
kind:
description: 'The kind.'
type: string
const: Virtual
type: object
securitySchemes:
bearerAuth:
type: http
Expand Down
2 changes: 2 additions & 0 deletions tests/Fixtures/Scratch/AttributeInheritance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ components:
properties:
name:
type: string
type: object
Child2:
type: object
allOf:
Expand All @@ -34,3 +35,4 @@ components:
properties:
title:
type: string
type: object
1 change: 1 addition & 0 deletions tests/Fixtures/Scratch/Docblocks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ components:
id:
description: 'The id'
type: integer
type: object
1 change: 1 addition & 0 deletions tests/Fixtures/Scratch/MergeTraitsExtended.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,4 @@ components:
type: string
name:
type: string
type: object
Loading