-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Unable to mark the body parameter as REQUIRED when part of the proto message is path param #4666
Comments
Thanks for your detailed bug report. This sounds like a reasonable bug, I expect the logic for parsing the path parameters and marking them required doesn't take this annotation into account. Would you be willing to help contribute a fix? The logic for this is in here: https://github.com/grpc-ecosystem/grpc-gateway/blob/main/protoc-gen-openapiv2/internal/genopenapi/template.go. |
I'm not familiar with Golang to contribute quality code to fix the problem 😓 |
@johanbrandhorst - I would like to try to fix this |
Go for it |
Hello @johanbrandhorst , I was able to write a fix for this issue. To test it, I installed However, I am unable to write a test case in books.proto
To simulate this in a test,
What should be written in the body part ? Putting an empty array I did not find any other test case with a similar example. |
Hi, looks like you should be able to use an empty slice:
Here's an example test:
Here's the parser for the body parameter when its an empty slice:
|
Hey @johanbrandhorst , thanks for pointing the example above. I have opened PR #4850 . Kindly provide feedback. Thanks |
🐛 Bug Report
We have the below proto description with openAPI annotations.
FederatedIdentity identity = 4 [(google.api.field_behavior) = REQUIRED];
is request body param which is required. However, part of theidentity
, thetype
field is also path param/v1/identity/{identity.type}/register-by-link/cancel
In the generated openapi spec, the identity is not marked as required.
Expected behavior
The remaining parts of identity should be marked as required.
Actual Behavior
Only the part including in the path param is marked as required, the remaining parts as request body params are not marked as required.
Your Environment
MacOS M1
The text was updated successfully, but these errors were encountered: