allOf not supported in multifiles spec
See original GitHub issueI have discovered that “allOf” seems to be unsupported when using multiple files.
If I have this simplified version of petstore.yaml in a single file, everything is ok:
swagger.yaml
swagger: '2.0'
info:
version: '1.0.0'
title: Swagger Petstore (Simple)
description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
termsOfService: http://helloreverb.com/terms/
contact:
name: Swagger API team
email: foo@example.com
url: http://swagger.io
license:
name: MIT
url: http://opensource.org/licenses/MIT
host: petstore.swagger.io
basePath: /api
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/pets:
get:
description: Returns all pets from the system that the user has access to
operationId: findPets
produces:
- application/json
- application/xml
- text/xml
- text/html
parameters:
- name: tags
in: query
description: tags to filter by
required: false
type: array
items:
type: string
collectionFormat: csv
- name: limit
in: query
description: maximum number of results to return
required: false
type: integer
format: int32
responses:
'200':
description: pet response
schema:
type: array
items:
$ref: '#/definitions/ShippingInfo'
definitions:
PrintInfo:
type: object
description: "Print info of the shipping info"
required:
- B
properties:
B:
type: boolean
ShippingInfo:
type: object
description: "Information about the shipping for a device"
allOf:
- $ref: "#/definitions/PrintInfo"
- type: object
required:
- A
properties:
A:
type: integer
format: int64
If I do the same thing, but using 2 files, PrintInfo
is not in the definitions and ShippingInfo
only contains the field A
(should contain A
and B
)
swagger.yaml
swagger: '2.0'
info:
version: '1.0.0'
title: Swagger Petstore (Simple)
description: A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification
termsOfService: http://helloreverb.com/terms/
contact:
name: Swagger API team
email: foo@example.com
url: http://swagger.io
license:
name: MIT
url: http://opensource.org/licenses/MIT
host: petstore.swagger.io
basePath: /api
schemes:
- http
consumes:
- application/json
produces:
- application/json
paths:
/pets:
get:
description: Returns all pets from the system that the user has access to
operationId: findPets
produces:
- application/json
- application/xml
- text/xml
- text/html
parameters:
- name: tags
in: query
description: tags to filter by
required: false
type: array
items:
type: string
collectionFormat: csv
- name: limit
in: query
description: maximum number of results to return
required: false
type: integer
format: int32
responses:
'200':
description: pet response
schema:
type: array
items:
$ref: './definitions.yaml#/definitions/ShippingInfo'
definitions.yaml
definitions:
PrintInfo:
type: object
description: "Print info of the shipping info"
required:
- B
properties:
B:
type: boolean
ShippingInfo:
type: object
description: "Information about the shipping for a device"
allOf:
- $ref: "#/definitions/PrintInfo"
- type: object
required:
- A
properties:
A:
type: integer
format: int64
The only difference between these 2 examples is the fact that one is in one file and the other is in 2 files. @gracekarina This might interest you, it is highly related to this: https://github.com/swagger-api/swagger-parser/issues/581
Thanks
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:10 (3 by maintainers)
Top Results From Across the Web
oneOf, anyOf, allOf, not - Swagger
oneOf – validates the value against exactly one of the subschemas; allOf ... Besides these, there is a not keyword which you can...
Read more >Understanding JSON Schema 2020-12 documentation
allOf ; anyOf; oneOf; not; Properties of Schema Composition ... Note that this doesn't necessarily mean combining schemas from multiple files or JSON...
Read more >How to use multiple references in OpenAPI 3 yaml file's paths ...
I tried to use allOf , but it leads to Property allOf is not allowed. error. The create.yml file is this: post: tags:...
Read more >OpenAPI Specification
Throughout the specification description fields are noted as supporting ... allOf - Inline or referenced schema MUST be of a Schema Object and...
Read more >OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
Tooling which supports OAS 3.1 SHOULD be compatible with all OAS 3.1.* versions. The patch version SHOULD NOT be considered by tooling, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Please write a new one
It seems to work and already be in the v2.4 of swagger-codegen! Thanks a lot @gracekarina