Forum Discussion

superh2m's avatar
superh2m
New Contributor
6 years ago

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 :(

3 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    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.