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.
🚀 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 theMethod
,Message
,File
andField
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#L2488Service
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#L2518I think we need to add notes to the doc, as changing the configuration files' priority may impact existing users.