From d57d765ba671473a56d25d4202ef97bbdb1a1413 Mon Sep 17 00:00:00 2001 From: Zilong Wang Date: Thu, 24 Jan 2019 16:00:00 -0500 Subject: [PATCH 1/6] add the package name to the tags field of each endpoint --- protoc-gen-swagger/genswagger/template.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 771a005c99b..1054b3a3bdf 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -821,7 +821,7 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re responseSchema.Ref = strings.Replace(responseSchema.Ref, `#/definitions/`, `#/x-stream-definitions/`, 1) } operationObject := &swaggerOperationObject{ - Tags: []string{svc.GetName()}, + Tags: []string{fmt.Sprintf("%s.%s", svc.File.GetPackage(), svc.GetName())}, Parameters: parameters, Responses: swaggerResponsesObject{ "200": swaggerResponseObject{ From 3d3f76b757bea72b5fdc371459622baef5551015 Mon Sep 17 00:00:00 2001 From: Zilong Wang Date: Thu, 24 Jan 2019 17:42:33 -0500 Subject: [PATCH 2/6] prepend the package name only if it is defined in the proto file --- protoc-gen-swagger/genswagger/template.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 1054b3a3bdf..5dba2fe3e79 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -820,8 +820,14 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re // Use the streamdefinition which wraps the message in a "result" responseSchema.Ref = strings.Replace(responseSchema.Ref, `#/definitions/`, `#/x-stream-definitions/`, 1) } + + tag := svc.GetName() + if pkg := svc.File.GetPackage(); pkg != "" { + tag = pkg + "." + tag + } + operationObject := &swaggerOperationObject{ - Tags: []string{fmt.Sprintf("%s.%s", svc.File.GetPackage(), svc.GetName())}, + Tags: []string{tag}, Parameters: parameters, Responses: swaggerResponsesObject{ "200": swaggerResponseObject{ From dc157cc677cfbc36880a1df00c76b78d59a83425 Mon Sep 17 00:00:00 2001 From: Zilong Wang Date: Thu, 24 Jan 2019 17:57:49 -0500 Subject: [PATCH 3/6] fix the generate stage of the CI by checking in generated files --- examples/clients/abe/BUILD.bazel | 4 +- ...mplepb_a_bit_of_everything_service_api.go} | 40 +++++++++---------- ...esexamplepbcamel_case_service_name_api.go} | 12 +++--- examples/clients/echo/BUILD.bazel | 2 +- ...ewayexamplesexamplepb_echo_service_api.go} | 24 +++++------ examples/clients/responsebody/BUILD.bazel | 2 +- ...xamplesexamplepbResponseBodyServiceApi.md} | 8 ++-- ...lesexamplepb_response_body_service_api.go} | 16 ++++---- examples/clients/unannotatedecho/BUILD.bazel | 2 +- ...examplepb_unannotated_echo_service_api.go} | 18 ++++----- .../a_bit_of_everything.swagger.json | 32 +++++++-------- .../proto/examplepb/echo_service.swagger.json | 14 +++---- .../response_body_service.swagger.json | 6 +-- examples/proto/examplepb/stream.swagger.json | 6 +-- .../unannotated_echo_service.swagger.json | 8 ++-- .../proto/examplepb/wrappers.swagger.json | 22 +++++----- 16 files changed, 108 insertions(+), 108 deletions(-) rename examples/clients/abe/{a_bit_of_everything_service_api.go => grpcgatewayexamplesexamplepb_a_bit_of_everything_service_api.go} (92%) rename examples/clients/abe/{camel_case_service_name_api.go => grpcgatewayexamplesexamplepbcamel_case_service_name_api.go} (85%) rename examples/clients/echo/{echo_service_api.go => grpcgatewayexamplesexamplepb_echo_service_api.go} (92%) rename examples/clients/responsebody/docs/{ResponseBodyServiceApi.md => GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md} (81%) rename examples/clients/responsebody/{response_body_service_api.go => grpcgatewayexamplesexamplepb_response_body_service_api.go} (89%) rename examples/clients/unannotatedecho/{unannotated_echo_service_api.go => grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go} (90%) diff --git a/examples/clients/abe/BUILD.bazel b/examples/clients/abe/BUILD.bazel index 4d3c3546e93..a1e2befaca4 100644 --- a/examples/clients/abe/BUILD.bazel +++ b/examples/clients/abe/BUILD.bazel @@ -6,10 +6,8 @@ go_library( name = "go_default_library", srcs = [ "a_bit_of_everything_nested.go", - "a_bit_of_everything_service_api.go", "api_client.go", "api_response.go", - "camel_case_service_name_api.go", "configuration.go", "echo_rpc_api.go", "echo_service_api.go", @@ -19,6 +17,8 @@ go_library( "examplepb_body.go", "examplepb_numeric_enum.go", "examplepb_update_v2_request.go", + "grpcgatewayexamplesexamplepb_a_bit_of_everything_service_api.go", + "grpcgatewayexamplesexamplepbcamel_case_service_name_api.go", "message_path_enum_nested_path_enum.go", "nested_deep_enum.go", "pathenum_path_enum.go", diff --git a/examples/clients/abe/a_bit_of_everything_service_api.go b/examples/clients/abe/grpcgatewayexamplesexamplepb_a_bit_of_everything_service_api.go similarity index 92% rename from examples/clients/abe/a_bit_of_everything_service_api.go rename to examples/clients/abe/grpcgatewayexamplesexamplepb_a_bit_of_everything_service_api.go index 1e8956c2aff..05d65dec7ce 100644 --- a/examples/clients/abe/a_bit_of_everything_service_api.go +++ b/examples/clients/abe/grpcgatewayexamplesexamplepb_a_bit_of_everything_service_api.go @@ -18,22 +18,22 @@ import ( "fmt" ) -type ABitOfEverythingServiceApi struct { +type GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi struct { Configuration *Configuration } -func NewABitOfEverythingServiceApi() *ABitOfEverythingServiceApi { +func NewGrpcgatewayexamplesexamplepbABitOfEverythingServiceApi() *GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi { configuration := NewConfiguration() - return &ABitOfEverythingServiceApi{ + return &GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi{ Configuration: configuration, } } -func NewABitOfEverythingServiceApiWithBasePath(basePath string) *ABitOfEverythingServiceApi { +func NewGrpcgatewayexamplesexamplepbABitOfEverythingServiceApiWithBasePath(basePath string) *GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi { configuration := NewConfiguration() configuration.BasePath = basePath - return &ABitOfEverythingServiceApi{ + return &GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi{ Configuration: configuration, } } @@ -62,7 +62,7 @@ func NewABitOfEverythingServiceApiWithBasePath(basePath string) *ABitOfEverythin * @param nestedPathEnumValue * @return *ExamplepbABitOfEverything */ -func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string, enumValue string, pathEnumValue string, nestedPathEnumValue string) (*ExamplepbABitOfEverything, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string, enumValue string, pathEnumValue string, nestedPathEnumValue string) (*ExamplepbABitOfEverything, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -153,7 +153,7 @@ func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float * @param body * @return *ExamplepbABitOfEverything */ -func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -229,7 +229,7 @@ func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) ( * @param body * @return *ExamplepbABitOfEverything */ -func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -305,7 +305,7 @@ func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body E * @param uuid * @return *interface{} */ -func (a ABitOfEverythingServiceApi) Delete(uuid string) (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Delete(uuid string) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables @@ -373,7 +373,7 @@ func (a ABitOfEverythingServiceApi) Delete(uuid string) (*interface{}, *APIRespo * * @return *interface{} */ -func (a ABitOfEverythingServiceApi) ErrorWithDetails() (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) ErrorWithDetails() (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -447,7 +447,7 @@ func (a ABitOfEverythingServiceApi) ErrorWithDetails() (*interface{}, *APIRespon * @param body * @return *interface{} */ -func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body ExamplepbBody) (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) GetMessageWithBody(id string, body ExamplepbBody) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -549,7 +549,7 @@ func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body Examplepb * @param repeatedEnumValue repeated enum value. it is comma-separated in query. - ZERO: ZERO means 0 - ONE: ONE means 1 * @return *interface{} */ -func (a ABitOfEverythingServiceApi) GetQuery(uuid string, floatValue float32, singleNestedName string, singleNestedAmount int64, singleNestedOk string, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, bytesValue string, uint32Value int64, enumValue string, pathEnumValue string, nestedPathEnumValue string, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, repeatedStringValue []string, oneofString string, nonConventionalNameValue string, timestampValue time.Time, repeatedEnumValue []string) (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) GetQuery(uuid string, floatValue float32, singleNestedName string, singleNestedAmount int64, singleNestedOk string, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, bytesValue string, uint32Value int64, enumValue string, pathEnumValue string, nestedPathEnumValue string, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, repeatedStringValue []string, oneofString string, nonConventionalNameValue string, timestampValue time.Time, repeatedEnumValue []string) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -655,7 +655,7 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, floatValue float32, si * @param pathRepeatedSint64Value * @return *ExamplepbABitOfEverythingRepeated */ -func (a ABitOfEverythingServiceApi) GetRepeatedQuery(pathRepeatedFloatValue []float32, pathRepeatedDoubleValue []float64, pathRepeatedInt64Value []string, pathRepeatedUint64Value []string, pathRepeatedInt32Value []int32, pathRepeatedFixed64Value []string, pathRepeatedFixed32Value []int64, pathRepeatedBoolValue []bool, pathRepeatedStringValue []string, pathRepeatedBytesValue []string, pathRepeatedUint32Value []int64, pathRepeatedEnumValue []string, pathRepeatedSfixed32Value []int32, pathRepeatedSfixed64Value []string, pathRepeatedSint32Value []int32, pathRepeatedSint64Value []string) (*ExamplepbABitOfEverythingRepeated, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) GetRepeatedQuery(pathRepeatedFloatValue []float32, pathRepeatedDoubleValue []float64, pathRepeatedInt64Value []string, pathRepeatedUint64Value []string, pathRepeatedInt32Value []int32, pathRepeatedFixed64Value []string, pathRepeatedFixed32Value []int64, pathRepeatedBoolValue []bool, pathRepeatedStringValue []string, pathRepeatedBytesValue []string, pathRepeatedUint32Value []int64, pathRepeatedEnumValue []string, pathRepeatedSfixed32Value []int32, pathRepeatedSfixed64Value []string, pathRepeatedSint32Value []int32, pathRepeatedSint64Value []string) (*ExamplepbABitOfEverythingRepeated, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -744,7 +744,7 @@ func (a ABitOfEverythingServiceApi) GetRepeatedQuery(pathRepeatedFloatValue []fl * @param uuid * @return *ExamplepbABitOfEverything */ -func (a ABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEverything, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEverything, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -819,7 +819,7 @@ func (a ABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEveryth * @param body * @return *interface{} */ -func (a ABitOfEverythingServiceApi) PatchWithFieldMaskInBody(abeUuid string, body ExamplepbUpdateV2Request) (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) PatchWithFieldMaskInBody(abeUuid string, body ExamplepbUpdateV2Request) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Patch") // create path and map variables @@ -896,7 +896,7 @@ func (a ABitOfEverythingServiceApi) PatchWithFieldMaskInBody(abeUuid string, bod * @param body * @return *interface{} */ -func (a ABitOfEverythingServiceApi) PostWithEmptyBody(name string, body ExamplepbBody) (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) PostWithEmptyBody(name string, body ExamplepbBody) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -971,7 +971,7 @@ func (a ABitOfEverythingServiceApi) PostWithEmptyBody(name string, body Examplep * * @return *interface{} */ -func (a ABitOfEverythingServiceApi) Timeout() (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Timeout() (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -1045,7 +1045,7 @@ func (a ABitOfEverythingServiceApi) Timeout() (*interface{}, *APIResponse, error * @param body * @return *interface{} */ -func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Put") // create path and map variables @@ -1122,7 +1122,7 @@ func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEver * @param body * @return *interface{} */ -func (a ABitOfEverythingServiceApi) UpdateV2(abeUuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) UpdateV2(abeUuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Put") // create path and map variables @@ -1199,7 +1199,7 @@ func (a ABitOfEverythingServiceApi) UpdateV2(abeUuid string, body ExamplepbABitO * @param body * @return *interface{} */ -func (a ABitOfEverythingServiceApi) UpdateV22(abeUuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) UpdateV22(abeUuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Patch") // create path and map variables diff --git a/examples/clients/abe/camel_case_service_name_api.go b/examples/clients/abe/grpcgatewayexamplesexamplepbcamel_case_service_name_api.go similarity index 85% rename from examples/clients/abe/camel_case_service_name_api.go rename to examples/clients/abe/grpcgatewayexamplesexamplepbcamel_case_service_name_api.go index d761b19786c..65d1bb76705 100644 --- a/examples/clients/abe/camel_case_service_name_api.go +++ b/examples/clients/abe/grpcgatewayexamplesexamplepbcamel_case_service_name_api.go @@ -16,22 +16,22 @@ import ( "encoding/json" ) -type CamelCaseServiceNameApi struct { +type GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi struct { Configuration *Configuration } -func NewCamelCaseServiceNameApi() *CamelCaseServiceNameApi { +func NewGrpcgatewayexamplesexamplepbcamelCaseServiceNameApi() *GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi { configuration := NewConfiguration() - return &CamelCaseServiceNameApi{ + return &GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi{ Configuration: configuration, } } -func NewCamelCaseServiceNameApiWithBasePath(basePath string) *CamelCaseServiceNameApi { +func NewGrpcgatewayexamplesexamplepbcamelCaseServiceNameApiWithBasePath(basePath string) *GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi { configuration := NewConfiguration() configuration.BasePath = basePath - return &CamelCaseServiceNameApi{ + return &GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi{ Configuration: configuration, } } @@ -41,7 +41,7 @@ func NewCamelCaseServiceNameApiWithBasePath(basePath string) *CamelCaseServiceNa * * @return *interface{} */ -func (a CamelCaseServiceNameApi) Empty() (*interface{}, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi) Empty() (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables diff --git a/examples/clients/echo/BUILD.bazel b/examples/clients/echo/BUILD.bazel index 090b56aafab..402d328ccf0 100644 --- a/examples/clients/echo/BUILD.bazel +++ b/examples/clients/echo/BUILD.bazel @@ -8,9 +8,9 @@ go_library( "api_client.go", "api_response.go", "configuration.go", - "echo_service_api.go", "examplepb_embedded.go", "examplepb_simple_message.go", + "grpcgatewayexamplesexamplepb_echo_service_api.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/clients/echo", deps = ["@com_github_go_resty_resty//:go_default_library"], diff --git a/examples/clients/echo/echo_service_api.go b/examples/clients/echo/grpcgatewayexamplesexamplepb_echo_service_api.go similarity index 92% rename from examples/clients/echo/echo_service_api.go rename to examples/clients/echo/grpcgatewayexamplesexamplepb_echo_service_api.go index 6ae7cf85a32..fd29a8ff90d 100644 --- a/examples/clients/echo/echo_service_api.go +++ b/examples/clients/echo/grpcgatewayexamplesexamplepb_echo_service_api.go @@ -17,22 +17,22 @@ import ( "fmt" ) -type EchoServiceApi struct { +type GrpcgatewayexamplesexamplepbEchoServiceApi struct { Configuration *Configuration } -func NewEchoServiceApi() *EchoServiceApi { +func NewGrpcgatewayexamplesexamplepbEchoServiceApi() *GrpcgatewayexamplesexamplepbEchoServiceApi { configuration := NewConfiguration() - return &EchoServiceApi{ + return &GrpcgatewayexamplesexamplepbEchoServiceApi{ Configuration: configuration, } } -func NewEchoServiceApiWithBasePath(basePath string) *EchoServiceApi { +func NewGrpcgatewayexamplesexamplepbEchoServiceApiWithBasePath(basePath string) *GrpcgatewayexamplesexamplepbEchoServiceApi { configuration := NewConfiguration() configuration.BasePath = basePath - return &EchoServiceApi{ + return &GrpcgatewayexamplesexamplepbEchoServiceApi{ Configuration: configuration, } } @@ -44,7 +44,7 @@ func NewEchoServiceApiWithBasePath(basePath string) *EchoServiceApi { * @param id Id represents the message identifier. * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) Echo(id string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo(id string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -113,7 +113,7 @@ func (a EchoServiceApi) Echo(id string) (*ExamplepbSimpleMessage, *APIResponse, * @param noNote * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) Echo2(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo2(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -190,7 +190,7 @@ func (a EchoServiceApi) Echo2(id string, num string, lineNum string, lang string * @param noNote * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) Echo3(id string, num string, lang string, lineNum string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo3(id string, num string, lang string, lineNum string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -266,7 +266,7 @@ func (a EchoServiceApi) Echo3(id string, num string, lang string, lineNum string * @param noProgress * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) Echo4(id string, lineNum string, statusNote string, num string, lang string, statusProgress string, en string, noProgress string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo4(id string, lineNum string, statusNote string, num string, lang string, statusProgress string, en string, noProgress string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -341,7 +341,7 @@ func (a EchoServiceApi) Echo4(id string, lineNum string, statusNote string, num * @param noProgress * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) Echo5(noNote string, id string, num string, lineNum string, lang string, statusProgress string, en string, noProgress string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo5(noNote string, id string, num string, lineNum string, lang string, statusProgress string, en string, noProgress string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -408,7 +408,7 @@ func (a EchoServiceApi) Echo5(noNote string, id string, num string, lineNum stri * @param body * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbEchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -477,7 +477,7 @@ func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleM * @param noNote * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) EchoDelete(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbEchoServiceApi) EchoDelete(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables diff --git a/examples/clients/responsebody/BUILD.bazel b/examples/clients/responsebody/BUILD.bazel index e621bea6960..4f8fdd8a49d 100644 --- a/examples/clients/responsebody/BUILD.bazel +++ b/examples/clients/responsebody/BUILD.bazel @@ -14,7 +14,7 @@ go_library( "examplepb_response_body_out.go", "examplepb_response_body_out_response.go", "examplepb_response_body_req.go", - "response_body_service_api.go", + "grpcgatewayexamplesexamplepb_response_body_service_api.go", "response_response_type.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/clients/responsebody", diff --git a/examples/clients/responsebody/docs/ResponseBodyServiceApi.md b/examples/clients/responsebody/docs/GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md similarity index 81% rename from examples/clients/responsebody/docs/ResponseBodyServiceApi.md rename to examples/clients/responsebody/docs/GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md index 458725faa9b..fdafd8089ec 100644 --- a/examples/clients/responsebody/docs/ResponseBodyServiceApi.md +++ b/examples/clients/responsebody/docs/GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md @@ -1,12 +1,12 @@ -# \ResponseBodyServiceApi +# \GrpcgatewayexamplesexamplepbResponseBodyServiceApi All URIs are relative to *http://localhost* Method | HTTP request | Description ------------- | ------------- | ------------- -[**GetResponseBody**](ResponseBodyServiceApi.md#GetResponseBody) | **Get** /responsebody/{data} | -[**ListResponseBodies**](ResponseBodyServiceApi.md#ListResponseBodies) | **Get** /responsebodies/{data} | -[**ListResponseStrings**](ResponseBodyServiceApi.md#ListResponseStrings) | **Get** /responsestrings/{data} | +[**GetResponseBody**](GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md#GetResponseBody) | **Get** /responsebody/{data} | +[**ListResponseBodies**](GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md#ListResponseBodies) | **Get** /responsebodies/{data} | +[**ListResponseStrings**](GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md#ListResponseStrings) | **Get** /responsestrings/{data} | # **GetResponseBody** diff --git a/examples/clients/responsebody/response_body_service_api.go b/examples/clients/responsebody/grpcgatewayexamplesexamplepb_response_body_service_api.go similarity index 89% rename from examples/clients/responsebody/response_body_service_api.go rename to examples/clients/responsebody/grpcgatewayexamplesexamplepb_response_body_service_api.go index 000cecd6ddd..5b6aac5778f 100644 --- a/examples/clients/responsebody/response_body_service_api.go +++ b/examples/clients/responsebody/grpcgatewayexamplesexamplepb_response_body_service_api.go @@ -17,22 +17,22 @@ import ( "fmt" ) -type ResponseBodyServiceApi struct { +type GrpcgatewayexamplesexamplepbResponseBodyServiceApi struct { Configuration *Configuration } -func NewResponseBodyServiceApi() *ResponseBodyServiceApi { +func NewGrpcgatewayexamplesexamplepbResponseBodyServiceApi() *GrpcgatewayexamplesexamplepbResponseBodyServiceApi { configuration := NewConfiguration() - return &ResponseBodyServiceApi{ + return &GrpcgatewayexamplesexamplepbResponseBodyServiceApi{ Configuration: configuration, } } -func NewResponseBodyServiceApiWithBasePath(basePath string) *ResponseBodyServiceApi { +func NewGrpcgatewayexamplesexamplepbResponseBodyServiceApiWithBasePath(basePath string) *GrpcgatewayexamplesexamplepbResponseBodyServiceApi { configuration := NewConfiguration() configuration.BasePath = basePath - return &ResponseBodyServiceApi{ + return &GrpcgatewayexamplesexamplepbResponseBodyServiceApi{ Configuration: configuration, } } @@ -43,7 +43,7 @@ func NewResponseBodyServiceApiWithBasePath(basePath string) *ResponseBodyService * @param data * @return *ExamplepbResponseBodyOutResponse */ -func (a ResponseBodyServiceApi) GetResponseBody(data string) (*ExamplepbResponseBodyOutResponse, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbResponseBodyServiceApi) GetResponseBody(data string) (*ExamplepbResponseBodyOutResponse, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -103,7 +103,7 @@ func (a ResponseBodyServiceApi) GetResponseBody(data string) (*ExamplepbResponse * @param data * @return []ExamplepbRepeatedResponseBodyOutResponse */ -func (a ResponseBodyServiceApi) ListResponseBodies(data string) ([]ExamplepbRepeatedResponseBodyOutResponse, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbResponseBodyServiceApi) ListResponseBodies(data string) ([]ExamplepbRepeatedResponseBodyOutResponse, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -163,7 +163,7 @@ func (a ResponseBodyServiceApi) ListResponseBodies(data string) ([]ExamplepbRepe * @param data * @return []string */ -func (a ResponseBodyServiceApi) ListResponseStrings(data string) ([]string, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbResponseBodyServiceApi) ListResponseStrings(data string) ([]string, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables diff --git a/examples/clients/unannotatedecho/BUILD.bazel b/examples/clients/unannotatedecho/BUILD.bazel index 611c6c7052d..7d57f72e9bc 100644 --- a/examples/clients/unannotatedecho/BUILD.bazel +++ b/examples/clients/unannotatedecho/BUILD.bazel @@ -9,7 +9,7 @@ go_library( "api_response.go", "configuration.go", "examplepb_unannotated_simple_message.go", - "unannotated_echo_service_api.go", + "grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/clients/unannotatedecho", deps = ["@com_github_go_resty_resty//:go_default_library"], diff --git a/examples/clients/unannotatedecho/unannotated_echo_service_api.go b/examples/clients/unannotatedecho/grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go similarity index 90% rename from examples/clients/unannotatedecho/unannotated_echo_service_api.go rename to examples/clients/unannotatedecho/grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go index cb3efdde4d4..607cb267b52 100644 --- a/examples/clients/unannotatedecho/unannotated_echo_service_api.go +++ b/examples/clients/unannotatedecho/grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go @@ -17,22 +17,22 @@ import ( "fmt" ) -type UnannotatedEchoServiceApi struct { +type GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi struct { Configuration *Configuration } -func NewUnannotatedEchoServiceApi() *UnannotatedEchoServiceApi { +func NewGrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi() *GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi { configuration := NewConfiguration() - return &UnannotatedEchoServiceApi{ + return &GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi{ Configuration: configuration, } } -func NewUnannotatedEchoServiceApiWithBasePath(basePath string) *UnannotatedEchoServiceApi { +func NewGrpcgatewayexamplesexamplepbUnannotatedEchoServiceApiWithBasePath(basePath string) *GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi { configuration := NewConfiguration() configuration.BasePath = basePath - return &UnannotatedEchoServiceApi{ + return &GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi{ Configuration: configuration, } } @@ -44,7 +44,7 @@ func NewUnannotatedEchoServiceApiWithBasePath(basePath string) *UnannotatedEchoS * @param id Id represents the message identifier. * @return *ExamplepbUnannotatedSimpleMessage */ -func (a UnannotatedEchoServiceApi) Echo(id string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) Echo(id string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -107,7 +107,7 @@ func (a UnannotatedEchoServiceApi) Echo(id string) (*ExamplepbUnannotatedSimpleM * @param duration * @return *ExamplepbUnannotatedSimpleMessage */ -func (a UnannotatedEchoServiceApi) Echo2(id string, num string, duration string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) Echo2(id string, num string, duration string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -169,7 +169,7 @@ func (a UnannotatedEchoServiceApi) Echo2(id string, num string, duration string) * @param body * @return *ExamplepbUnannotatedSimpleMessage */ -func (a UnannotatedEchoServiceApi) EchoBody(body ExamplepbUnannotatedSimpleMessage) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) EchoBody(body ExamplepbUnannotatedSimpleMessage) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -232,7 +232,7 @@ func (a UnannotatedEchoServiceApi) EchoBody(body ExamplepbUnannotatedSimpleMessa * @param duration * @return *ExamplepbUnannotatedSimpleMessage */ -func (a UnannotatedEchoServiceApi) EchoDelete(id string, num string, duration string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) EchoDelete(id string, num string, duration string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables diff --git a/examples/proto/examplepb/a_bit_of_everything.swagger.json b/examples/proto/examplepb/a_bit_of_everything.swagger.json index 3e246b63c78..fc965721821 100644 --- a/examples/proto/examplepb/a_bit_of_everything.swagger.json +++ b/examples/proto/examplepb/a_bit_of_everything.swagger.json @@ -65,7 +65,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } }, @@ -365,7 +365,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ], "deprecated": true, "security": [], @@ -542,7 +542,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } }, @@ -591,7 +591,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } }, @@ -631,7 +631,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] }, "delete": { @@ -669,7 +669,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ], "security": [ { @@ -724,7 +724,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } }, @@ -953,7 +953,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } }, @@ -1001,7 +1001,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] }, "patch": { @@ -1047,7 +1047,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } }, @@ -1183,7 +1183,7 @@ } }, "tags": [ - "camelCaseServiceName" + "grpc.gateway.examples.examplepb.camelCaseServiceName" ] } }, @@ -1215,7 +1215,7 @@ } }, "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } }, @@ -1263,7 +1263,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } }, @@ -1295,7 +1295,7 @@ } }, "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } }, @@ -1343,7 +1343,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } }, @@ -1391,7 +1391,7 @@ } ], "tags": [ - "ABitOfEverythingService" + "grpc.gateway.examples.examplepb.ABitOfEverythingService" ] } } diff --git a/examples/proto/examplepb/echo_service.swagger.json b/examples/proto/examplepb/echo_service.swagger.json index f1687bccf64..9cc32b94522 100644 --- a/examples/proto/examplepb/echo_service.swagger.json +++ b/examples/proto/examplepb/echo_service.swagger.json @@ -39,7 +39,7 @@ } ], "tags": [ - "EchoService" + "grpc.gateway.examples.examplepb.EchoService" ] } }, @@ -119,7 +119,7 @@ } ], "tags": [ - "EchoService" + "grpc.gateway.examples.examplepb.EchoService" ] } }, @@ -199,7 +199,7 @@ } ], "tags": [ - "EchoService" + "grpc.gateway.examples.examplepb.EchoService" ] } }, @@ -273,7 +273,7 @@ } ], "tags": [ - "EchoService" + "grpc.gateway.examples.examplepb.EchoService" ] } }, @@ -347,7 +347,7 @@ } ], "tags": [ - "EchoService" + "grpc.gateway.examples.examplepb.EchoService" ] } }, @@ -374,7 +374,7 @@ } ], "tags": [ - "EchoService" + "grpc.gateway.examples.examplepb.EchoService" ] } }, @@ -453,7 +453,7 @@ } ], "tags": [ - "EchoService" + "grpc.gateway.examples.examplepb.EchoService" ] } } diff --git a/examples/proto/examplepb/response_body_service.swagger.json b/examples/proto/examplepb/response_body_service.swagger.json index 820129e93eb..a56d99e5ba8 100644 --- a/examples/proto/examplepb/response_body_service.swagger.json +++ b/examples/proto/examplepb/response_body_service.swagger.json @@ -38,7 +38,7 @@ } ], "tags": [ - "ResponseBodyService" + "grpc.gateway.examples.examplepb.ResponseBodyService" ] } }, @@ -62,7 +62,7 @@ } ], "tags": [ - "ResponseBodyService" + "grpc.gateway.examples.examplepb.ResponseBodyService" ] } }, @@ -89,7 +89,7 @@ } ], "tags": [ - "ResponseBodyService" + "grpc.gateway.examples.examplepb.ResponseBodyService" ] } } diff --git a/examples/proto/examplepb/stream.swagger.json b/examples/proto/examplepb/stream.swagger.json index 7739b3ea13d..c6bfa70bae4 100644 --- a/examples/proto/examplepb/stream.swagger.json +++ b/examples/proto/examplepb/stream.swagger.json @@ -27,7 +27,7 @@ } }, "tags": [ - "StreamService" + "grpc.gateway.examples.examplepb.StreamService" ] } }, @@ -54,7 +54,7 @@ } ], "tags": [ - "StreamService" + "grpc.gateway.examples.examplepb.StreamService" ] } }, @@ -81,7 +81,7 @@ } ], "tags": [ - "StreamService" + "grpc.gateway.examples.examplepb.StreamService" ] } } diff --git a/examples/proto/examplepb/unannotated_echo_service.swagger.json b/examples/proto/examplepb/unannotated_echo_service.swagger.json index 48825985057..0b265e2fa6b 100644 --- a/examples/proto/examplepb/unannotated_echo_service.swagger.json +++ b/examples/proto/examplepb/unannotated_echo_service.swagger.json @@ -39,7 +39,7 @@ } ], "tags": [ - "UnannotatedEchoService" + "grpc.gateway.examples.examplepb.UnannotatedEchoService" ] } }, @@ -79,7 +79,7 @@ } ], "tags": [ - "UnannotatedEchoService" + "grpc.gateway.examples.examplepb.UnannotatedEchoService" ] } }, @@ -106,7 +106,7 @@ } ], "tags": [ - "UnannotatedEchoService" + "grpc.gateway.examples.examplepb.UnannotatedEchoService" ] } }, @@ -145,7 +145,7 @@ } ], "tags": [ - "UnannotatedEchoService" + "grpc.gateway.examples.examplepb.UnannotatedEchoService" ] } } diff --git a/examples/proto/examplepb/wrappers.swagger.json b/examples/proto/examplepb/wrappers.swagger.json index f45b512e1c6..c3ea1074100 100644 --- a/examples/proto/examplepb/wrappers.swagger.json +++ b/examples/proto/examplepb/wrappers.swagger.json @@ -37,7 +37,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } }, @@ -65,7 +65,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } }, @@ -93,7 +93,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } }, @@ -121,7 +121,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } }, @@ -147,7 +147,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } }, @@ -175,7 +175,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } }, @@ -203,7 +203,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } }, @@ -231,7 +231,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } }, @@ -257,7 +257,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } }, @@ -285,7 +285,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } }, @@ -313,7 +313,7 @@ } ], "tags": [ - "WrappersService" + "grpc.gateway.examples.examplepb.WrappersService" ] } } From 6cc23e54d40b8f1ec8c82da7a42c9f4138f60c96 Mon Sep 17 00:00:00 2001 From: Zilong Wang Date: Mon, 28 Jan 2019 11:19:09 -0500 Subject: [PATCH 4/6] add a boolean flag allow_package_name_in_tags and unit tests --- examples/clients/abe/BUILD.bazel | 2 + ....go => a_bit_of_everything_service_api.go} | 40 ++++++++--------- ..._api.go => camel_case_service_name_api.go} | 12 +++--- examples/clients/echo/BUILD.bazel | 1 + ...cho_service_api.go => echo_service_api.go} | 24 +++++------ examples/clients/responsebody/BUILD.bazel | 1 + ...erviceApi.md => ResponseBodyServiceApi.md} | 8 ++-- ...ce_api.go => response_body_service_api.go} | 16 +++---- examples/clients/unannotatedecho/BUILD.bazel | 1 + ...api.go => unannotated_echo_service_api.go} | 18 ++++---- .../a_bit_of_everything.swagger.json | 32 +++++++------- .../proto/examplepb/echo_service.swagger.json | 14 +++--- .../response_body_service.swagger.json | 6 +-- examples/proto/examplepb/stream.swagger.json | 6 +-- .../unannotated_echo_service.swagger.json | 8 ++-- .../proto/examplepb/wrappers.swagger.json | 22 +++++----- .../descriptor/registry.go | 16 +++++++ protoc-gen-swagger/genswagger/template.go | 2 +- protoc-gen-swagger/main.go | 9 ++++ protoc-gen-swagger/main_test.go | 43 ++++++++++++------- 20 files changed, 162 insertions(+), 119 deletions(-) rename examples/clients/abe/{grpcgatewayexamplesexamplepb_a_bit_of_everything_service_api.go => a_bit_of_everything_service_api.go} (92%) rename examples/clients/abe/{grpcgatewayexamplesexamplepbcamel_case_service_name_api.go => camel_case_service_name_api.go} (85%) rename examples/clients/echo/{grpcgatewayexamplesexamplepb_echo_service_api.go => echo_service_api.go} (92%) rename examples/clients/responsebody/docs/{GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md => ResponseBodyServiceApi.md} (81%) rename examples/clients/responsebody/{grpcgatewayexamplesexamplepb_response_body_service_api.go => response_body_service_api.go} (89%) rename examples/clients/unannotatedecho/{grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go => unannotated_echo_service_api.go} (90%) diff --git a/examples/clients/abe/BUILD.bazel b/examples/clients/abe/BUILD.bazel index a1e2befaca4..94fdf0a6ab4 100644 --- a/examples/clients/abe/BUILD.bazel +++ b/examples/clients/abe/BUILD.bazel @@ -6,8 +6,10 @@ go_library( name = "go_default_library", srcs = [ "a_bit_of_everything_nested.go", + "a_bit_of_everything_service_api.go", "api_client.go", "api_response.go", + "camel_case_service_name_api.go", "configuration.go", "echo_rpc_api.go", "echo_service_api.go", diff --git a/examples/clients/abe/grpcgatewayexamplesexamplepb_a_bit_of_everything_service_api.go b/examples/clients/abe/a_bit_of_everything_service_api.go similarity index 92% rename from examples/clients/abe/grpcgatewayexamplesexamplepb_a_bit_of_everything_service_api.go rename to examples/clients/abe/a_bit_of_everything_service_api.go index 05d65dec7ce..1e8956c2aff 100644 --- a/examples/clients/abe/grpcgatewayexamplesexamplepb_a_bit_of_everything_service_api.go +++ b/examples/clients/abe/a_bit_of_everything_service_api.go @@ -18,22 +18,22 @@ import ( "fmt" ) -type GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi struct { +type ABitOfEverythingServiceApi struct { Configuration *Configuration } -func NewGrpcgatewayexamplesexamplepbABitOfEverythingServiceApi() *GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi { +func NewABitOfEverythingServiceApi() *ABitOfEverythingServiceApi { configuration := NewConfiguration() - return &GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi{ + return &ABitOfEverythingServiceApi{ Configuration: configuration, } } -func NewGrpcgatewayexamplesexamplepbABitOfEverythingServiceApiWithBasePath(basePath string) *GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi { +func NewABitOfEverythingServiceApiWithBasePath(basePath string) *ABitOfEverythingServiceApi { configuration := NewConfiguration() configuration.BasePath = basePath - return &GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi{ + return &ABitOfEverythingServiceApi{ Configuration: configuration, } } @@ -62,7 +62,7 @@ func NewGrpcgatewayexamplesexamplepbABitOfEverythingServiceApiWithBasePath(baseP * @param nestedPathEnumValue * @return *ExamplepbABitOfEverything */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string, enumValue string, pathEnumValue string, nestedPathEnumValue string) (*ExamplepbABitOfEverything, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, uint32Value int64, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, nonConventionalNameValue string, enumValue string, pathEnumValue string, nestedPathEnumValue string) (*ExamplepbABitOfEverything, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -153,7 +153,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Create(floatValu * @param body * @return *ExamplepbABitOfEverything */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -229,7 +229,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) CreateBody(body * @param body * @return *ExamplepbABitOfEverything */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body ExamplepbABitOfEverything) (*ExamplepbABitOfEverything, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -305,7 +305,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) DeepPathEcho(sin * @param uuid * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Delete(uuid string) (*interface{}, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Delete(uuid string) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables @@ -373,7 +373,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Delete(uuid stri * * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) ErrorWithDetails() (*interface{}, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) ErrorWithDetails() (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -447,7 +447,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) ErrorWithDetails * @param body * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) GetMessageWithBody(id string, body ExamplepbBody) (*interface{}, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) GetMessageWithBody(id string, body ExamplepbBody) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -549,7 +549,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) GetMessageWithBo * @param repeatedEnumValue repeated enum value. it is comma-separated in query. - ZERO: ZERO means 0 - ONE: ONE means 1 * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) GetQuery(uuid string, floatValue float32, singleNestedName string, singleNestedAmount int64, singleNestedOk string, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, bytesValue string, uint32Value int64, enumValue string, pathEnumValue string, nestedPathEnumValue string, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, repeatedStringValue []string, oneofString string, nonConventionalNameValue string, timestampValue time.Time, repeatedEnumValue []string) (*interface{}, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) GetQuery(uuid string, floatValue float32, singleNestedName string, singleNestedAmount int64, singleNestedOk string, doubleValue float64, int64Value string, uint64Value string, int32Value int32, fixed64Value string, fixed32Value int64, boolValue bool, stringValue string, bytesValue string, uint32Value int64, enumValue string, pathEnumValue string, nestedPathEnumValue string, sfixed32Value int32, sfixed64Value string, sint32Value int32, sint64Value string, repeatedStringValue []string, oneofString string, nonConventionalNameValue string, timestampValue time.Time, repeatedEnumValue []string) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -655,7 +655,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) GetQuery(uuid st * @param pathRepeatedSint64Value * @return *ExamplepbABitOfEverythingRepeated */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) GetRepeatedQuery(pathRepeatedFloatValue []float32, pathRepeatedDoubleValue []float64, pathRepeatedInt64Value []string, pathRepeatedUint64Value []string, pathRepeatedInt32Value []int32, pathRepeatedFixed64Value []string, pathRepeatedFixed32Value []int64, pathRepeatedBoolValue []bool, pathRepeatedStringValue []string, pathRepeatedBytesValue []string, pathRepeatedUint32Value []int64, pathRepeatedEnumValue []string, pathRepeatedSfixed32Value []int32, pathRepeatedSfixed64Value []string, pathRepeatedSint32Value []int32, pathRepeatedSint64Value []string) (*ExamplepbABitOfEverythingRepeated, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) GetRepeatedQuery(pathRepeatedFloatValue []float32, pathRepeatedDoubleValue []float64, pathRepeatedInt64Value []string, pathRepeatedUint64Value []string, pathRepeatedInt32Value []int32, pathRepeatedFixed64Value []string, pathRepeatedFixed32Value []int64, pathRepeatedBoolValue []bool, pathRepeatedStringValue []string, pathRepeatedBytesValue []string, pathRepeatedUint32Value []int64, pathRepeatedEnumValue []string, pathRepeatedSfixed32Value []int32, pathRepeatedSfixed64Value []string, pathRepeatedSint32Value []int32, pathRepeatedSint64Value []string) (*ExamplepbABitOfEverythingRepeated, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -744,7 +744,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) GetRepeatedQuery * @param uuid * @return *ExamplepbABitOfEverything */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEverything, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEverything, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -819,7 +819,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Lookup(uuid stri * @param body * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) PatchWithFieldMaskInBody(abeUuid string, body ExamplepbUpdateV2Request) (*interface{}, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) PatchWithFieldMaskInBody(abeUuid string, body ExamplepbUpdateV2Request) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Patch") // create path and map variables @@ -896,7 +896,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) PatchWithFieldMa * @param body * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) PostWithEmptyBody(name string, body ExamplepbBody) (*interface{}, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) PostWithEmptyBody(name string, body ExamplepbBody) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -971,7 +971,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) PostWithEmptyBod * * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Timeout() (*interface{}, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Timeout() (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -1045,7 +1045,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Timeout() (*inte * @param body * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Put") // create path and map variables @@ -1122,7 +1122,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) Update(uuid stri * @param body * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) UpdateV2(abeUuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) UpdateV2(abeUuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Put") // create path and map variables @@ -1199,7 +1199,7 @@ func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) UpdateV2(abeUuid * @param body * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbABitOfEverythingServiceApi) UpdateV22(abeUuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) UpdateV22(abeUuid string, body ExamplepbABitOfEverything) (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Patch") // create path and map variables diff --git a/examples/clients/abe/grpcgatewayexamplesexamplepbcamel_case_service_name_api.go b/examples/clients/abe/camel_case_service_name_api.go similarity index 85% rename from examples/clients/abe/grpcgatewayexamplesexamplepbcamel_case_service_name_api.go rename to examples/clients/abe/camel_case_service_name_api.go index 65d1bb76705..d761b19786c 100644 --- a/examples/clients/abe/grpcgatewayexamplesexamplepbcamel_case_service_name_api.go +++ b/examples/clients/abe/camel_case_service_name_api.go @@ -16,22 +16,22 @@ import ( "encoding/json" ) -type GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi struct { +type CamelCaseServiceNameApi struct { Configuration *Configuration } -func NewGrpcgatewayexamplesexamplepbcamelCaseServiceNameApi() *GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi { +func NewCamelCaseServiceNameApi() *CamelCaseServiceNameApi { configuration := NewConfiguration() - return &GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi{ + return &CamelCaseServiceNameApi{ Configuration: configuration, } } -func NewGrpcgatewayexamplesexamplepbcamelCaseServiceNameApiWithBasePath(basePath string) *GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi { +func NewCamelCaseServiceNameApiWithBasePath(basePath string) *CamelCaseServiceNameApi { configuration := NewConfiguration() configuration.BasePath = basePath - return &GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi{ + return &CamelCaseServiceNameApi{ Configuration: configuration, } } @@ -41,7 +41,7 @@ func NewGrpcgatewayexamplesexamplepbcamelCaseServiceNameApiWithBasePath(basePath * * @return *interface{} */ -func (a GrpcgatewayexamplesexamplepbcamelCaseServiceNameApi) Empty() (*interface{}, *APIResponse, error) { +func (a CamelCaseServiceNameApi) Empty() (*interface{}, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables diff --git a/examples/clients/echo/BUILD.bazel b/examples/clients/echo/BUILD.bazel index 402d328ccf0..cf0f687dae8 100644 --- a/examples/clients/echo/BUILD.bazel +++ b/examples/clients/echo/BUILD.bazel @@ -8,6 +8,7 @@ go_library( "api_client.go", "api_response.go", "configuration.go", + "echo_service_api.go", "examplepb_embedded.go", "examplepb_simple_message.go", "grpcgatewayexamplesexamplepb_echo_service_api.go", diff --git a/examples/clients/echo/grpcgatewayexamplesexamplepb_echo_service_api.go b/examples/clients/echo/echo_service_api.go similarity index 92% rename from examples/clients/echo/grpcgatewayexamplesexamplepb_echo_service_api.go rename to examples/clients/echo/echo_service_api.go index fd29a8ff90d..6ae7cf85a32 100644 --- a/examples/clients/echo/grpcgatewayexamplesexamplepb_echo_service_api.go +++ b/examples/clients/echo/echo_service_api.go @@ -17,22 +17,22 @@ import ( "fmt" ) -type GrpcgatewayexamplesexamplepbEchoServiceApi struct { +type EchoServiceApi struct { Configuration *Configuration } -func NewGrpcgatewayexamplesexamplepbEchoServiceApi() *GrpcgatewayexamplesexamplepbEchoServiceApi { +func NewEchoServiceApi() *EchoServiceApi { configuration := NewConfiguration() - return &GrpcgatewayexamplesexamplepbEchoServiceApi{ + return &EchoServiceApi{ Configuration: configuration, } } -func NewGrpcgatewayexamplesexamplepbEchoServiceApiWithBasePath(basePath string) *GrpcgatewayexamplesexamplepbEchoServiceApi { +func NewEchoServiceApiWithBasePath(basePath string) *EchoServiceApi { configuration := NewConfiguration() configuration.BasePath = basePath - return &GrpcgatewayexamplesexamplepbEchoServiceApi{ + return &EchoServiceApi{ Configuration: configuration, } } @@ -44,7 +44,7 @@ func NewGrpcgatewayexamplesexamplepbEchoServiceApiWithBasePath(basePath string) * @param id Id represents the message identifier. * @return *ExamplepbSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo(id string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) Echo(id string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -113,7 +113,7 @@ func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo(id string) (*ExamplepbS * @param noNote * @return *ExamplepbSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo2(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) Echo2(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -190,7 +190,7 @@ func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo2(id string, num string, * @param noNote * @return *ExamplepbSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo3(id string, num string, lang string, lineNum string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) Echo3(id string, num string, lang string, lineNum string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -266,7 +266,7 @@ func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo3(id string, num string, * @param noProgress * @return *ExamplepbSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo4(id string, lineNum string, statusNote string, num string, lang string, statusProgress string, en string, noProgress string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) Echo4(id string, lineNum string, statusNote string, num string, lang string, statusProgress string, en string, noProgress string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -341,7 +341,7 @@ func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo4(id string, lineNum str * @param noProgress * @return *ExamplepbSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo5(noNote string, id string, num string, lineNum string, lang string, statusProgress string, en string, noProgress string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) Echo5(noNote string, id string, num string, lineNum string, lang string, statusProgress string, en string, noProgress string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -408,7 +408,7 @@ func (a GrpcgatewayexamplesexamplepbEchoServiceApi) Echo5(noNote string, id stri * @param body * @return *ExamplepbSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbEchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -477,7 +477,7 @@ func (a GrpcgatewayexamplesexamplepbEchoServiceApi) EchoBody(body ExamplepbSimpl * @param noNote * @return *ExamplepbSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbEchoServiceApi) EchoDelete(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) EchoDelete(id string, num string, lineNum string, lang string, statusProgress string, statusNote string, en string, noProgress string, noNote string) (*ExamplepbSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables diff --git a/examples/clients/responsebody/BUILD.bazel b/examples/clients/responsebody/BUILD.bazel index 4f8fdd8a49d..5778b6d4452 100644 --- a/examples/clients/responsebody/BUILD.bazel +++ b/examples/clients/responsebody/BUILD.bazel @@ -15,6 +15,7 @@ go_library( "examplepb_response_body_out_response.go", "examplepb_response_body_req.go", "grpcgatewayexamplesexamplepb_response_body_service_api.go", + "response_body_service_api.go", "response_response_type.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/clients/responsebody", diff --git a/examples/clients/responsebody/docs/GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md b/examples/clients/responsebody/docs/ResponseBodyServiceApi.md similarity index 81% rename from examples/clients/responsebody/docs/GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md rename to examples/clients/responsebody/docs/ResponseBodyServiceApi.md index fdafd8089ec..458725faa9b 100644 --- a/examples/clients/responsebody/docs/GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md +++ b/examples/clients/responsebody/docs/ResponseBodyServiceApi.md @@ -1,12 +1,12 @@ -# \GrpcgatewayexamplesexamplepbResponseBodyServiceApi +# \ResponseBodyServiceApi All URIs are relative to *http://localhost* Method | HTTP request | Description ------------- | ------------- | ------------- -[**GetResponseBody**](GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md#GetResponseBody) | **Get** /responsebody/{data} | -[**ListResponseBodies**](GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md#ListResponseBodies) | **Get** /responsebodies/{data} | -[**ListResponseStrings**](GrpcgatewayexamplesexamplepbResponseBodyServiceApi.md#ListResponseStrings) | **Get** /responsestrings/{data} | +[**GetResponseBody**](ResponseBodyServiceApi.md#GetResponseBody) | **Get** /responsebody/{data} | +[**ListResponseBodies**](ResponseBodyServiceApi.md#ListResponseBodies) | **Get** /responsebodies/{data} | +[**ListResponseStrings**](ResponseBodyServiceApi.md#ListResponseStrings) | **Get** /responsestrings/{data} | # **GetResponseBody** diff --git a/examples/clients/responsebody/grpcgatewayexamplesexamplepb_response_body_service_api.go b/examples/clients/responsebody/response_body_service_api.go similarity index 89% rename from examples/clients/responsebody/grpcgatewayexamplesexamplepb_response_body_service_api.go rename to examples/clients/responsebody/response_body_service_api.go index 5b6aac5778f..000cecd6ddd 100644 --- a/examples/clients/responsebody/grpcgatewayexamplesexamplepb_response_body_service_api.go +++ b/examples/clients/responsebody/response_body_service_api.go @@ -17,22 +17,22 @@ import ( "fmt" ) -type GrpcgatewayexamplesexamplepbResponseBodyServiceApi struct { +type ResponseBodyServiceApi struct { Configuration *Configuration } -func NewGrpcgatewayexamplesexamplepbResponseBodyServiceApi() *GrpcgatewayexamplesexamplepbResponseBodyServiceApi { +func NewResponseBodyServiceApi() *ResponseBodyServiceApi { configuration := NewConfiguration() - return &GrpcgatewayexamplesexamplepbResponseBodyServiceApi{ + return &ResponseBodyServiceApi{ Configuration: configuration, } } -func NewGrpcgatewayexamplesexamplepbResponseBodyServiceApiWithBasePath(basePath string) *GrpcgatewayexamplesexamplepbResponseBodyServiceApi { +func NewResponseBodyServiceApiWithBasePath(basePath string) *ResponseBodyServiceApi { configuration := NewConfiguration() configuration.BasePath = basePath - return &GrpcgatewayexamplesexamplepbResponseBodyServiceApi{ + return &ResponseBodyServiceApi{ Configuration: configuration, } } @@ -43,7 +43,7 @@ func NewGrpcgatewayexamplesexamplepbResponseBodyServiceApiWithBasePath(basePath * @param data * @return *ExamplepbResponseBodyOutResponse */ -func (a GrpcgatewayexamplesexamplepbResponseBodyServiceApi) GetResponseBody(data string) (*ExamplepbResponseBodyOutResponse, *APIResponse, error) { +func (a ResponseBodyServiceApi) GetResponseBody(data string) (*ExamplepbResponseBodyOutResponse, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -103,7 +103,7 @@ func (a GrpcgatewayexamplesexamplepbResponseBodyServiceApi) GetResponseBody(data * @param data * @return []ExamplepbRepeatedResponseBodyOutResponse */ -func (a GrpcgatewayexamplesexamplepbResponseBodyServiceApi) ListResponseBodies(data string) ([]ExamplepbRepeatedResponseBodyOutResponse, *APIResponse, error) { +func (a ResponseBodyServiceApi) ListResponseBodies(data string) ([]ExamplepbRepeatedResponseBodyOutResponse, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -163,7 +163,7 @@ func (a GrpcgatewayexamplesexamplepbResponseBodyServiceApi) ListResponseBodies(d * @param data * @return []string */ -func (a GrpcgatewayexamplesexamplepbResponseBodyServiceApi) ListResponseStrings(data string) ([]string, *APIResponse, error) { +func (a ResponseBodyServiceApi) ListResponseStrings(data string) ([]string, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables diff --git a/examples/clients/unannotatedecho/BUILD.bazel b/examples/clients/unannotatedecho/BUILD.bazel index 7d57f72e9bc..ecd43c86cd5 100644 --- a/examples/clients/unannotatedecho/BUILD.bazel +++ b/examples/clients/unannotatedecho/BUILD.bazel @@ -10,6 +10,7 @@ go_library( "configuration.go", "examplepb_unannotated_simple_message.go", "grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go", + "unannotated_echo_service_api.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/clients/unannotatedecho", deps = ["@com_github_go_resty_resty//:go_default_library"], diff --git a/examples/clients/unannotatedecho/grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go b/examples/clients/unannotatedecho/unannotated_echo_service_api.go similarity index 90% rename from examples/clients/unannotatedecho/grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go rename to examples/clients/unannotatedecho/unannotated_echo_service_api.go index 607cb267b52..cb3efdde4d4 100644 --- a/examples/clients/unannotatedecho/grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go +++ b/examples/clients/unannotatedecho/unannotated_echo_service_api.go @@ -17,22 +17,22 @@ import ( "fmt" ) -type GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi struct { +type UnannotatedEchoServiceApi struct { Configuration *Configuration } -func NewGrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi() *GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi { +func NewUnannotatedEchoServiceApi() *UnannotatedEchoServiceApi { configuration := NewConfiguration() - return &GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi{ + return &UnannotatedEchoServiceApi{ Configuration: configuration, } } -func NewGrpcgatewayexamplesexamplepbUnannotatedEchoServiceApiWithBasePath(basePath string) *GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi { +func NewUnannotatedEchoServiceApiWithBasePath(basePath string) *UnannotatedEchoServiceApi { configuration := NewConfiguration() configuration.BasePath = basePath - return &GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi{ + return &UnannotatedEchoServiceApi{ Configuration: configuration, } } @@ -44,7 +44,7 @@ func NewGrpcgatewayexamplesexamplepbUnannotatedEchoServiceApiWithBasePath(basePa * @param id Id represents the message identifier. * @return *ExamplepbUnannotatedSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) Echo(id string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +func (a UnannotatedEchoServiceApi) Echo(id string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -107,7 +107,7 @@ func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) Echo(id string) ( * @param duration * @return *ExamplepbUnannotatedSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) Echo2(id string, num string, duration string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +func (a UnannotatedEchoServiceApi) Echo2(id string, num string, duration string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables @@ -169,7 +169,7 @@ func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) Echo2(id string, * @param body * @return *ExamplepbUnannotatedSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) EchoBody(body ExamplepbUnannotatedSimpleMessage) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +func (a UnannotatedEchoServiceApi) EchoBody(body ExamplepbUnannotatedSimpleMessage) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables @@ -232,7 +232,7 @@ func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) EchoBody(body Exa * @param duration * @return *ExamplepbUnannotatedSimpleMessage */ -func (a GrpcgatewayexamplesexamplepbUnannotatedEchoServiceApi) EchoDelete(id string, num string, duration string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { +func (a UnannotatedEchoServiceApi) EchoDelete(id string, num string, duration string) (*ExamplepbUnannotatedSimpleMessage, *APIResponse, error) { var localVarHttpMethod = strings.ToUpper("Delete") // create path and map variables diff --git a/examples/proto/examplepb/a_bit_of_everything.swagger.json b/examples/proto/examplepb/a_bit_of_everything.swagger.json index fc965721821..3e246b63c78 100644 --- a/examples/proto/examplepb/a_bit_of_everything.swagger.json +++ b/examples/proto/examplepb/a_bit_of_everything.swagger.json @@ -65,7 +65,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } }, @@ -365,7 +365,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ], "deprecated": true, "security": [], @@ -542,7 +542,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } }, @@ -591,7 +591,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } }, @@ -631,7 +631,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] }, "delete": { @@ -669,7 +669,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ], "security": [ { @@ -724,7 +724,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } }, @@ -953,7 +953,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } }, @@ -1001,7 +1001,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] }, "patch": { @@ -1047,7 +1047,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } }, @@ -1183,7 +1183,7 @@ } }, "tags": [ - "grpc.gateway.examples.examplepb.camelCaseServiceName" + "camelCaseServiceName" ] } }, @@ -1215,7 +1215,7 @@ } }, "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } }, @@ -1263,7 +1263,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } }, @@ -1295,7 +1295,7 @@ } }, "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } }, @@ -1343,7 +1343,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } }, @@ -1391,7 +1391,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ABitOfEverythingService" + "ABitOfEverythingService" ] } } diff --git a/examples/proto/examplepb/echo_service.swagger.json b/examples/proto/examplepb/echo_service.swagger.json index 9cc32b94522..f1687bccf64 100644 --- a/examples/proto/examplepb/echo_service.swagger.json +++ b/examples/proto/examplepb/echo_service.swagger.json @@ -39,7 +39,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.EchoService" + "EchoService" ] } }, @@ -119,7 +119,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.EchoService" + "EchoService" ] } }, @@ -199,7 +199,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.EchoService" + "EchoService" ] } }, @@ -273,7 +273,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.EchoService" + "EchoService" ] } }, @@ -347,7 +347,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.EchoService" + "EchoService" ] } }, @@ -374,7 +374,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.EchoService" + "EchoService" ] } }, @@ -453,7 +453,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.EchoService" + "EchoService" ] } } diff --git a/examples/proto/examplepb/response_body_service.swagger.json b/examples/proto/examplepb/response_body_service.swagger.json index a56d99e5ba8..820129e93eb 100644 --- a/examples/proto/examplepb/response_body_service.swagger.json +++ b/examples/proto/examplepb/response_body_service.swagger.json @@ -38,7 +38,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ResponseBodyService" + "ResponseBodyService" ] } }, @@ -62,7 +62,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ResponseBodyService" + "ResponseBodyService" ] } }, @@ -89,7 +89,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.ResponseBodyService" + "ResponseBodyService" ] } } diff --git a/examples/proto/examplepb/stream.swagger.json b/examples/proto/examplepb/stream.swagger.json index c6bfa70bae4..7739b3ea13d 100644 --- a/examples/proto/examplepb/stream.swagger.json +++ b/examples/proto/examplepb/stream.swagger.json @@ -27,7 +27,7 @@ } }, "tags": [ - "grpc.gateway.examples.examplepb.StreamService" + "StreamService" ] } }, @@ -54,7 +54,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.StreamService" + "StreamService" ] } }, @@ -81,7 +81,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.StreamService" + "StreamService" ] } } diff --git a/examples/proto/examplepb/unannotated_echo_service.swagger.json b/examples/proto/examplepb/unannotated_echo_service.swagger.json index 0b265e2fa6b..48825985057 100644 --- a/examples/proto/examplepb/unannotated_echo_service.swagger.json +++ b/examples/proto/examplepb/unannotated_echo_service.swagger.json @@ -39,7 +39,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.UnannotatedEchoService" + "UnannotatedEchoService" ] } }, @@ -79,7 +79,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.UnannotatedEchoService" + "UnannotatedEchoService" ] } }, @@ -106,7 +106,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.UnannotatedEchoService" + "UnannotatedEchoService" ] } }, @@ -145,7 +145,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.UnannotatedEchoService" + "UnannotatedEchoService" ] } } diff --git a/examples/proto/examplepb/wrappers.swagger.json b/examples/proto/examplepb/wrappers.swagger.json index c3ea1074100..f45b512e1c6 100644 --- a/examples/proto/examplepb/wrappers.swagger.json +++ b/examples/proto/examplepb/wrappers.swagger.json @@ -37,7 +37,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } }, @@ -65,7 +65,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } }, @@ -93,7 +93,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } }, @@ -121,7 +121,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } }, @@ -147,7 +147,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } }, @@ -175,7 +175,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } }, @@ -203,7 +203,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } }, @@ -231,7 +231,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } }, @@ -257,7 +257,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } }, @@ -285,7 +285,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } }, @@ -313,7 +313,7 @@ } ], "tags": [ - "grpc.gateway.examples.examplepb.WrappersService" + "WrappersService" ] } } diff --git a/protoc-gen-grpc-gateway/descriptor/registry.go b/protoc-gen-grpc-gateway/descriptor/registry.go index 9a201112b0a..6f525202d62 100644 --- a/protoc-gen-grpc-gateway/descriptor/registry.go +++ b/protoc-gen-grpc-gateway/descriptor/registry.go @@ -50,6 +50,10 @@ type Registry struct { // allowRepeatedFieldsInBody permits repeated field in body field path of `google.api.http` annotation option allowRepeatedFieldsInBody bool + // allowPackageNameInTags controls whether the package name defined in the `package` directive + // in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation. + allowPackageNameInTags bool + // repeatedPathParamSeparator specifies how path parameter repeated fields are separated repeatedPathParamSeparator repeatedFieldSeparator @@ -350,6 +354,18 @@ func (r *Registry) IsAllowRepeatedFieldsInBody() bool { return r.allowRepeatedFieldsInBody } +// SetAllowPackageNameInTags controls whether the package name defined in the `package` directive +// in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation. +func (r *Registry) SetAllowPackageNameInTags(allow bool) { + r.allowPackageNameInTags = allow +} + +// IsAllowPackageNameInTags checks whether the package name defined in the `package` directive +// in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation. +func (r *Registry) IsAllowPackageNameInTags() bool { + return r.allowPackageNameInTags +} + // GetRepeatedPathParamSeparator returns a rune spcifying how // path parameter repeated fields are separated. func (r *Registry) GetRepeatedPathParamSeparator() rune { diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 5dba2fe3e79..0ef520b51ac 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -822,7 +822,7 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re } tag := svc.GetName() - if pkg := svc.File.GetPackage(); pkg != "" { + if pkg := svc.File.GetPackage(); pkg != "" && reg.IsAllowPackageNameInTags() { tag = pkg + "." + tag } diff --git a/protoc-gen-swagger/main.go b/protoc-gen-swagger/main.go index a4d11fd1ef5..e04582d7472 100644 --- a/protoc-gen-swagger/main.go +++ b/protoc-gen-swagger/main.go @@ -25,6 +25,7 @@ var ( repeatedPathParamSeparator = flag.String("repeated_path_param_separator", "csv", "configures how repeated fields should be split. Allowed values are `csv`, `pipes`, `ssv` and `tsv`.") versionFlag = flag.Bool("version", false, "print the current verison") allowRepeatedFieldsInBody = flag.Bool("allow_repeated_fields_in_body", false, "allows to use repeated field in `body` and `response_body` field of `google.api.http` annotation option") + allowPackageNameInTags = flag.Bool("allow_package_name_in_tags", false, "if unset, the gRPC service name is added to the `Tags` field of each operation. if set and the `package` directive is shown in the proto file, the package name will be prepended to the service name") ) // Variables set by goreleaser at build time @@ -74,6 +75,7 @@ func main() { reg.SetMergeFileName(*mergeFileName) reg.SetUseJSONNamesForFields(*useJSONNamesForFields) reg.SetAllowRepeatedFieldsInBody(*allowRepeatedFieldsInBody) + reg.SetAllowPackageNameInTags(*allowPackageNameInTags) if err := reg.SetRepeatedPathParamSeparator(*repeatedPathParamSeparator); err != nil { emitError(err) return @@ -168,6 +170,13 @@ func parseReqParam(param string, f *flag.FlagSet, pkgMap map[string]string) erro } continue } + if spec[0] == "allow_package_name_in_tags" { + err := f.Set(spec[0], "true") + if err != nil { + return fmt.Errorf("Cannot set flag %s: %v", p, err) + } + continue + } err := f.Set(spec[0], "") if err != nil { return fmt.Errorf("Cannot set flag %s: %v", p, err) diff --git a/protoc-gen-swagger/main_test.go b/protoc-gen-swagger/main_test.go index dc8e09bdb12..5f71a414b87 100644 --- a/protoc-gen-swagger/main_test.go +++ b/protoc-gen-swagger/main_test.go @@ -17,6 +17,7 @@ func TestParseReqParam(t *testing.T) { allowDeleteBodyV bool allowMergeV bool allowRepeatedFieldsInBodyV bool + allowPackageNameInTagsV bool fileV string importPathV string mergeFileNameV string @@ -28,35 +29,35 @@ func TestParseReqParam(t *testing.T) { name: "Test 0", expected: map[string]string{}, request: "", - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, fileV: "-", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 1", expected: map[string]string{"google/api/annotations.proto": "github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api"}, - request: "allow_delete_body,allow_merge,allow_repeated_fields_in_body,file=./foo.pb,import_prefix=/bar/baz,Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api", - allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, + request: "allow_delete_body,allow_merge,allow_repeated_fields_in_body,allow_package_name_in_tags,file=./foo.pb,import_prefix=/bar/baz,Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api", + allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, allowPackageNameInTagsV: true, fileV: "./foo.pb", importPathV: "/bar/baz", mergeFileNameV: "apidocs", }, { name: "Test 2", expected: map[string]string{"google/api/annotations.proto": "github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api"}, - request: "allow_delete_body=true,allow_merge=true,allow_repeated_fields_in_body=true,merge_file_name=test_name,file=./foo.pb,import_prefix=/bar/baz,Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api", - allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, + request: "allow_delete_body=true,allow_merge=true,allow_repeated_fields_in_body=true,allow_package_name_in_tags=true,merge_file_name=test_name,file=./foo.pb,import_prefix=/bar/baz,Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api", + allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, allowPackageNameInTagsV: true, fileV: "./foo.pb", importPathV: "/bar/baz", mergeFileNameV: "test_name", }, { name: "Test 3", expected: map[string]string{"a/b/c.proto": "github.com/x/y/z", "f/g/h.proto": "github.com/1/2/3/"}, request: "allow_delete_body=false,allow_merge=false,Ma/b/c.proto=github.com/x/y/z,Mf/g/h.proto=github.com/1/2/3/", - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 4", expected: map[string]string{}, request: "", - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { @@ -64,7 +65,7 @@ func TestParseReqParam(t *testing.T) { expected: map[string]string{}, request: "unknown_param=17", expectedError: errors.New("Cannot set flag unknown_param=17: no such flag -unknown_param"), - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { @@ -72,14 +73,14 @@ func TestParseReqParam(t *testing.T) { expected: map[string]string{}, request: "Mfoo", expectedError: errors.New("Cannot set flag Mfoo: no such flag -Mfoo"), - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 7", expected: map[string]string{}, - request: "allow_delete_body,file,import_prefix,allow_merge,allow_repeated_fields_in_body,merge_file_name", - allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, + request: "allow_delete_body,file,import_prefix,allow_merge,allow_repeated_fields_in_body,allow_package_name_in_tags,merge_file_name", + allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, allowPackageNameInTagsV: true, fileV: "", importPathV: "", mergeFileNameV: "", }, { @@ -87,9 +88,17 @@ func TestParseReqParam(t *testing.T) { expected: map[string]string{}, request: "allow_delete_body,file,import_prefix,allow_merge,allow_repeated_fields_in_body=3,merge_file_name", expectedError: errors.New(`Cannot set flag allow_repeated_fields_in_body=3: strconv.ParseBool: parsing "3": invalid syntax`), - allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: false, + allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, fileV: "", importPathV: "", mergeFileNameV: "apidocs", }, + { + name: "Test 9", + expected: map[string]string{}, + request: "allow_package_name_in_tags=3", + expectedError: errors.New(`Cannot set flag allow_package_name_in_tags=3: strconv.ParseBool: parsing "3": invalid syntax`), + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, + fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", + }, } for i, tc := range testcases { @@ -112,10 +121,10 @@ func TestParseReqParam(t *testing.T) { tt.Errorf("pkgMap parse error, expected '%v', got '%v'", tc.expected, pkgMap) } if err.Error() != tc.expectedError.Error() { - tt.Errorf("expected error malformed, expected %q, go %q", tc.expectedError.Error(), err.Error()) + tt.Errorf("expected error malformed, expected %q, got %q", tc.expectedError.Error(), err.Error()) } } - checkFlags(tc.allowDeleteBodyV, tc.allowMergeV, tc.allowRepeatedFieldsInBodyV, tc.fileV, tc.importPathV, tc.mergeFileNameV, tt, i) + checkFlags(tc.allowDeleteBodyV, tc.allowMergeV, tc.allowRepeatedFieldsInBodyV, tc.allowPackageNameInTagsV, tc.fileV, tc.importPathV, tc.mergeFileNameV, tt, i) clearFlags() }) @@ -123,7 +132,7 @@ func TestParseReqParam(t *testing.T) { } -func checkFlags(allowDeleteV, allowMergeV, allowRepeatedFieldsInBodyV bool, fileV, importPathV, mergeFileNameV string, t *testing.T, tid int) { +func checkFlags(allowDeleteV, allowMergeV, allowRepeatedFieldsInBodyV, allowPackageNameInTagsV bool, fileV, importPathV, mergeFileNameV string, t *testing.T, tid int) { if *importPrefix != importPathV { t.Errorf("Test %v: import_prefix misparsed, expected '%v', got '%v'", tid, importPathV, *importPrefix) } @@ -142,6 +151,9 @@ func checkFlags(allowDeleteV, allowMergeV, allowRepeatedFieldsInBodyV bool, file if *allowRepeatedFieldsInBody != allowRepeatedFieldsInBodyV { t.Errorf("Test %v: allow_repeated_fields_in_body misparsed, expected '%v', got '%v'", tid, allowRepeatedFieldsInBodyV, *allowRepeatedFieldsInBody) } + if *allowPackageNameInTags != allowPackageNameInTagsV { + t.Errorf("Test %v: allow_repeated_fields_in_body misparsed, expected '%v', got '%v'", tid, allowPackageNameInTagsV, *allowPackageNameInTags) + } } func clearFlags() { @@ -150,5 +162,6 @@ func clearFlags() { *allowDeleteBody = false *allowMerge = false *allowRepeatedFieldsInBody = false + *allowPackageNameInTags = false *mergeFileName = "apidocs" } From 884b7d24e05d047b72c6bcc99ec455e233f2fcce Mon Sep 17 00:00:00 2001 From: Zilong Wang Date: Mon, 28 Jan 2019 11:25:40 -0500 Subject: [PATCH 5/6] update bazel files --- examples/clients/abe/BUILD.bazel | 2 -- examples/clients/echo/BUILD.bazel | 1 - examples/clients/responsebody/BUILD.bazel | 1 - examples/clients/unannotatedecho/BUILD.bazel | 1 - 4 files changed, 5 deletions(-) diff --git a/examples/clients/abe/BUILD.bazel b/examples/clients/abe/BUILD.bazel index 94fdf0a6ab4..4d3c3546e93 100644 --- a/examples/clients/abe/BUILD.bazel +++ b/examples/clients/abe/BUILD.bazel @@ -19,8 +19,6 @@ go_library( "examplepb_body.go", "examplepb_numeric_enum.go", "examplepb_update_v2_request.go", - "grpcgatewayexamplesexamplepb_a_bit_of_everything_service_api.go", - "grpcgatewayexamplesexamplepbcamel_case_service_name_api.go", "message_path_enum_nested_path_enum.go", "nested_deep_enum.go", "pathenum_path_enum.go", diff --git a/examples/clients/echo/BUILD.bazel b/examples/clients/echo/BUILD.bazel index cf0f687dae8..090b56aafab 100644 --- a/examples/clients/echo/BUILD.bazel +++ b/examples/clients/echo/BUILD.bazel @@ -11,7 +11,6 @@ go_library( "echo_service_api.go", "examplepb_embedded.go", "examplepb_simple_message.go", - "grpcgatewayexamplesexamplepb_echo_service_api.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/clients/echo", deps = ["@com_github_go_resty_resty//:go_default_library"], diff --git a/examples/clients/responsebody/BUILD.bazel b/examples/clients/responsebody/BUILD.bazel index 5778b6d4452..e621bea6960 100644 --- a/examples/clients/responsebody/BUILD.bazel +++ b/examples/clients/responsebody/BUILD.bazel @@ -14,7 +14,6 @@ go_library( "examplepb_response_body_out.go", "examplepb_response_body_out_response.go", "examplepb_response_body_req.go", - "grpcgatewayexamplesexamplepb_response_body_service_api.go", "response_body_service_api.go", "response_response_type.go", ], diff --git a/examples/clients/unannotatedecho/BUILD.bazel b/examples/clients/unannotatedecho/BUILD.bazel index ecd43c86cd5..611c6c7052d 100644 --- a/examples/clients/unannotatedecho/BUILD.bazel +++ b/examples/clients/unannotatedecho/BUILD.bazel @@ -9,7 +9,6 @@ go_library( "api_response.go", "configuration.go", "examplepb_unannotated_simple_message.go", - "grpcgatewayexamplesexamplepb_unannotated_echo_service_api.go", "unannotated_echo_service_api.go", ], importpath = "github.com/grpc-ecosystem/grpc-gateway/examples/clients/unannotatedecho", From d42349673409537de1ec6fa24d2965dc4cb5aa83 Mon Sep 17 00:00:00 2001 From: Zilong Wang Date: Mon, 28 Jan 2019 15:35:27 -0500 Subject: [PATCH 6/6] rename the flag to include_package_in_tags --- .../descriptor/registry.go | 18 ++++---- protoc-gen-swagger/genswagger/template.go | 2 +- protoc-gen-swagger/main.go | 6 +-- protoc-gen-swagger/main_test.go | 42 +++++++++---------- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/protoc-gen-grpc-gateway/descriptor/registry.go b/protoc-gen-grpc-gateway/descriptor/registry.go index 6f525202d62..510ab253830 100644 --- a/protoc-gen-grpc-gateway/descriptor/registry.go +++ b/protoc-gen-grpc-gateway/descriptor/registry.go @@ -50,10 +50,10 @@ type Registry struct { // allowRepeatedFieldsInBody permits repeated field in body field path of `google.api.http` annotation option allowRepeatedFieldsInBody bool - // allowPackageNameInTags controls whether the package name defined in the `package` directive + // includePackageInTags controls whether the package name defined in the `package` directive // in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation. - allowPackageNameInTags bool - + includePackageInTags bool + // repeatedPathParamSeparator specifies how path parameter repeated fields are separated repeatedPathParamSeparator repeatedFieldSeparator @@ -354,16 +354,16 @@ func (r *Registry) IsAllowRepeatedFieldsInBody() bool { return r.allowRepeatedFieldsInBody } -// SetAllowPackageNameInTags controls whether the package name defined in the `package` directive +// SetIncludePackageInTags controls whether the package name defined in the `package` directive // in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation. -func (r *Registry) SetAllowPackageNameInTags(allow bool) { - r.allowPackageNameInTags = allow +func (r *Registry) SetIncludePackageInTags(allow bool) { + r.includePackageInTags = allow } -// IsAllowPackageNameInTags checks whether the package name defined in the `package` directive +// IsIncludePackageInTags checks whether the package name defined in the `package` directive // in the proto file can be prepended to the gRPC service name in the `Tags` field of every operation. -func (r *Registry) IsAllowPackageNameInTags() bool { - return r.allowPackageNameInTags +func (r *Registry) IsIncludePackageInTags() bool { + return r.includePackageInTags } // GetRepeatedPathParamSeparator returns a rune spcifying how diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 0ef520b51ac..fcc98b1f51f 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -822,7 +822,7 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re } tag := svc.GetName() - if pkg := svc.File.GetPackage(); pkg != "" && reg.IsAllowPackageNameInTags() { + if pkg := svc.File.GetPackage(); pkg != "" && reg.IsIncludePackageInTags() { tag = pkg + "." + tag } diff --git a/protoc-gen-swagger/main.go b/protoc-gen-swagger/main.go index e04582d7472..16ce528b709 100644 --- a/protoc-gen-swagger/main.go +++ b/protoc-gen-swagger/main.go @@ -25,7 +25,7 @@ var ( repeatedPathParamSeparator = flag.String("repeated_path_param_separator", "csv", "configures how repeated fields should be split. Allowed values are `csv`, `pipes`, `ssv` and `tsv`.") versionFlag = flag.Bool("version", false, "print the current verison") allowRepeatedFieldsInBody = flag.Bool("allow_repeated_fields_in_body", false, "allows to use repeated field in `body` and `response_body` field of `google.api.http` annotation option") - allowPackageNameInTags = flag.Bool("allow_package_name_in_tags", false, "if unset, the gRPC service name is added to the `Tags` field of each operation. if set and the `package` directive is shown in the proto file, the package name will be prepended to the service name") + includePackageInTags = flag.Bool("include_package_in_tags", false, "if unset, the gRPC service name is added to the `Tags` field of each operation. if set and the `package` directive is shown in the proto file, the package name will be prepended to the service name") ) // Variables set by goreleaser at build time @@ -75,7 +75,7 @@ func main() { reg.SetMergeFileName(*mergeFileName) reg.SetUseJSONNamesForFields(*useJSONNamesForFields) reg.SetAllowRepeatedFieldsInBody(*allowRepeatedFieldsInBody) - reg.SetAllowPackageNameInTags(*allowPackageNameInTags) + reg.SetIncludePackageInTags(*includePackageInTags) if err := reg.SetRepeatedPathParamSeparator(*repeatedPathParamSeparator); err != nil { emitError(err) return @@ -170,7 +170,7 @@ func parseReqParam(param string, f *flag.FlagSet, pkgMap map[string]string) erro } continue } - if spec[0] == "allow_package_name_in_tags" { + if spec[0] == "include_package_in_tags" { err := f.Set(spec[0], "true") if err != nil { return fmt.Errorf("Cannot set flag %s: %v", p, err) diff --git a/protoc-gen-swagger/main_test.go b/protoc-gen-swagger/main_test.go index 5f71a414b87..b5ebda041a2 100644 --- a/protoc-gen-swagger/main_test.go +++ b/protoc-gen-swagger/main_test.go @@ -17,7 +17,7 @@ func TestParseReqParam(t *testing.T) { allowDeleteBodyV bool allowMergeV bool allowRepeatedFieldsInBodyV bool - allowPackageNameInTagsV bool + includePackageInTagsV bool fileV string importPathV string mergeFileNameV string @@ -29,35 +29,35 @@ func TestParseReqParam(t *testing.T) { name: "Test 0", expected: map[string]string{}, request: "", - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, includePackageInTagsV: false, fileV: "-", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 1", expected: map[string]string{"google/api/annotations.proto": "github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api"}, - request: "allow_delete_body,allow_merge,allow_repeated_fields_in_body,allow_package_name_in_tags,file=./foo.pb,import_prefix=/bar/baz,Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api", - allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, allowPackageNameInTagsV: true, + request: "allow_delete_body,allow_merge,allow_repeated_fields_in_body,include_package_in_tags,file=./foo.pb,import_prefix=/bar/baz,Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api", + allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, includePackageInTagsV: true, fileV: "./foo.pb", importPathV: "/bar/baz", mergeFileNameV: "apidocs", }, { name: "Test 2", expected: map[string]string{"google/api/annotations.proto": "github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api"}, - request: "allow_delete_body=true,allow_merge=true,allow_repeated_fields_in_body=true,allow_package_name_in_tags=true,merge_file_name=test_name,file=./foo.pb,import_prefix=/bar/baz,Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api", - allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, allowPackageNameInTagsV: true, + request: "allow_delete_body=true,allow_merge=true,allow_repeated_fields_in_body=true,include_package_in_tags=true,merge_file_name=test_name,file=./foo.pb,import_prefix=/bar/baz,Mgoogle/api/annotations.proto=github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis/google/api", + allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, includePackageInTagsV: true, fileV: "./foo.pb", importPathV: "/bar/baz", mergeFileNameV: "test_name", }, { name: "Test 3", expected: map[string]string{"a/b/c.proto": "github.com/x/y/z", "f/g/h.proto": "github.com/1/2/3/"}, request: "allow_delete_body=false,allow_merge=false,Ma/b/c.proto=github.com/x/y/z,Mf/g/h.proto=github.com/1/2/3/", - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, includePackageInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 4", expected: map[string]string{}, request: "", - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, includePackageInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { @@ -65,7 +65,7 @@ func TestParseReqParam(t *testing.T) { expected: map[string]string{}, request: "unknown_param=17", expectedError: errors.New("Cannot set flag unknown_param=17: no such flag -unknown_param"), - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, includePackageInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { @@ -73,14 +73,14 @@ func TestParseReqParam(t *testing.T) { expected: map[string]string{}, request: "Mfoo", expectedError: errors.New("Cannot set flag Mfoo: no such flag -Mfoo"), - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, includePackageInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 7", expected: map[string]string{}, - request: "allow_delete_body,file,import_prefix,allow_merge,allow_repeated_fields_in_body,allow_package_name_in_tags,merge_file_name", - allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, allowPackageNameInTagsV: true, + request: "allow_delete_body,file,import_prefix,allow_merge,allow_repeated_fields_in_body,include_package_in_tags,merge_file_name", + allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: true, includePackageInTagsV: true, fileV: "", importPathV: "", mergeFileNameV: "", }, { @@ -88,15 +88,15 @@ func TestParseReqParam(t *testing.T) { expected: map[string]string{}, request: "allow_delete_body,file,import_prefix,allow_merge,allow_repeated_fields_in_body=3,merge_file_name", expectedError: errors.New(`Cannot set flag allow_repeated_fields_in_body=3: strconv.ParseBool: parsing "3": invalid syntax`), - allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, + allowDeleteBodyV: true, allowMergeV: true, allowRepeatedFieldsInBodyV: false, includePackageInTagsV: false, fileV: "", importPathV: "", mergeFileNameV: "apidocs", }, { name: "Test 9", expected: map[string]string{}, - request: "allow_package_name_in_tags=3", - expectedError: errors.New(`Cannot set flag allow_package_name_in_tags=3: strconv.ParseBool: parsing "3": invalid syntax`), - allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, allowPackageNameInTagsV: false, + request: "include_package_in_tags=3", + expectedError: errors.New(`Cannot set flag include_package_in_tags=3: strconv.ParseBool: parsing "3": invalid syntax`), + allowDeleteBodyV: false, allowMergeV: false, allowRepeatedFieldsInBodyV: false, includePackageInTagsV: false, fileV: "stdin", importPathV: "", mergeFileNameV: "apidocs", }, } @@ -124,7 +124,7 @@ func TestParseReqParam(t *testing.T) { tt.Errorf("expected error malformed, expected %q, got %q", tc.expectedError.Error(), err.Error()) } } - checkFlags(tc.allowDeleteBodyV, tc.allowMergeV, tc.allowRepeatedFieldsInBodyV, tc.allowPackageNameInTagsV, tc.fileV, tc.importPathV, tc.mergeFileNameV, tt, i) + checkFlags(tc.allowDeleteBodyV, tc.allowMergeV, tc.allowRepeatedFieldsInBodyV, tc.includePackageInTagsV, tc.fileV, tc.importPathV, tc.mergeFileNameV, tt, i) clearFlags() }) @@ -132,7 +132,7 @@ func TestParseReqParam(t *testing.T) { } -func checkFlags(allowDeleteV, allowMergeV, allowRepeatedFieldsInBodyV, allowPackageNameInTagsV bool, fileV, importPathV, mergeFileNameV string, t *testing.T, tid int) { +func checkFlags(allowDeleteV, allowMergeV, allowRepeatedFieldsInBodyV, includePackageInTagsV bool, fileV, importPathV, mergeFileNameV string, t *testing.T, tid int) { if *importPrefix != importPathV { t.Errorf("Test %v: import_prefix misparsed, expected '%v', got '%v'", tid, importPathV, *importPrefix) } @@ -151,8 +151,8 @@ func checkFlags(allowDeleteV, allowMergeV, allowRepeatedFieldsInBodyV, allowPack if *allowRepeatedFieldsInBody != allowRepeatedFieldsInBodyV { t.Errorf("Test %v: allow_repeated_fields_in_body misparsed, expected '%v', got '%v'", tid, allowRepeatedFieldsInBodyV, *allowRepeatedFieldsInBody) } - if *allowPackageNameInTags != allowPackageNameInTagsV { - t.Errorf("Test %v: allow_repeated_fields_in_body misparsed, expected '%v', got '%v'", tid, allowPackageNameInTagsV, *allowPackageNameInTags) + if *includePackageInTags != includePackageInTagsV { + t.Errorf("Test %v: allow_repeated_fields_in_body misparsed, expected '%v', got '%v'", tid, includePackageInTagsV, *includePackageInTags) } } @@ -162,6 +162,6 @@ func clearFlags() { *allowDeleteBody = false *allowMerge = false *allowRepeatedFieldsInBody = false - *allowPackageNameInTags = false + *includePackageInTags = false *mergeFileName = "apidocs" }