cancel
Showing results for 
Search instead for 
Did you mean: 

Additional properties not allowed: oneOf

Highlighted
New Contributor

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 :

Screenshot from 2019-02-04 13-32-23.png

But in the model view I have an empty model  : 

Screenshot from 2019-02-04 13-34-01.png

 

Do you know why ?

I really need help Smiley Sad

3 REPLIES 3
Moderator

Re: Additional properties not allowed: oneOf

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 Technical Writer
________________________
Vote up helpful replies.
Accept this reply if you think it's the best solution to your question.
New Contributor

Re: Additional properties not allowed: oneOf

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 ?

Screenshot from 2019-02-04 14-29-33.png

Moderator

Re: Additional properties not allowed: oneOf

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 Technical Writer
________________________
Vote up helpful replies.
Accept this reply if you think it's the best solution to your question.
New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors