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

Extend google.protobuf.EnumOptions for Schema #4931

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

Conversation

hown3d
Copy link

@hown3d hown3d commented Nov 10, 2024

References to other Issues or PRs

Fixes #2671

Brief description of what is fixed or changed

Allows to set options on proto enums with OpenAPI Schema.
Only a subset of the Schema fields are respected since most of them are not applicable on enums.

Other comments

PR is based mostly on #2855 with a few adjustments

Signed-off-by: Lukas Hoehl <[email protected]>
//
// All IDs are the same, as assigned. It is okay that they are the same, as they extend
// different descriptor messages.
Schema openapiv2_enum = 1042;
Copy link
Author

@hown3d hown3d Nov 10, 2024

Choose a reason for hiding this comment

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

I would like to discuss if we really need to embed the whole Schema message here since most of the fields are not applicable to Enums. When applying the parsed schema I currently only respect a subset of fields.
Maybe something like EnumSchema that is a subset of Schema? Would need more implementation effort though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd definitely prefer it if we used a smaller more accurate message definition, since I don't see enums ever supporting the same features as the other options 👍🏻

Copy link
Author

Choose a reason for hiding this comment

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

Where would the new message reside?
https://github.com/grpc-ecosystem/grpc-gateway/blob/442bd3ab9497e4f9b3bbcbf4e53854300a68dd5a/protoc-gen-openapiv2/options/openapiv2.proto currently only contains messages that represent the OpenAPI specification. Having a message that does not represent a OpenAPI spec is somewhat misleading.
https://github.com/grpc-ecosystem/grpc-gateway/blob/442bd3ab9497e4f9b3bbcbf4e53854300a68dd5a/protoc-gen-openapiv2/options/annotations.proto holds the extensions that register to the descriptors, so I guess that file is not an option either.

What's your opinion here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

My initial thought was openapiv2.proto. How do you mean that it doesn't represent the OpenAPI specification? We're talking about defining a subset of message Schema as it would apply to enums, right? I was under the impression that using Schema wouldn't make sense since many options in there will never be possible for enums. In that sense, I guess we're defining our own subset of the OpenAPI spec?

Copy link
Author

Choose a reason for hiding this comment

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

Yes, it would be a subset of the Schema message.
What I wanted to say it that currently each message in openapi.proto follows closely to the spec of OpenAPI 2.
For example the Schema message maps to the Message object of the OpenAPI spec.
The new EnumSchema would not map to an object of the spec, but I guess that's negligible

Copy link
Collaborator

Choose a reason for hiding this comment

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

I appreciate the sentiment - I think we have to break with the convention for the sake of user experience.

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.

Extend google.protobuf.EnumOptions
2 participants