-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
protoc-gen-openapiv2: Do not add invisible enum values as default #5129
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little conflicted about this. On the one hand, it makes sense that if you want to hide the value it shouldn't show up as a default. On the other hand, all protobuf enum values have defaults that will be set if no value is explicitly supplied. What do you think about returning the integer value while hiding the name?
Also could you try adding add an enum with this property to the https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/visibility_rule_echo_service.proto test file? Thanks!
Done.
Sorry, I didn't get this. Can you explain this a bit more? There is already an enum in the file, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I didn't get this. Can you explain this a bit more? There is already an enum in the file, VisibilityEnum, and no Swagger file is generated for the file.
Sorry, I was unclear. What I meant was, lets add a new enum to the proto file https://github.com/grpc-ecosystem/grpc-gateway/blob/main/examples/internal/proto/examplepb/visibility_rule_echo_service.proto. Lets have the default value be hidden using the visibility specification. This should update the *.swagger.json files generated by various visibility test configs we have living alongside this file (see https://github.com/grpc-ecosystem/grpc-gateway/tree/main/examples/internal/proto/examplepb). It would be great to see that the enum is there but the default value is omitted, in the case where the enum is used as a string. Does that make sense?
Done! |
Have you read the Contributing Guidelines?
Yes
Brief description of what is fixed or changed
Right now, if we hide the default enum value with
value_visibility
, it does not appear in the enum list but still shows up in thedefault
field. This PR adds a check that skips the default enum value if it is hidden. That way, we will not see a hidden enum as the default. With this PR, ifunknown_type
is hidden, it will no longer appear as the default.Example proto:
Example output (before fix):
Other comments