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

Fix a bug where strict json decoder is not used. #757

Merged
merged 1 commit into from Oct 3, 2022
Merged

Fix a bug where strict json decoder is not used. #757

merged 1 commit into from Oct 3, 2022

Conversation

Fethbita
Copy link
Contributor

A json decoder is created however it is not used. The Strict value is essentially useless. This PR fixes the problem and uses the created json decoder and Strict value is also used.

Copy link
Collaborator

@jamietanna jamietanna left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Great spot.

Oddly enough, it looks like this code path isn't used, as the following change doesn't break any tests 🙃:

 func jsonHandler(_ string, r io.Reader, obj interface{}, strict bool) error {
        d := json.NewDecoder(r)
        if strict {
+               panic("hi")
                d.DisallowUnknownFields()
        }
        return json.NewDecoder(r).Decode(obj)

Worth us investigating further, but in the meantime this is a good solution!

@jamietanna jamietanna merged commit 61e864f into deepmap:master Oct 3, 2022
adrianpk pushed a commit to foorester/oapi-codegen that referenced this pull request Jan 16, 2024
Fix a bug where strict json decoder is not used.
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