-
-
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
Enum in path generates invalid Swagger schema #854
Comments
The problem is that the schema reference to the enum is needed to generate correct code. Without this essential information is missing. Why is it even evaluated when it is not allowed? Is there any way to fix this without removing the field? |
Ref: #328 |
Thanks for the quick reply Rico. I'm sorry, I searched for existing issues but I didn't find #328. I'm sure the validators are just iterating over the whole structure and ensuring that all the rules for a valid schema are met. I can really only think of three options.
In my use case, neither I or anyone else will be generating code from the documentation created. It will simply be analyzed and compared with a previous version of the document to ensure that there were no breaking changes. |
The 4th option: In this special case (enum parameter) generate an x-schema field and use this in NSwag as fallback when generating code and no schema field is set... However i hoped that there is a way to correctly describe a primitive parh/query enum parameter. But it seems that this is not possible... |
We are now using x-schema to generate a valid specand additionally inline the enum for tools which do not support x-schema... |
Validating the schema generated from the following controller gives a Swagger schema parsing error.
The generated YAML is
Running this through the Swagger Editor generates the following error:
According to the Swagger documentation (in the FAQ at the bottom), "schema is only used with in: body parameters".
Removing the schema: field from the parameter then validates properly with the Swagger Editor.
I am attempting to use swagger-diff to ensure my API is backwards compatible at all times, but it too throws an error because of the schema: field.
The text was updated successfully, but these errors were encountered: