You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Validator falls back to assuming that this is v2 (which is why produces is required to avoid generating a warning) - and the output is:
openapi.yaml passed the validator
Expected behaviour
Validator should fail because neither swagger nor openapi fields are specified in the root object. It would probably be simplest if validation just stopped at this point, rather than making any assumptions about the version that was desired.
When a bad value is provided
Current behaviour
The value provided for swagger and openapi are not checked. This means that strange configurations pass validation. The following pass with no warnings or errors:
My understanding of the specs is that the openapi.yaml file's root object must contain one of:
swagger: 2.0 (because spec says: """The value MUST be "2.0".""") or
openapi: 3.0.0 or
openapi: 3.0.1 or
openapi: 3.0.2
Any other variation should raise an error and halt validation.
This might be a little strict in terms of the possible values for openapi, but it certainly should not allow anything that does not look like a semver string since the spec says "An OpenAPI document compatible with OAS 3.. contains a required openapi field which designates the semantic version of the OAS that it uses."
The text was updated successfully, but these errors were encountered:
Context
In version 3 of OpenAPI, the field
openapi
is required in the root object as per the spec: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.2.md#fixed-fieldsIn version 2, the field
swagger
is required as per the spec: https://swagger.io/specification/v2/#fixed-fieldsHowever, the validator does not check that these fields are provided, nor does it check their values.
The examples below are running v0.17.0 inside a Node 13.7 docker container.
When not provided
Current behaviour
Given the following specification, which contains neither
swagger
noropenapi
:Validator falls back to assuming that this is v2 (which is why
produces
is required to avoid generating a warning) - and the output is:Expected behaviour
Validator should fail because neither
swagger
noropenapi
fields are specified in the root object. It would probably be simplest if validation just stopped at this point, rather than making any assumptions about the version that was desired.When a bad value is provided
Current behaviour
The value provided for
swagger
andopenapi
are not checked. This means that strange configurations pass validation. The following pass with no warnings or errors:Providing both values:
Providing objects:
Expected behaviour
My understanding of the specs is that the
openapi.yaml
file's root object must contain one of:swagger: 2.0
(because spec says: """The value MUST be "2.0".""") oropenapi: 3.0.0
oropenapi: 3.0.1
oropenapi: 3.0.2
Any other variation should raise an error and halt validation.
This might be a little strict in terms of the possible values for
openapi
, but it certainly should not allow anything that does not look like a semver string since the spec says "An OpenAPI document compatible with OAS 3.. contains a requiredopenapi
field which designates the semantic version of the OAS that it uses."The text was updated successfully, but these errors were encountered: