From 4e7148485efde59c26a59a73a461f52b694f1135 Mon Sep 17 00:00:00 2001 From: comynli Date: Tue, 15 Nov 2022 18:41:29 +0800 Subject: [PATCH 1/3] feat(protoc-gen-openapi): If fq_schema_naming is true, use service fullname as the tagname --- cmd/protoc-gen-openapi/generator/generator.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cmd/protoc-gen-openapi/generator/generator.go b/cmd/protoc-gen-openapi/generator/generator.go index 563aabf0..f13ca360 100644 --- a/cmd/protoc-gen-openapi/generator/generator.go +++ b/cmd/protoc-gen-openapi/generator/generator.go @@ -687,9 +687,12 @@ 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, service.GoName, comment, defaultHost, path, body, inputMessage, outputMessage) + d, operationID, tagName, comment, defaultHost, path, body, inputMessage, outputMessage) // Merge any `Operation` annotations with the current extOperation := proto.GetExtension(method.Desc.Options(), v3.E_Operation) From e664f2d24f27a5438480331ec8aa2537fc5b56ac Mon Sep 17 00:00:00 2001 From: comynli Date: Tue, 15 Nov 2022 19:04:26 +0800 Subject: [PATCH 2/3] 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}) } } } From f77b5ad3914555d7a16b628a78667032c035cdf2 Mon Sep 17 00:00:00 2001 From: Tim Burks Date: Fri, 24 Mar 2023 11:04:02 -0700 Subject: [PATCH 3/3] Update generator.go Fix problem created by my incorrect merge. --- cmd/protoc-gen-openapi/generator/generator.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/protoc-gen-openapi/generator/generator.go b/cmd/protoc-gen-openapi/generator/generator.go index ba4a7f99..3d157a16 100644 --- a/cmd/protoc-gen-openapi/generator/generator.go +++ b/cmd/protoc-gen-openapi/generator/generator.go @@ -755,7 +755,7 @@ func (g *OpenAPIv3Generator) addPathsToDocumentV3(d *v3.Document, services []*pr } if annotationsCount > 0 { - comment := g.filterCommentString(service.Comments.Leading, false) + comment := g.filterCommentString(service.Comments.Leading) d.Tags = append(d.Tags, &v3.Tag{Name: tagName, Description: comment}) } }