Additional properties not allowed: oneOf
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Additional properties not allowed: oneOf
Hi everyone !
It's been few days that I'm trying to create a "clean" configuration with swagger, but swagger-cli doesn't validate some of it.
To explain the context, first of all I use swagger-cli with swagger-ui, and I bundle the following output used by swagger-ui with swagger-cli :
"choices": {
"type": "array",
"description": "The choices",
"items": {
"anyOf": [
{ "$ref": "../../../choice/choice.boolean.output.json" },
{ "$ref": "../../../choice/choice.integer.output.json" },
{ "$ref": "../../../choice/choice.text.output.json" }
]
}
}
And everytime I'm trying to validate the schema with the following command :
swagger-cli validate api-description.yaml
I have the same error :
Additional properties not allowed: oneOf at #/properties/.../items/properties/choices
I try lot of combinations with docs :
https://swagger.io/docs/specification/data-models/inheritance-and-polymorphism/
https://swagger.io/docs/specification/data-models/oneof-anyof-allof-not/
https://swagger.io/docs/specification/data-models/data-types/
https://swagger.io/docs/specification/describing-responses/
And I notice something weird about that, that I'm able to bundle it with the same package swagger-cli and display part of it in the swagger-ui "Example value" section :
But in the model view I have an empty model :
Do you know why ?
I really need help 😞
- Labels:
-
Swagger Core
-
Swagger UI
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is your definition
"swagger": "2.0"
or
"openapi": "3.0.0"
?
"anyOf" was introduced in OpenAPI 3.0 and is not supported in OpenAPI/Swagger 2.0.
Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
swagger: "2.0"
😕
It will never be supported in Swagger ?
But why in the github https://github.com/swagger-api/swagger-core it's marked the version 2.0 it's compatible with the version OpenAPI 3.0 ?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You need Swagger Core 2.x in order to use OpenAPI 3.0 features such as oneOf.
The "swagger": "2.0" and "openapi": "3.0.0" identifiers in an API definition are versions of the OpenAPI Specification, which defines the syntax and keywords you can use. Swagger Core is a library that implements OpenAPI Spec. Please see What Is the Difference Between Swagger and OpenAPI?
Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
