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

openapi{2,3}: surface both json/yaml unmarshal errors #950

Merged
merged 1 commit into from
Jun 2, 2024

Conversation

timothympace
Copy link
Contributor

If an error is encountered when attempting to unmarshal an openapi document formatted as JSON, callers will only see the error message from the YAML unmarshal. This adds an error message that combines both.

@fenollp
Copy link
Collaborator

fenollp commented May 24, 2024

Do you have a use case where both errors are required?

Or would it be fine to simply return the json error instead of the yml one?

@timothympace
Copy link
Contributor Author

If json unmarshal fails (due to invalid openapi schema), the current code will try to unmarshal as yaml. Most of the times this is ok because yaml.Unmarshal will surface the same schema issue, but it can also return other errors beforehand like this one. In that case, it's very unclear what the actual issue was. This PR may not be the right fix for that use case though.

@fenollp fenollp changed the title Surface both json/yaml unmarshal errors openapi{2,3}: surface both json/yaml unmarshal errors Jun 2, 2024
@fenollp fenollp merged commit 2cf1262 into getkin:master Jun 2, 2024
7 checks passed
@fenollp
Copy link
Collaborator

fenollp commented Jun 2, 2024

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants