-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
additionalProperties is generated with a boolean in swagger2 #2170
Comments
What't the alternative way to express this in Swagger 2? |
In Swagger 2 additionalProperties cannot take a boolean value. Either it is present, or it takes a Schema Object as value https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#schema-object https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schema-object See the differences in spec in the above specifications (v2 and v3) |
So we should just disable generation of |
I agree with disabling the generation of this field in swagger 2. I think you can disable it for OpenApi 3 too, since if it's not present the spec assumes that field is true. On a broader note, how is this property generated if it does take a schema object in NSwag ? |
It is generated as a property with an object, e.g. Currently it is only set to |
The default is only Swagger2 has no notion of a boolean value for this property |
The question is the behavior... |
If you check here https://swagger.io/docs/specification/data-models/data-types/ you'll see that |
How can I disable additional properties when not setting the property defaults to additionalProperties: {}? |
According to that issue thread in swagger, that would should mean that we can assume additionalProperties as Only in the OAS v3 spec is |
Just nice, what a big mess these whole JSON Schema/Swagger 2/OpenAPI 3 specs are... |
I agree 👍 My main issue here, is swagger v2 parsers/validators might fail at the generated swagger output, since they will not expect this field to have a boolean as a value |
Created a PR ... tests missing |
Cool, I'll take a look at it in a bit, unless you want to go ahead and merge it yourself ;) |
Please check/review the tests. |
When using webapi2swagger with outputType set as swagger2 , the additionalProperties field is generated with a boolean set to false.
This is not correct for swagger2 since the boolean value was only introduced for this field in open api 3
The text was updated successfully, but these errors were encountered: