From dc91ebc5a70760bf63dcab62d668b39f21b9e447 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Comyn=20LI=20=E6=9D=8E=E5=AD=A6=E6=98=8E?= Date: Tue, 15 Nov 2022 19:04:26 +0800 Subject: [PATCH] feat(protoc-gen-openapi): If fq_schema_naming is true, use service fullname as the operation tagname --- cmd/protoc-gen-openapi/generator/generator.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/protoc-gen-openapi/generator/generator.go b/cmd/protoc-gen-openapi/generator/generator.go index f13ca360..eb63c6ca 100644 --- a/cmd/protoc-gen-openapi/generator/generator.go +++ b/cmd/protoc-gen-openapi/generator/generator.go @@ -646,6 +646,11 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr for _, service := range services { annotationsCount := 0 + tagName := service.GoName + if g.conf.FQSchemaNaming != nil && *g.conf.FQSchemaNaming { + tagName = string(service.Desc.FullName()) + } + for _, method := range service.Methods { comment := g.filterCommentString(method.Comments.Leading, false) inputMessage := method.Input @@ -687,10 +692,6 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr if methodName != "" { defaultHost := proto.GetExtension(service.Desc.Options(), annotations.E_DefaultHost).(string) - tagName := service.GoName - if g.conf.FQSchemaNaming != nil && *g.conf.FQSchemaNaming { - tagName = string(service.Desc.FullName()) - } op, path2 := g.buildOperationV3( d, operationID, tagName, comment, defaultHost, path, body, inputMessage, outputMessage) @@ -706,7 +707,7 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr if annotationsCount > 0 { comment := g.filterCommentString(service.Comments.Leading, false) - d.Tags = append(d.Tags, &v3.Tag{Name: service.GoName, Description: comment}) + d.Tags = append(d.Tags, &v3.Tag{Name: tagName, Description: comment}) } } }