Content-Length: 248605 | pFad | http://github.com/oapi-codegen/oapi-codegen/pull/1936

66 fix: respect requestBody.required in strict server by dbarrosop · Pull Request #1936 · oapi-codegen/oapi-codegen · GitHub
Skip to content

fix: respect requestBody.required in strict server #1936

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dbarrosop
Copy link

I noticed that requestBody.required wasn't being respected and requests without a body were failing with an [EOF] error even though required was set to false.

This PR is a tentative fix to this issue. It certainly works as my API now behaves according to the spec and it fails without a body only if required: true

I was wondering if we should also do:

var body *{{$opid}}{{.NameTag}}RequestBody

That would mean that if the body isn't present we would correctly send a nil object down to the server implementation but I am concerned that would lead to lots of panics in existing services for users that hadn't been paying attention to the fact that required: false is the default behavior when not set.

Thoughts?

@dbarrosop dbarrosop requested a review from a team as a code owner March 23, 2025 18:40
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.

1 participant








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/oapi-codegen/oapi-codegen/pull/1936

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy