Options defined in the OpenAPI config file should take precedence over configs in the Proto file
#2 891 ouverte le 16 sept. 2022
Métriques du dépôt
- Stars
- (16 971 stars)
- Métriques de merge PR
- (Merge moyen 1j 4h) (141 PRs mergées en 30 j)
Description
🚀 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.