Skip to content

Commit e664f2d

Browse files
comynliComyn LI 李学明
authored andcommitted
feat(protoc-gen-openapi): If fq_schema_naming is true, use service fullname as the operation tagname
1 parent 4e71484 commit e664f2d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

cmd/protoc-gen-openapi/generator/generator.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,11 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr
646646
for _, service := range services {
647647
annotationsCount := 0
648648

649+
tagName := service.GoName
650+
if g.conf.FQSchemaNaming != nil && *g.conf.FQSchemaNaming {
651+
tagName = string(service.Desc.FullName())
652+
}
653+
649654
for _, method := range service.Methods {
650655
comment := g.filterCommentString(method.Comments.Leading, false)
651656
inputMessage := method.Input
@@ -687,10 +692,6 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr
687692

688693
if methodName != "" {
689694
defaultHost := proto.GetExtension(service.Desc.Options(), annotations.E_DefaultHost).(string)
690-
tagName := service.GoName
691-
if g.conf.FQSchemaNaming != nil && *g.conf.FQSchemaNaming {
692-
tagName = string(service.Desc.FullName())
693-
}
694695
op, path2 := g.buildOperationV3(
695696
d, operationID, tagName, comment, defaultHost, path, body, inputMessage, outputMessage)
696697

@@ -706,7 +707,7 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr
706707

707708
if annotationsCount > 0 {
708709
comment := g.filterCommentString(service.Comments.Leading, false)
709-
d.Tags = append(d.Tags, &v3.Tag{Name: service.GoName, Description: comment})
710+
d.Tags = append(d.Tags, &v3.Tag{Name: tagName, Description: comment})
710711
}
711712
}
712713
}

0 commit comments

Comments
 (0)