grpc-gateway
grpc-gateway copied to clipboard
protoc_gen_openapiv2.options.openapiv2_field does not affect google.protobuf.Any and message fields
I want to add description to google.protobuf.Any
and message
(Notification
) fields:
syntax = "proto3";
package myapi;
import "google/protobuf/any.proto";
import "google/protobuf/empty.proto";
import "google/api/annotations.proto"; // https://github.com/googleapis/googleapis
import "protoc-gen-openapiv2/options/annotations.proto"; // https://github.com/grpc-ecosystem/grpc-gateway
option go_package = "myapi/grpc_client_web";
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "MyAPI";
};
schemes: HTTPS;
};
service MyAPI {
rpc Method1(google.protobuf.Empty) returns (stream Method1_response) {
option (google.api.http) = {
post: "/api/Method1"
body: "*"
};
}
}
message Method1_response {
message Notification {
string name = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Awesome description"}];
int32 value = 2;
google.protobuf.Any data = 3 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Some description!!!"}];
}
Notification message = 1 [(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {
description: "Best description!!!"}];
}
After generation I see only the standard description for google.protobuf.Any
and Notification
whereas the description of string
field is applied:
All the well known types have hardcoded type definitions since they are special cased in the marshaler. There might be an argument for being able to set a description only. You can take a look at the logic here: https://github.com/grpc-ecosystem/grpc-gateway/blob/master/protoc-gen-openapiv2/internal/genopenapi/template.go#L504-L506. Would you be willing to fix this behavior?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.