Skip to content

Commit

Permalink
Include Package in Service Tags when Option is Enabled (#2519)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiswanto D authored Jan 28, 2022
1 parent 95e6765 commit 09a279d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions protoc-gen-openapiv2/internal/genopenapi/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,11 +870,16 @@ func partsToRegexpMap(parts []string) map[string]string {
return regExps
}

func renderServiceTags(services []*descriptor.Service) []openapiTagObject {
func renderServiceTags(services []*descriptor.Service, reg *descriptor.Registry) []openapiTagObject {
var tags []openapiTagObject
for _, svc := range services {
tagName := svc.GetName()
if pkg := svc.File.GetPackage(); pkg != "" && reg.IsIncludePackageInTags() {
tagName = pkg + "." + tagName
}

tag := openapiTagObject{
Name: *svc.Name,
Name: tagName,
}
if proto.HasExtension(svc.Options, openapi_options.E_Openapiv2Tag) {
ext := proto.GetExtension(svc.Options, openapi_options.E_Openapiv2Tag)
Expand Down Expand Up @@ -1394,7 +1399,7 @@ func applyTemplate(p param) (*openapiSwaggerObject, error) {
if err := renderServices(p.Services, s.Paths, p.reg, requestResponseRefs, customRefs, p.Messages); err != nil {
panic(err)
}
s.Tags = append(s.Tags, renderServiceTags(p.Services)...)
s.Tags = append(s.Tags, renderServiceTags(p.Services, p.reg)...)

messages := messageMap{}
streamingMessages := messageMap{}
Expand Down

0 comments on commit 09a279d

Please sign in to comment.