grpc-ecosystem/grpc-gateway

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

Open

#2,891 创建于 2022年9月16日

在 GitHub 查看
 (2 评论) (1 反应) (0 负责人)Go (16,971 star) (2,250 fork)batch import
buggood first issuehelp wantedopenapi

描述

🚀 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. https://github.com/grpc-ecosystem/grpc-gateway/blob/031bc11c5e7a7ed791f0325cbc01f715ae6714bf/protoc-gen-openapiv2/internal/genopenapi/template.go#L2488

Service has already been fixed. You can refer to the following implementation when fixing the others. https://github.com/grpc-ecosystem/grpc-gateway/blob/031bc11c5e7a7ed791f0325cbc01f715ae6714bf/protoc-gen-openapiv2/internal/genopenapi/template.go#L2518

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

贡献者指南

Options defined in the OpenAPI config file should take precedence over configs in the Proto file · grpc-ecosystem/grpc-gateway#2891 | Good First Issue