Skip to content
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

feature request: add option to skip response validation #1104

Open
justenwalker opened this issue Nov 14, 2023 · 0 comments
Open

feature request: add option to skip response validation #1104

justenwalker opened this issue Nov 14, 2023 · 0 comments
Labels
enhancement New feature or request openapi-features OpenAPI features support issues

Comments

@justenwalker
Copy link

Description

There should be an option to skip response validation. The response from the actual API is the canonical response.
So when the API gives one, we should be able to receive it. If the response from the API does not validate, there should be an option not to be strict and error, but instead try "best effort".

References

For example, lets say an API says a field is required in the response, but its only available in the response under certain conditions.

I've worked with an API that behaved like this:

  1. The Spec says the "users" field is required in the response
  2. If the API has users, it returns a "users" property filled out with the users it found
=> | GET /users
<= | {"users:" [ {...}, {...}, {...} ]}
  1. However, if there are no users, it returns an empty object:
=> | GET /users
<= | {}

The code generated by ogen check to see if the response contains the "users" property and fails in the second scenario; when in reality I don't actually care. I have no control over the OpenAPI Spec of the API in question, so unless it is fixed upstream I would have to make some manual edits to the spec before generation in order to make it optional and prevent this from erroring out.

@justenwalker justenwalker added enhancement New feature or request openapi-features OpenAPI features support issues labels Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request openapi-features OpenAPI features support issues
Projects
None yet
Development

No branches or pull requests

1 participant