Skip to content

Commit

Permalink
Set type: 'object' when moving properties into allOf (#1489)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerManoMann authored Oct 17, 2023
1 parent 551c62a commit bc6107f
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 6 deletions.
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

0 comments on commit bc6107f

Please sign in to comment.