-
-
Notifications
You must be signed in to change notification settings - Fork 228
Optionally disable validation #107
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
Comments
Interestingly these would only be problems on main right now, not on the latest released version. Pydantic is much stricter than the parse-as-we-go method being used in 0.4.x. There's certainly no reason not to allow extra fields here and Pydantic has that capability, so that should be fixed before 0.5.0 (what main will become) is released. There are also some errors in your example above of fields that are missing which are required. If they are truly required (and not a mistake in the Pydantic schema) then it'll take some doing to ignore them. I don't believe Pydantic has a way to do this, so it will probably require some try/except looping around the parser. You're right in that it would be a better experience to just discard the pieces of the document that were wrong instead of the whole thing. |
Ah, well I was hitting some other issue with the released version (I think From using another validation library (OpenAPI Enforcer for JS), I know that the missing fields are |
- Create vendored version of openapi-pydantic-schema in `schema`. - Update to this projects quality standards. - Allow (ignore) extra keys when parsing schema - Redo error handling to be much more robust so more pieces of the generator can degrade gracefully instead of outright failing.
@TMiguelT I believe error handling on main is now robust enough to handle the example you gave above no flags needed. It will ignore any extra keys and emit warnings for pieces of the document it can't generate but keep going. I did not add any special error handling for if something in the document violates OpenAPI schema (e.g. missing a required field) but the generator should be much better at handling valid OpenAPI documents that it just doesn't support yet. Please give it a shot and let me know how it goes. These changes will be available in 0.5.0 whenever that milestone is complete. |
Yep, that seems to work quite well, I'm happy with the generator just ignoring the errors in the schema unless it breaks something. Thanks! |
Related to it, can we still have an option to skip validation? I get 55 errors with |
Is your feature request related to a problem? Please describe.
It seems that some OpenAPI specifications aren't always correct, but it might be helpful to allow generation anyway.
For example, I installed the latest version from the
main
branch using:and the warnings I got were:
Describe the solution you'd like
I would like a flag, for example
--skip-validation
, that disables the validation if the errors aren't fatal. In the above case, they're simply extra fields, so it shouldn't prohibit running the generator.Describe alternatives you've considered
I was able to use openapi-generator with the
--skip-validate-spec
flag, which worked, but I would like to be able to do this in pure python.The text was updated successfully, but these errors were encountered: