Skip to content

Commit

Permalink
feat(protoc-gen-openapi): If fq_schema_naming is true, use service fu…
Browse files Browse the repository at this point in the history
…llname as the operation tagname
  • Loading branch information
comynli authored and Comyn LI 李学明 committed Nov 15, 2022
1 parent 4e71484 commit e664f2d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions cmd/protoc-gen-openapi/generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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})
}
}
}
Expand Down

0 comments on commit e664f2d

Please sign in to comment.