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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug #3829] [protoc-gen-openapiv2] consider openapiv2_tag.name attribute when generating ope… #3830

Merged
merged 3 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/internal/clients/abe/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tags:
- name: "echo rpc"
description: "Echo Rpc description"
x-traitTag: true
- name: "ABitOfEverythingService"
- name: "ABitOfEverything"
description: "ABitOfEverythingService description -- which should not be used in\
\ place of the documentation comment!"
externalDocs:
Expand Down
277 changes: 139 additions & 138 deletions examples/internal/proto/examplepb/a_bit_of_everything.pb.go

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ message UpdateBookRequest {
// proto messages and URL templates are still processed correctly.
service ABitOfEverythingService {
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_tag) = {
name: "ABitOfEverything"
description: "ABitOfEverythingService description -- which should not be used in place of the documentation comment!"
external_docs: {
url: "https://github.com/grpc-ecosystem/grpc-gateway";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"x-traitTag": true
},
{
"name": "ABitOfEverythingService",
"name": "ABitOfEverything",
"description": "ABitOfEverythingService description -- which should not be used in place of the documentation comment!",
"externalDocs": {
"description": "Find out more about EchoService",
Expand Down
3 changes: 3 additions & 0 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,9 @@ func renderServiceTags(services []*descriptor.Service, reg *descriptor.Registry)
tag.ExternalDocs.Description = goTemplateComments(opts.ExternalDocs.Description, svc, reg)
}
}
if opts.GetName() != "" {
tag.Name = opts.GetName()
}
}
tags = append(tags, tag)
}
Expand Down
7 changes: 6 additions & 1 deletion protoc-gen-openapiv2/internal/genopenapi/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6319,7 +6319,8 @@ func TestTagsWithGoTemplate(t *testing.T) {
Description: "{{ import \"file\" }}",
},
{
Name: "ExampleService",
Name: "ExampleService",
Description: "ExampleService!",
},
{
Name: "not a service tag 2",
Expand Down Expand Up @@ -6354,6 +6355,10 @@ func TestTagsWithGoTemplate(t *testing.T) {
Name: "Service with my_key",
Description: "the my_value",
},
{
Name: "service tag",
Description: "ExampleService!",
},
}
if !reflect.DeepEqual(actual.Tags, expectedTags) {
t.Errorf("Expected tags %+v, not %+v", expectedTags, actual.Tags)
Expand Down
Loading