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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options defined in the OpenAPI config file should take precedence over configs in the Proto file #2891

Open
numacci21 opened this issue Sep 16, 2022 · 2 comments

Comments

@numacci21
Copy link
Contributor

馃殌 Feature

As pointed out in #2858, users usually use the openapi configuration file when they can't edit the protobuf file for some reason. So it would be better for the options defined in the openapi configuration file to take precedence.

Currently, only Service has been modified to give priority to the options defined in the OpenAPI configuration file, while the Method, Message, File and Field still give priority to the options defined in the Proto file.

What we need to do

Fix each getXxxOpenAPIOption method so that it first retrieves the options defined in the OpenAPI configuration file, and uses the values defined in the Proto file only if the OpenAPI config options are empty.

It would be nice to check if the automatically generated examples do not change and add some test cases if needed.

For Method, we may need to fix the function below.

func getMethodOpenAPIOption(reg *descriptor.Registry, meth *descriptor.Method) (*openapi_options.Operation, error) {

Service has already been fixed. You can refer to the following implementation when fixing the others.

func getServiceOpenAPIOption(reg *descriptor.Registry, svc *descriptor.Service) (*openapi_options.Tag, error) {

I think we need to add notes to the doc, as changing the configuration files' priority may impact existing users.

@avinilcodes
Copy link

I would like to contribute, can you please assign this to me.

@johanbrandhorst
Copy link
Collaborator

Please feel free to open a PR, there's no need to assign the issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants