From 6ff06d809eb2ab886b3713515ea8475e94c8739d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sat, 7 May 2016 23:14:41 +0100 Subject: [PATCH 01/26] Apply additional Swagger properties using JSON. Depends on PR #134. Reverts 562956fa74bfa71588576449ff0e3fa9c0b49ca0. --- examples/examplepb/echo_service.pb.go | 46 ++++++++++++++++++++ examples/examplepb/echo_service.proto | 37 ++++++++++++++++ examples/examplepb/echo_service.swagger.json | 14 +++++- protoc-gen-swagger/genswagger/template.go | 39 ++++++++++++++++- 4 files changed, 133 insertions(+), 3 deletions(-) diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index f4b5f3b5caa..2a42e6caebd 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -9,6 +9,25 @@ Echo Service Echo Service API consists of a single service which returns a message. + + It is generated from these files: examples/examplepb/echo_service.proto examples/examplepb/a_bit_of_everything.proto @@ -48,6 +67,15 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // SimpleMessage represents a simple message sent to the Echo service. +// +// type SimpleMessage struct { // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` @@ -92,6 +120,15 @@ type EchoServiceClient interface { // // The message posted as the id parameter will also be // returned. + // + // Echo(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) @@ -130,6 +167,15 @@ type EchoServiceServer interface { // // The message posted as the id parameter will also be // returned. + // + // Echo(context.Context, *SimpleMessage) (*SimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(context.Context, *SimpleMessage) (*SimpleMessage, error) diff --git a/examples/examplepb/echo_service.proto b/examples/examplepb/echo_service.proto index 0a7a6fa7f49..9006e61c28f 100644 --- a/examples/examplepb/echo_service.proto +++ b/examples/examplepb/echo_service.proto @@ -5,11 +5,39 @@ option go_package = "examplepb"; // // Echo Service API consists of a single service which returns // a message. +// +// package grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; // SimpleMessage represents a simple message sent to the Echo service. +// +// message SimpleMessage { // Id represents the message identifier. string id = 1; @@ -22,6 +50,15 @@ service EchoService { // // The message posted as the id parameter will also be // returned. + // + // rpc Echo(SimpleMessage) returns (SimpleMessage) { option (google.api.http) = { post: "/v1/example/echo/{id}" diff --git a/examples/examplepb/echo_service.swagger.json b/examples/examplepb/echo_service.swagger.json index c58fbc54cea..26ced7bb6a1 100644 --- a/examples/examplepb/echo_service.swagger.json +++ b/examples/examplepb/echo_service.swagger.json @@ -3,8 +3,14 @@ "info": { "title": "Echo Service", "description": "Echo Service API consists of a single service which returns\na message.", - "version": "version not set" + "version": "1.0", + "contact": { + "name": "gRPC-Gateway project", + "url": "https://github.com/gengo/grpc-gateway", + "email": "none@example.com" + } }, + "host": "localhost", "schemes": [ "http", "https" @@ -39,7 +45,11 @@ ], "tags": [ "EchoService" - ] + ], + "externalDocs": { + "description": "Find out more about EchoService", + "url": "http://github.com/gengo/grpc-gateway" + } } }, "/v1/example/echo/{id}/{num}": { diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index b2353aa5341..67482fecd25 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -14,6 +14,8 @@ import ( "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor" ) +var swaggerExtrasRegexp = regexp.MustCompile(`(?s)^(.*[^\s])[\s]*[\s]*(.*)$`) + func listEnumNames(enum *descriptor.Enum) (names []string) { for _, value := range enum.GetValue() { names = append(names, value.GetName()) @@ -631,20 +633,55 @@ func applyTemplate(p param) (string, error) { // updateSwaggerDataFromComments updates a Swagger object based on a comment // from the proto file. // +// As a first step, a section matching: +// +// +// +// where .* contains valid JSON will be stored for later processing, and then +// removed from the passed string. +// (Implementation note: Currently, the JSON gets immediately applied and +// thus cannot override summary and description.) +// // First paragraph of a comment is used for summary. Remaining paragraphs of a // comment are used for description. If 'Summary' field is not present on the // passed swaggerObject, the summary and description are joined by \n\n. // // If there is a field named 'Info', its 'Summary' and 'Description' fields -// will be updated instead. +// will be updated instead. (JSON always gets applied directly to the passed +// object.) // // If there is no 'Summary', the same behavior will be attempted on 'Title', // but only if the last character is not a period. +// +// To apply additional Swagger properties, one can pass valid JSON as described +// before. This JSON gets parsed and applied to the passed swaggerObject +// directly. This lets users easily apply custom properties such as contact +// details, API base path, et al. func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) error { if len(comment) == 0 { return nil } + // Find a section containing additional Swagger metadata. + matches := swaggerExtrasRegexp.FindStringSubmatch(comment) + + if len(matches) > 0 { + // If found, before further processing, replace the + // comment with a version that does not contain the + // extras. + comment = matches[1] + if len(matches[3]) > 0 { + comment += "\n\n" + matches[3] + } + + // Parse the JSON and apply it. + // TODO(ivucica): apply extras /after/ applying summary + // and description. + if err := json.Unmarshal([]byte(matches[2]), swaggerObject); err != nil { + return fmt.Errorf("error: %s, parsing: %s", err.Error(), matches[2]) + } + } + // Figure out what to apply changes to. swaggerObjectValue := reflect.ValueOf(swaggerObject) infoObjectValue := swaggerObjectValue.Elem().FieldByName("Info") From fcc2dca6ad0e974426b65428c77e867d3bc3cf5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sat, 7 May 2016 23:38:36 +0100 Subject: [PATCH 02/26] Swagger: Replaced '' for raw JSON with last paragraph 'Swagger: '. Per discussion in gengo/grpc-gateway#134. --- examples/examplepb/echo_service.pb.go | 16 ++---- examples/examplepb/echo_service.proto | 12 +--- protoc-gen-swagger/genswagger/template.go | 67 ++++++++--------------- 3 files changed, 30 insertions(+), 65 deletions(-) diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index 2a42e6caebd..fa328f58d7a 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -9,8 +9,7 @@ Echo Service Echo Service API consists of a single service which returns a message. - It is generated from these files: examples/examplepb/echo_service.proto @@ -68,14 +66,12 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // SimpleMessage represents a simple message sent to the Echo service. // -// type SimpleMessage struct { // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` @@ -121,14 +117,12 @@ type EchoServiceClient interface { // The message posted as the id parameter will also be // returned. // - // Echo(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) @@ -168,14 +162,12 @@ type EchoServiceServer interface { // The message posted as the id parameter will also be // returned. // - // Echo(context.Context, *SimpleMessage) (*SimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(context.Context, *SimpleMessage) (*SimpleMessage, error) diff --git a/examples/examplepb/echo_service.proto b/examples/examplepb/echo_service.proto index 9006e61c28f..a083e0f9e0d 100644 --- a/examples/examplepb/echo_service.proto +++ b/examples/examplepb/echo_service.proto @@ -6,8 +6,7 @@ option go_package = "examplepb"; // Echo Service API consists of a single service which returns // a message. // -// package grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; // SimpleMessage represents a simple message sent to the Echo service. // -// message SimpleMessage { // Id represents the message identifier. string id = 1; @@ -51,14 +47,12 @@ service EchoService { // The message posted as the id parameter will also be // returned. // - // rpc Echo(SimpleMessage) returns (SimpleMessage) { option (google.api.http) = { post: "/v1/example/echo/{id}" diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 67482fecd25..a46e3c3d2ea 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -633,55 +633,27 @@ func applyTemplate(p param) (string, error) { // updateSwaggerDataFromComments updates a Swagger object based on a comment // from the proto file. // -// As a first step, a section matching: -// -// -// -// where .* contains valid JSON will be stored for later processing, and then -// removed from the passed string. -// (Implementation note: Currently, the JSON gets immediately applied and -// thus cannot override summary and description.) -// -// First paragraph of a comment is used for summary. Remaining paragraphs of a -// comment are used for description. If 'Summary' field is not present on the -// passed swaggerObject, the summary and description are joined by \n\n. +// First paragraph of a comment is used for summary. Remaining paragraphs of +// a comment are used for description. If 'Summary' field is not present on +// the passed swaggerObject, the summary and description are joined by \n\n. // // If there is a field named 'Info', its 'Summary' and 'Description' fields // will be updated instead. (JSON always gets applied directly to the passed -// object.) +// object, never to 'Info'.) // // If there is no 'Summary', the same behavior will be attempted on 'Title', // but only if the last character is not a period. // -// To apply additional Swagger properties, one can pass valid JSON as described -// before. This JSON gets parsed and applied to the passed swaggerObject -// directly. This lets users easily apply custom properties such as contact -// details, API base path, et al. +// To apply additional Swagger properties, one can pass valid JSON +// in the last paragraph of the comment. The last paragraph needs to start +// with the string 'Swagger: '. This JSON gets parsed and applied to +// the passed swaggerObject directly. This lets developers easily apply +// custom properties such as contact details, API base path, et al. func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) error { if len(comment) == 0 { return nil } - // Find a section containing additional Swagger metadata. - matches := swaggerExtrasRegexp.FindStringSubmatch(comment) - - if len(matches) > 0 { - // If found, before further processing, replace the - // comment with a version that does not contain the - // extras. - comment = matches[1] - if len(matches[3]) > 0 { - comment += "\n\n" + matches[3] - } - - // Parse the JSON and apply it. - // TODO(ivucica): apply extras /after/ applying summary - // and description. - if err := json.Unmarshal([]byte(matches[2]), swaggerObject); err != nil { - return fmt.Errorf("error: %s, parsing: %s", err.Error(), matches[2]) - } - } - // Figure out what to apply changes to. swaggerObjectValue := reflect.ValueOf(swaggerObject) infoObjectValue := swaggerObjectValue.Elem().FieldByName("Info") @@ -700,17 +672,24 @@ func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) er usingTitle = true } + // Parse the JSON and apply it. + // TODO(ivucica): apply extras /after/ applying summary + // and description. + paragraphs := strings.Split(comment, "\n\n") + if len(paragraphs) > 0 && strings.HasPrefix(strings.TrimLeft(paragraphs[len(paragraphs)-1], " "), "Swagger: ") { + if err := json.Unmarshal([]byte(strings.TrimLeft(paragraphs[len(paragraphs)-1], " "))[len("Swagger: "):], swaggerObject); err != nil { + return fmt.Errorf("error: %s, parsing: %s", err.Error(), paragraphs[len(paragraphs)-1]) + } + paragraphs = paragraphs[:len(paragraphs)-1] + } + // If there is a summary (or summary-equivalent), use the first // paragraph as summary, and the rest as description. if summaryValue.CanSet() { - paragraphs := strings.Split(comment, "\n\n") - summary := strings.TrimSpace(paragraphs[0]) description := strings.TrimSpace(strings.Join(paragraphs[1:], "\n\n")) - if !usingTitle || summary == "" || summary[len(summary)-1] != '.' { - if len(summary) > 0 { - summaryValue.Set(reflect.ValueOf(summary)) - } + if !usingTitle || (len(summary) > 0 && summary[len(summary)-1] != '.') { + summaryValue.Set(reflect.ValueOf(summary)) if len(description) > 0 { if !descriptionValue.CanSet() { return fmt.Errorf("Encountered object type with a summary, but no description") @@ -724,7 +703,7 @@ func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) er // There was no summary field on the swaggerObject. Try to apply the // whole comment into description. if descriptionValue.CanSet() { - descriptionValue.Set(reflect.ValueOf(comment)) + descriptionValue.Set(reflect.ValueOf(strings.Join(paragraphs, "\n\n"))) return nil } From 20a6d4059404e3a47894ba359af91254746668d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sun, 8 May 2016 00:04:32 +0100 Subject: [PATCH 03/26] Change from 'Swagger: ' to 'OpenAPI: ' prefix. --- examples/examplepb/echo_service.pb.go | 8 ++++---- examples/examplepb/echo_service.proto | 6 +++--- protoc-gen-swagger/genswagger/template.go | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index fa328f58d7a..d08733a02ce 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -9,7 +9,7 @@ Echo Service Echo Service API consists of a single service which returns a message. -Swagger: { +OpenAPI: { "info": { "title": "Echo Service", "version": "1.0", @@ -66,7 +66,7 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // SimpleMessage represents a simple message sent to the Echo service. // -// Swagger: { +// OpenAPI: { // "externalDocs": { // "url": "http://github.com/gengo/grpc-gateway", // "description": "Find out more about EchoService" @@ -117,7 +117,7 @@ type EchoServiceClient interface { // The message posted as the id parameter will also be // returned. // - // Swagger: { + // OpenAPI: { // "externalDocs": { // "url": "http://github.com/gengo/grpc-gateway", // "description": "Find out more about EchoService" @@ -162,7 +162,7 @@ type EchoServiceServer interface { // The message posted as the id parameter will also be // returned. // - // Swagger: { + // OpenAPI: { // "externalDocs": { // "url": "http://github.com/gengo/grpc-gateway", // "description": "Find out more about EchoService" diff --git a/examples/examplepb/echo_service.proto b/examples/examplepb/echo_service.proto index a083e0f9e0d..ccedb195e11 100644 --- a/examples/examplepb/echo_service.proto +++ b/examples/examplepb/echo_service.proto @@ -6,7 +6,7 @@ option go_package = "examplepb"; // Echo Service API consists of a single service which returns // a message. // -// Swagger: { +// OpenAPI: { // "info": { // "title": "Echo Service", // "version": "1.0", @@ -28,7 +28,7 @@ import "google/api/annotations.proto"; // SimpleMessage represents a simple message sent to the Echo service. // -// Swagger: { +// OpenAPI: { // "externalDocs": { // "url": "http://github.com/grpc-ecosystem/grpc-gateway", // "description": "Find out more about EchoService" @@ -47,7 +47,7 @@ service EchoService { // The message posted as the id parameter will also be // returned. // - // Swagger: { + // OpenAPI: { // "externalDocs": { // "url": "http://github.com/grpc-ecosystem/grpc-gateway", // "description": "Find out more about EchoService" diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index a46e3c3d2ea..a4a09e2eb39 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -646,7 +646,7 @@ func applyTemplate(p param) (string, error) { // // To apply additional Swagger properties, one can pass valid JSON // in the last paragraph of the comment. The last paragraph needs to start -// with the string 'Swagger: '. This JSON gets parsed and applied to +// with the string 'OpenAPI: '. This JSON gets parsed and applied to // the passed swaggerObject directly. This lets developers easily apply // custom properties such as contact details, API base path, et al. func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) error { @@ -676,8 +676,8 @@ func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) er // TODO(ivucica): apply extras /after/ applying summary // and description. paragraphs := strings.Split(comment, "\n\n") - if len(paragraphs) > 0 && strings.HasPrefix(strings.TrimLeft(paragraphs[len(paragraphs)-1], " "), "Swagger: ") { - if err := json.Unmarshal([]byte(strings.TrimLeft(paragraphs[len(paragraphs)-1], " "))[len("Swagger: "):], swaggerObject); err != nil { + if len(paragraphs) > 0 && strings.HasPrefix(strings.TrimLeft(paragraphs[len(paragraphs)-1], " "), "OpenAPI: ") { + if err := json.Unmarshal([]byte(strings.TrimLeft(paragraphs[len(paragraphs)-1], " "))[len("OpenAPI: "):], swaggerObject); err != nil { return fmt.Errorf("error: %s, parsing: %s", err.Error(), paragraphs[len(paragraphs)-1]) } paragraphs = paragraphs[:len(paragraphs)-1] From 321663da99c7b3b6a312288ef5914254019a9b6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Mon, 13 Feb 2017 13:58:23 +0000 Subject: [PATCH 04/26] WIP: Use a proto option to describe whether a Swagger Operation is deprecated. Issues: - This change breaks tests, uses possibly inappropriate package names etc. - 'deprecated' status of an operation should be determined by whether the proto method has been declared deprecated. - Previous way of declaring extra values using JSON prefixed with "OpenAPI: " in the comments has not been removed. - Extension for Swagger options has an arbitrary, but almost certainly wrong, identifier assigned to it. - Neither global API properties nor the main useful property on a swagger Operation, "externalDocs", are supported with this new method. - As a possible idea, we may want to support raw JSON in an option as well. --- Makefile | 12 +++++-- protoc-gen-swagger/genswagger/template.go | 30 +++++++++++++++++ protoc-gen-swagger/genswagger/types.go | 1 + protoc-gen-swagger/options/annotations.proto | 10 ++++++ protoc-gen-swagger/options/swagger.proto | 35 ++++++++++++++++++++ 5 files changed, 85 insertions(+), 3 deletions(-) create mode 100644 protoc-gen-swagger/options/annotations.proto create mode 100644 protoc-gen-swagger/options/swagger.proto diff --git a/Makefile b/Makefile index 5fe3c4850e0..b206161a560 100644 --- a/Makefile +++ b/Makefile @@ -43,6 +43,9 @@ OUTPUT_DIR=_output RUNTIME_PROTO=runtime/internal/stream_chunk.proto RUNTIME_GO=$(RUNTIME_PROTO:.proto=.pb.go) +SWAGGER_PROTO=protoc-gen-swagger/options/swagger.proto protoc-gen-swagger/options/annotations.proto +SWAGGER_GO=$(SWAGGER_PROTO:.proto=.pb.go) + PKGMAP=Mgoogle/protobuf/descriptor.proto=$(GO_PLUGIN_PKG)/descriptor,Mexamples/sub/message.proto=$(PKG)/examples/sub ADDITIONAL_FLAGS= ifneq "$(GATEWAY_PLUGIN_FLAGS)" "" @@ -83,17 +86,20 @@ generate: $(RUNTIME_GO) .SUFFIXES: .go .proto -$(GO_PLUGIN): +$(GO_PLUGIN): go get $(GO_PLUGIN_PKG) go build -o $@ $(GO_PLUGIN_PKG) $(RUNTIME_GO): $(RUNTIME_PROTO) $(GO_PLUGIN) protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):. $(RUNTIME_PROTO) +$(SWAGGER_GO): $(SWAGGER_PROTO) $(GO_PLUGIN) + protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):. $(SWAGGER_PROTO) + $(GATEWAY_PLUGIN): $(RUNTIME_GO) $(GATEWAY_PLUGIN_SRC) go build -o $@ $(GATEWAY_PLUGIN_PKG) -$(SWAGGER_PLUGIN): $(SWAGGER_PLUGIN_SRC) +$(SWAGGER_PLUGIN): $(SWAGGER_PLUGIN_SRC) $(SWAGGER_GO) go build -o $@ $(SWAGGER_PLUGIN_PKG) $(EXAMPLE_SVCSRCS): $(GO_PLUGIN) $(EXAMPLES) @@ -120,7 +126,7 @@ $(ABE_EXAMPLE_SRCS): $(ABE_EXAMPLE_SPEC) $(EXAMPLE_CLIENT_DIR)/abe/git_push.sh \ $(EXAMPLE_CLIENT_DIR)/abe/.travis.yml -examples: $(EXAMPLE_SVCSRCS) $(EXAMPLE_GWSRCS) $(EXAMPLE_DEPSRCS) $(EXAMPLE_SWAGGERSRCS) $(EXAMPLE_CLIENT_SRCS) +examples: $(EXAMPLE_SVCSRCS) $(EXAMPLE_GWSRCS) $(EXAMPLE_DEPSRCS) $(EXAMPLE_SWAGGERSRCS) #$(EXAMPLE_CLIENT_SRCS) test: examples go test -race $(PKG)/... diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index a4a09e2eb39..2c3f4429838 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -12,6 +12,8 @@ import ( pbdescriptor "github.com/golang/protobuf/protoc-gen-go/descriptor" "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor" + swagger_options "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" + "github.com/golang/protobuf/proto" ) var swaggerExtrasRegexp = regexp.MustCompile(`(?s)^(.*[^\s])[\s]*[\s]*(.*)$`) @@ -555,6 +557,34 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re panic(err) } + extractOperationOptions := func (meth *pbdescriptor.MethodDescriptorProto) (*swagger_options.Operation, error) { + if meth.Options == nil { + return nil, nil + } + if !proto.HasExtension(meth.Options, swagger_options.E_SwaggerOperation) { + return nil, nil + } + ext, err := proto.GetExtension(meth.Options, swagger_options.E_SwaggerOperation) + if err != nil { + return nil, err + } + opts, ok := ext.(*swagger_options.Operation) + if !ok { + return nil, fmt.Errorf("extension is %T; want an Operation", ext) + } + return opts, nil + } + opts, err := extractOperationOptions(meth.MethodDescriptorProto) + if opts != nil { + if err != nil { + panic(err) + } + // TODO(ivucica): this would be better supported by looking whether the method is deprecated in the proto file + operationObject.Deprecated = opts.Deprecated + + // TODO(ivucica): add remaining fields of operation object + } + switch b.HTTPMethod { case "DELETE": pathItemObject.Delete = operationObject diff --git a/protoc-gen-swagger/genswagger/types.go b/protoc-gen-swagger/genswagger/types.go index c328d1c60cc..05c61b3e87f 100644 --- a/protoc-gen-swagger/genswagger/types.go +++ b/protoc-gen-swagger/genswagger/types.go @@ -80,6 +80,7 @@ type swaggerOperationObject struct { Responses swaggerResponsesObject `json:"responses"` Parameters swaggerParametersObject `json:"parameters,omitempty"` Tags []string `json:"tags,omitempty"` + Deprecated bool `json:"deprecated,omitempty"` ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"` } diff --git a/protoc-gen-swagger/options/annotations.proto b/protoc-gen-swagger/options/annotations.proto new file mode 100644 index 00000000000..6f2712fa546 --- /dev/null +++ b/protoc-gen-swagger/options/annotations.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; + +package grpc_gateway.protoc_gen_swagger.options; + +import "protoc-gen-swagger/options/swagger.proto"; +import "google/protobuf/descriptor.proto"; + +extend google.protobuf.MethodOptions { + Operation swagger_operation = 123456789; // TODO(ivucica): how to determine ID? +} diff --git a/protoc-gen-swagger/options/swagger.proto b/protoc-gen-swagger/options/swagger.proto new file mode 100644 index 00000000000..775aa7560e8 --- /dev/null +++ b/protoc-gen-swagger/options/swagger.proto @@ -0,0 +1,35 @@ +syntax = "proto3"; + +package grpc_gateway.protoc_gen_swagger.options; + +// `Operation` is a representation of Swagger specification's Operation object. +// +// See: http://swagger.io/specification/#operation-object-36 +// +// TODO(ivucica): document fields +message Operation { + repeated string tags = 1; + string summary = 2; + string description = 3; + ExternalDocumentation external_docs = 4; + string operation_id = 5; + repeated string consumes = 6; + repeated string produces = 7; + // field 8 is reserved for 'parameters'. + // field 9 is reserved for 'responses'. + repeated string schemes = 10; + bool deprecated = 11; + // field 12 is reserved for 'security'. + +} + +// `ExternalDocumentation` is a representation of Swagger specification's +// ExternalDocumentation object. +// +// See: http://swagger.io/specification/#external-documentation-object-40 +// +// TODO(ivucica): document fields +message ExternalDocumentation { + string description = 1; + string url = 2; +} From 70439667724c80df24f5b1530de88ba3cc75111d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Tue, 7 Mar 2017 18:18:54 +0000 Subject: [PATCH 05/26] WIP: Setting API properties through an option. --- examples/examplepb/echo_service.proto | 38 ++++--- examples/examplepb/echo_service.swagger.json | 5 +- protoc-gen-swagger/genswagger/template.go | 105 +++++++++++++++---- protoc-gen-swagger/options/annotations.proto | 5 +- protoc-gen-swagger/options/swagger.proto | 47 +++++++++ 5 files changed, 159 insertions(+), 41 deletions(-) diff --git a/examples/examplepb/echo_service.proto b/examples/examplepb/echo_service.proto index ccedb195e11..560fe7ac88e 100644 --- a/examples/examplepb/echo_service.proto +++ b/examples/examplepb/echo_service.proto @@ -5,26 +5,27 @@ option go_package = "examplepb"; // // Echo Service API consists of a single service which returns // a message. -// -// OpenAPI: { -// "info": { -// "title": "Echo Service", -// "version": "1.0", -// "contact": { -// "name": "gRPC-Gateway project", -// "url": "https://github.com/grpc-ecosystem/grpc-gateway", -// "email": "none@example.com" -// } -// }, -// "host": "localhost", -// "externalDocs": { -// "url": "https://github.com/grpc-ecosystem/grpc-gateway", -// "description": "More about gRPC-Gateway" -// } -// } package grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; +import "protoc-gen-swagger/options/annotations.proto"; + +option (grpc_gateway.protoc_gen_swagger.options.swagger_swagger) = { + info: { + title: "Echo Service"; + version: "1.0"; + contact: { + name: "gRPC-Gateway project"; + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + email: "none@example.com"; + }; + }; + host: "localhost"; + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "More about gRPC-Gateway"; + } +}; // SimpleMessage represents a simple message sent to the Echo service. // @@ -60,6 +61,9 @@ service EchoService { get: "/v1/example/echo/{id}/{num}" } }; + option (grpc_gateway.protoc_gen_swagger.options.swagger_operation) = { + deprecated: true + }; } // EchoBody method receives a simple message and returns it. rpc EchoBody(SimpleMessage) returns (SimpleMessage) { diff --git a/examples/examplepb/echo_service.swagger.json b/examples/examplepb/echo_service.swagger.json index 26ced7bb6a1..50fb6d15417 100644 --- a/examples/examplepb/echo_service.swagger.json +++ b/examples/examplepb/echo_service.swagger.json @@ -6,7 +6,7 @@ "version": "1.0", "contact": { "name": "gRPC-Gateway project", - "url": "https://github.com/gengo/grpc-gateway", + "url": "https://github.com/grpc-ecosystem/grpc-gateway", "email": "none@example.com" } }, @@ -46,9 +46,10 @@ "tags": [ "EchoService" ], + "deprecated": true, "externalDocs": { "description": "Find out more about EchoService", - "url": "http://github.com/gengo/grpc-gateway" + "url": "http://github.com/grpc-ecosystem/grpc-gateway" } } }, diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 2c3f4429838..7301d3ec2cc 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -10,10 +10,10 @@ import ( "strings" "sync" + "github.com/golang/protobuf/proto" pbdescriptor "github.com/golang/protobuf/protoc-gen-go/descriptor" "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway/descriptor" swagger_options "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" - "github.com/golang/protobuf/proto" ) var swaggerExtrasRegexp = regexp.MustCompile(`(?s)^(.*[^\s])[\s]*[\s]*(.*)$`) @@ -557,34 +557,17 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re panic(err) } - extractOperationOptions := func (meth *pbdescriptor.MethodDescriptorProto) (*swagger_options.Operation, error) { - if meth.Options == nil { - return nil, nil - } - if !proto.HasExtension(meth.Options, swagger_options.E_SwaggerOperation) { - return nil, nil - } - ext, err := proto.GetExtension(meth.Options, swagger_options.E_SwaggerOperation) - if err != nil { - return nil, err - } - opts, ok := ext.(*swagger_options.Operation) - if !ok { - return nil, fmt.Errorf("extension is %T; want an Operation", ext) - } - return opts, nil - } - opts, err := extractOperationOptions(meth.MethodDescriptorProto) + opts, err := extractOperationOptionFromMethodDescriptor(meth.MethodDescriptorProto) if opts != nil { if err != nil { panic(err) } // TODO(ivucica): this would be better supported by looking whether the method is deprecated in the proto file operationObject.Deprecated = opts.Deprecated - + // TODO(ivucica): add remaining fields of operation object } - + switch b.HTTPMethod { case "DELETE": pathItemObject.Delete = operationObject @@ -651,6 +634,46 @@ func applyTemplate(p param) (string, error) { panic(err) } + // There may be additional options in the swagger option in the proto. + spb, err := extractSwaggerOptionFromFileDescriptor(p.FileDescriptorProto) + if err != nil { + panic(err) + } + if spb != nil { + if spb.Swagger != "" { + s.Swagger = spb.Swagger + } + if spb.BasePath != "" { + s.BasePath = spb.BasePath + } + if spb.Info != nil { + if spb.Info.Title != "" { + s.Info.Title = spb.Info.Title + } + if spb.Info.Version != "" { + s.Info.Version = spb.Info.Version + } + if spb.Info.Contact != nil { + if s.Info.Contact == nil { + s.Info.Contact = &swaggerContactObject{} + } + if spb.Info.Contact.Name != "" { + s.Info.Contact.Name = spb.Info.Contact.Name + } + if spb.Info.Contact.Url != "" { + s.Info.Contact.URL = spb.Info.Contact.Url + } + if spb.Info.Contact.Email != "" { + s.Info.Contact.Email = spb.Info.Contact.Email + } + } + } + if spb.Host != "" { + s.Host = spb.Host + } + // TODO(ivucica): import the remaining fields + } + // We now have rendered the entire swagger object. Write the bytes out to a // string so it can be written to disk. var w bytes.Buffer @@ -904,3 +927,43 @@ func protoPathIndex(descriptorType reflect.Type, what string) int32 { return int32(path) } + +// extractOperationOptionFromMethodDescriptor extracts the message of type +// swagger_options.Operation from a given proto method's descriptor. +func extractOperationOptionFromMethodDescriptor(meth *pbdescriptor.MethodDescriptorProto) (*swagger_options.Operation, error) { + if meth.Options == nil { + return nil, nil + } + if !proto.HasExtension(meth.Options, swagger_options.E_SwaggerOperation) { + return nil, nil + } + ext, err := proto.GetExtension(meth.Options, swagger_options.E_SwaggerOperation) + if err != nil { + return nil, err + } + opts, ok := ext.(*swagger_options.Operation) + if !ok { + return nil, fmt.Errorf("extension is %T; want an Operation", ext) + } + return opts, nil +} + +// extractSwaggerOptionFromFileDescriptor extracts the message of type +// swagger_options.Swagger from a given proto method's descriptor. +func extractSwaggerOptionFromFileDescriptor(file *pbdescriptor.FileDescriptorProto) (*swagger_options.Swagger, error) { + if file.Options == nil { + return nil, nil + } + if !proto.HasExtension(file.Options, swagger_options.E_SwaggerSwagger) { + return nil, nil + } + ext, err := proto.GetExtension(file.Options, swagger_options.E_SwaggerSwagger) + if err != nil { + return nil, err + } + opts, ok := ext.(*swagger_options.Swagger) + if !ok { + return nil, fmt.Errorf("extension is %T; want an Swagger", ext) + } + return opts, nil +} diff --git a/protoc-gen-swagger/options/annotations.proto b/protoc-gen-swagger/options/annotations.proto index 6f2712fa546..1ae91faf733 100644 --- a/protoc-gen-swagger/options/annotations.proto +++ b/protoc-gen-swagger/options/annotations.proto @@ -5,6 +5,9 @@ package grpc_gateway.protoc_gen_swagger.options; import "protoc-gen-swagger/options/swagger.proto"; import "google/protobuf/descriptor.proto"; +extend google.protobuf.FileOptions { + Swagger swagger_swagger = 123456788; // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID +} extend google.protobuf.MethodOptions { - Operation swagger_operation = 123456789; // TODO(ivucica): how to determine ID? + Operation swagger_operation = 123456789; // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID } diff --git a/protoc-gen-swagger/options/swagger.proto b/protoc-gen-swagger/options/swagger.proto index 775aa7560e8..08fc50846a4 100644 --- a/protoc-gen-swagger/options/swagger.proto +++ b/protoc-gen-swagger/options/swagger.proto @@ -2,6 +2,28 @@ syntax = "proto3"; package grpc_gateway.protoc_gen_swagger.options; +// `Swagger` is a representation of Swagger specification's Swagger object. +// +// See: http://swagger.io/specification/#swagger-object-14 +// +// TODO(ivucica): document fields +message Swagger { + string swagger = 1; + Info info = 2; + string host = 3; + string base_path = 4; + repeated string schemes = 5; + repeated string consumes = 6; + repeated string produces = 7; + // field 8 is reserved for 'paths'. + // field 9 is reserved for 'definitions'. + // field 10 is reserved for 'responses'. + // field 11 is reserved for 'securityDefinitions'. + // field 12 is reserved for repeated 'security'. + // field 13 is reserved for repeated 'tags'. + ExternalDocumentation external_docs = 14; +} + // `Operation` is a representation of Swagger specification's Operation object. // // See: http://swagger.io/specification/#operation-object-36 @@ -23,6 +45,31 @@ message Operation { } +// `Info` is a representation of Swagger specification's Info object. +// +// See: http://swagger.io/specification/#info-object-17 +// +// TODO(ivucica): document fields +message Info { + string title = 1; + string description = 2; + string terms_of_service = 3; + Contact contact = 4; + // field 5 is reserved for 'license' + string version = 6; +} + +// `Contact` is a representation of Swagger specification's Contact object. +// +// See: http://swagger.io/specification/#contact-object-21 +// +// TODO(ivucica): document fields +message Contact { + string name = 1; + string url = 2; + string email = 3; +} + // `ExternalDocumentation` is a representation of Swagger specification's // ExternalDocumentation object. // From cdc10946b25146615d48c5580dcc043f80a79c16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Fri, 27 Oct 2017 22:15:46 +0000 Subject: [PATCH 06/26] WIP: Correctly reserve fields. Update link. TODO: merge with commit Mon Feb 13 13:58:23 2017 +0000. --- protoc-gen-swagger/options/annotations.proto | 6 ++++-- protoc-gen-swagger/options/swagger.proto | 22 ++++++++++++++------ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/protoc-gen-swagger/options/annotations.proto b/protoc-gen-swagger/options/annotations.proto index 1ae91faf733..52b8be59501 100644 --- a/protoc-gen-swagger/options/annotations.proto +++ b/protoc-gen-swagger/options/annotations.proto @@ -6,8 +6,10 @@ import "protoc-gen-swagger/options/swagger.proto"; import "google/protobuf/descriptor.proto"; extend google.protobuf.FileOptions { - Swagger swagger_swagger = 123456788; // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID + // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID + Swagger openapiv2_swagger = 123456788; } extend google.protobuf.MethodOptions { - Operation swagger_operation = 123456789; // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID + // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID + Operation openapiv2_operation = 123456789; } diff --git a/protoc-gen-swagger/options/swagger.proto b/protoc-gen-swagger/options/swagger.proto index 08fc50846a4..be28e3618b0 100644 --- a/protoc-gen-swagger/options/swagger.proto +++ b/protoc-gen-swagger/options/swagger.proto @@ -4,7 +4,7 @@ package grpc_gateway.protoc_gen_swagger.options; // `Swagger` is a representation of Swagger specification's Swagger object. // -// See: http://swagger.io/specification/#swagger-object-14 +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject // // TODO(ivucica): document fields message Swagger { @@ -16,17 +16,23 @@ message Swagger { repeated string consumes = 6; repeated string produces = 7; // field 8 is reserved for 'paths'. + reserved 8; // field 9 is reserved for 'definitions'. + reserved 9; // field 10 is reserved for 'responses'. + reserved 10; // field 11 is reserved for 'securityDefinitions'. + reserved 11; // field 12 is reserved for repeated 'security'. + reserved 12; // field 13 is reserved for repeated 'tags'. + reserved 13; ExternalDocumentation external_docs = 14; } // `Operation` is a representation of Swagger specification's Operation object. // -// See: http://swagger.io/specification/#operation-object-36 +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject // // TODO(ivucica): document fields message Operation { @@ -38,16 +44,19 @@ message Operation { repeated string consumes = 6; repeated string produces = 7; // field 8 is reserved for 'parameters'. + reserved 8; // field 9 is reserved for 'responses'. + reserved 9; repeated string schemes = 10; bool deprecated = 11; // field 12 is reserved for 'security'. + reserved 12; } // `Info` is a representation of Swagger specification's Info object. // -// See: http://swagger.io/specification/#info-object-17 +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject // // TODO(ivucica): document fields message Info { @@ -55,13 +64,14 @@ message Info { string description = 2; string terms_of_service = 3; Contact contact = 4; - // field 5 is reserved for 'license' + // field 5 is reserved for 'license'. + reserved 5; string version = 6; } // `Contact` is a representation of Swagger specification's Contact object. // -// See: http://swagger.io/specification/#contact-object-21 +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject // // TODO(ivucica): document fields message Contact { @@ -73,7 +83,7 @@ message Contact { // `ExternalDocumentation` is a representation of Swagger specification's // ExternalDocumentation object. // -// See: http://swagger.io/specification/#external-documentation-object-40 +// https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject // // TODO(ivucica): document fields message ExternalDocumentation { From 41b436f414c97d5f8ff8ee9134c0e12906979562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Fri, 27 Oct 2017 22:43:17 +0000 Subject: [PATCH 07/26] WIP: Refer to the specification as OpenAPI v2, not Swagger. Also, change the Go package name for options proto. --- Makefile | 10 +++++----- examples/examplepb/echo_service.proto | 4 ++-- protoc-gen-swagger/genswagger/template.go | 8 ++++---- protoc-gen-swagger/options/annotations.proto | 4 +++- .../options/{swagger.proto => openapiv2.proto} | 12 +++++++----- 5 files changed, 21 insertions(+), 17 deletions(-) rename protoc-gen-swagger/options/{swagger.proto => openapiv2.proto} (82%) diff --git a/Makefile b/Makefile index b206161a560..23b4cdaab96 100644 --- a/Makefile +++ b/Makefile @@ -43,8 +43,8 @@ OUTPUT_DIR=_output RUNTIME_PROTO=runtime/internal/stream_chunk.proto RUNTIME_GO=$(RUNTIME_PROTO:.proto=.pb.go) -SWAGGER_PROTO=protoc-gen-swagger/options/swagger.proto protoc-gen-swagger/options/annotations.proto -SWAGGER_GO=$(SWAGGER_PROTO:.proto=.pb.go) +OPENAPIV2_PROTO=protoc-gen-swagger/options/openapiv2.proto protoc-gen-swagger/options/annotations.proto +OPENAPIV2_GO=$(OPENAPIV2_PROTO:.proto=.pb.go) PKGMAP=Mgoogle/protobuf/descriptor.proto=$(GO_PLUGIN_PKG)/descriptor,Mexamples/sub/message.proto=$(PKG)/examples/sub ADDITIONAL_FLAGS= @@ -93,13 +93,13 @@ $(GO_PLUGIN): $(RUNTIME_GO): $(RUNTIME_PROTO) $(GO_PLUGIN) protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):. $(RUNTIME_PROTO) -$(SWAGGER_GO): $(SWAGGER_PROTO) $(GO_PLUGIN) - protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):. $(SWAGGER_PROTO) +$(OPENAPIV2_GO): $(OPENAPIV2_PROTO) $(GO_PLUGIN) + protoc -I $(PROTOC_INC_PATH) --plugin=$(GO_PLUGIN) -I. --go_out=$(PKGMAP):$(GOPATH)/src $(OPENAPIV2_PROTO) $(GATEWAY_PLUGIN): $(RUNTIME_GO) $(GATEWAY_PLUGIN_SRC) go build -o $@ $(GATEWAY_PLUGIN_PKG) -$(SWAGGER_PLUGIN): $(SWAGGER_PLUGIN_SRC) $(SWAGGER_GO) +$(SWAGGER_PLUGIN): $(SWAGGER_PLUGIN_SRC) $(OPENAPIV2_GO) go build -o $@ $(SWAGGER_PLUGIN_PKG) $(EXAMPLE_SVCSRCS): $(GO_PLUGIN) $(EXAMPLES) diff --git a/examples/examplepb/echo_service.proto b/examples/examplepb/echo_service.proto index 560fe7ac88e..22465644b75 100644 --- a/examples/examplepb/echo_service.proto +++ b/examples/examplepb/echo_service.proto @@ -10,7 +10,7 @@ package grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; import "protoc-gen-swagger/options/annotations.proto"; -option (grpc_gateway.protoc_gen_swagger.options.swagger_swagger) = { +option (grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger) = { info: { title: "Echo Service"; version: "1.0"; @@ -61,7 +61,7 @@ service EchoService { get: "/v1/example/echo/{id}/{num}" } }; - option (grpc_gateway.protoc_gen_swagger.options.swagger_operation) = { + option (grpc_gateway.protoc_gen_swagger.options.openapiv2_operation) = { deprecated: true }; } diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 7301d3ec2cc..fcb4aa9eb94 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -934,10 +934,10 @@ func extractOperationOptionFromMethodDescriptor(meth *pbdescriptor.MethodDescrip if meth.Options == nil { return nil, nil } - if !proto.HasExtension(meth.Options, swagger_options.E_SwaggerOperation) { + if !proto.HasExtension(meth.Options, swagger_options.E_Openapiv2Operation) { return nil, nil } - ext, err := proto.GetExtension(meth.Options, swagger_options.E_SwaggerOperation) + ext, err := proto.GetExtension(meth.Options, swagger_options.E_Openapiv2Operation) if err != nil { return nil, err } @@ -954,10 +954,10 @@ func extractSwaggerOptionFromFileDescriptor(file *pbdescriptor.FileDescriptorPro if file.Options == nil { return nil, nil } - if !proto.HasExtension(file.Options, swagger_options.E_SwaggerSwagger) { + if !proto.HasExtension(file.Options, swagger_options.E_Openapiv2Swagger) { return nil, nil } - ext, err := proto.GetExtension(file.Options, swagger_options.E_SwaggerSwagger) + ext, err := proto.GetExtension(file.Options, swagger_options.E_Openapiv2Swagger) if err != nil { return nil, err } diff --git a/protoc-gen-swagger/options/annotations.proto b/protoc-gen-swagger/options/annotations.proto index 52b8be59501..25777108033 100644 --- a/protoc-gen-swagger/options/annotations.proto +++ b/protoc-gen-swagger/options/annotations.proto @@ -2,7 +2,9 @@ syntax = "proto3"; package grpc_gateway.protoc_gen_swagger.options; -import "protoc-gen-swagger/options/swagger.proto"; +option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"; + +import "protoc-gen-swagger/options/openapiv2.proto"; import "google/protobuf/descriptor.proto"; extend google.protobuf.FileOptions { diff --git a/protoc-gen-swagger/options/swagger.proto b/protoc-gen-swagger/options/openapiv2.proto similarity index 82% rename from protoc-gen-swagger/options/swagger.proto rename to protoc-gen-swagger/options/openapiv2.proto index be28e3618b0..a2798cbaad3 100644 --- a/protoc-gen-swagger/options/swagger.proto +++ b/protoc-gen-swagger/options/openapiv2.proto @@ -2,7 +2,9 @@ syntax = "proto3"; package grpc_gateway.protoc_gen_swagger.options; -// `Swagger` is a representation of Swagger specification's Swagger object. +option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"; + +// `Swagger` is a representation of OpenAPI v2 specification's Swagger object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject // @@ -30,7 +32,7 @@ message Swagger { ExternalDocumentation external_docs = 14; } -// `Operation` is a representation of Swagger specification's Operation object. +// `Operation` is a representation of OpenAPI v2 specification's Operation object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject // @@ -54,7 +56,7 @@ message Operation { } -// `Info` is a representation of Swagger specification's Info object. +// `Info` is a representation of OpenAPI v2 specification's Info object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject // @@ -69,7 +71,7 @@ message Info { string version = 6; } -// `Contact` is a representation of Swagger specification's Contact object. +// `Contact` is a representation of OpenAPI v2 specification's Contact object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject // @@ -80,7 +82,7 @@ message Contact { string email = 3; } -// `ExternalDocumentation` is a representation of Swagger specification's +// `ExternalDocumentation` is a representation of OpenAPI v2 specification's // ExternalDocumentation object. // // https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject From 74cd3943f9b5d2c6939e70eb704e06a491dc6f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Fri, 27 Oct 2017 22:47:32 +0000 Subject: [PATCH 08/26] WIP: Clean up after OpenAPIv2 options proto generation. --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 23b4cdaab96..516aef076e1 100644 --- a/Makefile +++ b/Makefile @@ -149,5 +149,6 @@ realclean: distclean rm -f $(GO_PLUGIN) rm -f $(SWAGGER_PLUGIN) rm -f $(EXAMPLE_CLIENT_SRCS) + rm -f $(OPENAPIV2_GO) .PHONY: generate examples test lint clean distclean realclean From 549ccee975fe03f8aedd3f77bae40eb3b1f143b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Fri, 27 Oct 2017 22:48:11 +0000 Subject: [PATCH 09/26] WIP: JSON is disappearing from the output protos. --- examples/examplepb/echo_service.pb.go | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index d08733a02ce..dcb171a9bfe 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -9,23 +9,6 @@ Echo Service Echo Service API consists of a single service which returns a message. -OpenAPI: { - "info": { - "title": "Echo Service", - "version": "1.0", - "contact": { - "name": "gRPC-Gateway project", - "url": "https://github.com/gengo/grpc-gateway", - "email": "none@example.com" - } - }, - "host": "localhost", - "externalDocs": { - "url": "https://github.com/gengo/grpc-gateway", - "description": "More about gRPC-Gateway" - } -} - It is generated from these files: examples/examplepb/echo_service.proto examples/examplepb/a_bit_of_everything.proto From 6b2b3211144c044a66b59ef50288f9d07f49720e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Fri, 27 Oct 2017 23:10:13 +0000 Subject: [PATCH 10/26] WIP: Fix typo 'want an Swagger' -> 'want a Swagger object'. --- examples/examplepb/echo_service.pb.go | 52 ++++++++++++-------- examples/examplepb/echo_service.swagger.json | 7 ++- protoc-gen-swagger/genswagger/template.go | 2 +- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index dcb171a9bfe..38106ff94c5 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -30,6 +30,7 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import _ "google.golang.org/genproto/googleapis/api/annotations" +import _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" import ( context "golang.org/x/net/context" @@ -51,7 +52,7 @@ const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // // OpenAPI: { // "externalDocs": { -// "url": "http://github.com/gengo/grpc-gateway", +// "url": "http://github.com/grpc-ecosystem/grpc-gateway", // "description": "Find out more about EchoService" // } // } @@ -102,7 +103,7 @@ type EchoServiceClient interface { // // OpenAPI: { // "externalDocs": { - // "url": "http://github.com/gengo/grpc-gateway", + // "url": "http://github.com/grpc-ecosystem/grpc-gateway", // "description": "Find out more about EchoService" // } // } @@ -147,7 +148,7 @@ type EchoServiceServer interface { // // OpenAPI: { // "externalDocs": { - // "url": "http://github.com/gengo/grpc-gateway", + // "url": "http://github.com/grpc-ecosystem/grpc-gateway", // "description": "Find out more about EchoService" // } // } @@ -216,22 +217,31 @@ var _EchoService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/examplepb/echo_service.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 257 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xad, 0x48, 0xcc, - 0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0x87, 0x32, 0x0a, 0x92, 0xf4, 0x53, 0x93, 0x33, 0xf2, 0xe3, 0x8b, - 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xe4, 0xd3, 0x8b, - 0x0a, 0x92, 0xf5, 0xd2, 0x13, 0x4b, 0x52, 0xcb, 0x13, 0x2b, 0xf5, 0x60, 0x7a, 0xf4, 0xe0, 0x7a, - 0x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ff, 0xf8, 0x6e, 0x70, 0xce, 0xf4, 0x01, 0x00, - 0x00, + // 404 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x92, 0xcf, 0x6a, 0x15, 0x31, + 0x14, 0xc6, 0xc9, 0x5c, 0x11, 0x6f, 0xfc, 0x43, 0x09, 0x8a, 0x65, 0x54, 0x1c, 0x2e, 0x08, 0x45, + 0x9c, 0xc4, 0x5b, 0xc1, 0x45, 0x57, 0x52, 0x15, 0x71, 0x51, 0x90, 0xdb, 0x4d, 0xe9, 0xa6, 0x64, + 0x32, 0x87, 0x4c, 0x64, 0x26, 0x27, 0x4c, 0x32, 0xad, 0x43, 0xe9, 0xc6, 0xb5, 0x3b, 0xdf, 0xc0, + 0xa5, 0xf8, 0x1a, 0xae, 0x5c, 0x89, 0xa0, 0x2f, 0xe0, 0x4b, 0xb8, 0x93, 0xcc, 0x9d, 0x16, 0xa5, + 0x82, 0x74, 0xd1, 0x55, 0xce, 0x21, 0xdf, 0x97, 0xef, 0xc7, 0x47, 0xe8, 0x3d, 0x78, 0x23, 0x1b, + 0x57, 0x83, 0x17, 0xe3, 0xe0, 0x0a, 0x01, 0xaa, 0xc2, 0x3d, 0x0f, 0xed, 0xbe, 0x51, 0xc0, 0x5d, + 0x8b, 0x01, 0xd9, 0x5d, 0xdd, 0x3a, 0xc5, 0xb5, 0x0c, 0x70, 0x20, 0x7b, 0x7e, 0xec, 0xe1, 0x27, + 0x9e, 0xf4, 0xb6, 0x46, 0xd4, 0x35, 0x08, 0xe9, 0x8c, 0x90, 0xd6, 0x62, 0x90, 0xc1, 0xa0, 0xf5, + 0x4b, 0x7b, 0xfa, 0x60, 0x38, 0x54, 0xae, 0xc1, 0xe6, 0xfe, 0x40, 0x6a, 0x0d, 0xad, 0x40, 0x37, + 0x28, 0x4e, 0xab, 0x67, 0x73, 0x7a, 0x75, 0xdb, 0xc4, 0x77, 0xb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xf5, 0xfa, 0x64, 0xce, 0x1f, 0xa6, 0xd3, 0x1a, 0x95, 0xac, 0x2b, 0xf4, 0xa1, 0x7d, 0x49, 0x6f, + 0x6e, 0x61, 0x0b, 0x99, 0x2c, 0xb0, 0x0b, 0xd9, 0x9f, 0xa1, 0x67, 0x0d, 0xdb, 0x9d, 0x9e, 0x34, + 0x51, 0x5c, 0x1c, 0x7e, 0xd8, 0xa3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x58, 0x8c, 0x46, 0x6a, + 0xf7, 0x02, 0x00, 0x00, } diff --git a/examples/examplepb/echo_service.swagger.json b/examples/examplepb/echo_service.swagger.json index 50fb6d15417..2cc3508961f 100644 --- a/examples/examplepb/echo_service.swagger.json +++ b/examples/examplepb/echo_service.swagger.json @@ -83,7 +83,12 @@ ], "tags": [ "EchoService" - ] + ], + "deprecated": true, + "externalDocs": { + "description": "Find out more about EchoService", + "url": "http://github.com/grpc-ecosystem/grpc-gateway" + } } }, "/v1/example/echo_body": { diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index fcb4aa9eb94..981a8378c77 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -963,7 +963,7 @@ func extractSwaggerOptionFromFileDescriptor(file *pbdescriptor.FileDescriptorPro } opts, ok := ext.(*swagger_options.Swagger) if !ok { - return nil, fmt.Errorf("extension is %T; want an Swagger", ext) + return nil, fmt.Errorf("extension is %T; want a Swagger object", ext) } return opts, nil } From db4a056bc14ffcd2a0f66506afd9f4717e1291b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Fri, 27 Oct 2017 23:18:48 +0000 Subject: [PATCH 11/26] WIP: Process all remaining fields of the OpenAPI v2 Swagger object. --- examples/examplepb/echo_service.pb.go | 57 ++++++++++---------- examples/examplepb/echo_service.proto | 7 +++ examples/examplepb/echo_service.swagger.json | 13 +++-- protoc-gen-swagger/genswagger/template.go | 34 ++++++++++-- 4 files changed, 77 insertions(+), 34 deletions(-) diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index 38106ff94c5..0375c13b061 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -217,31 +217,34 @@ var _EchoService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/examplepb/echo_service.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 404 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x92, 0xcf, 0x6a, 0x15, 0x31, - 0x14, 0xc6, 0xc9, 0x5c, 0x11, 0x6f, 0xfc, 0x43, 0x09, 0x8a, 0x65, 0x54, 0x1c, 0x2e, 0x08, 0x45, - 0x9c, 0xc4, 0x5b, 0xc1, 0x45, 0x57, 0x52, 0x15, 0x71, 0x51, 0x90, 0xdb, 0x4d, 0xe9, 0xa6, 0x64, - 0x32, 0x87, 0x4c, 0x64, 0x26, 0x27, 0x4c, 0x32, 0xad, 0x43, 0xe9, 0xc6, 0xb5, 0x3b, 0xdf, 0xc0, - 0xa5, 0xf8, 0x1a, 0xae, 0x5c, 0x89, 0xa0, 0x2f, 0xe0, 0x4b, 0xb8, 0x93, 0xcc, 0x9d, 0x16, 0xa5, - 0x82, 0x74, 0xd1, 0x55, 0xce, 0x21, 0xdf, 0x97, 0xef, 0xc7, 0x47, 0xe8, 0x3d, 0x78, 0x23, 0x1b, - 0x57, 0x83, 0x17, 0xe3, 0xe0, 0x0a, 0x01, 0xaa, 0xc2, 0x3d, 0x0f, 0xed, 0xbe, 0x51, 0xc0, 0x5d, - 0x8b, 0x01, 0xd9, 0x5d, 0xdd, 0x3a, 0xc5, 0xb5, 0x0c, 0x70, 0x20, 0x7b, 0x7e, 0xec, 0xe1, 0x27, - 0x9e, 0xf4, 0xb6, 0x46, 0xd4, 0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96, 0xb9, 0x16, 0x5f, 0x83, 0x0a, - 0x8c, 0x57, 0x21, 0x38, 0xbf, 0x21, 0x84, 0x36, 0xa1, 0xea, 0x0a, 0xae, 0xb0, 0x11, 0x91, 0x2a, - 0x07, 0x85, 0xbe, 0xf7, 0x01, 0xc6, 0x75, 0x84, 0x4c, 0x57, 0x2c, 0x5a, 0x78, 0x32, 0x86, 0x47, - 0xf5, 0xfa, 0x64, 0xce, 0x1f, 0xa6, 0xd3, 0x1a, 0x95, 0xac, 0x2b, 0xf4, 0xa1, 0x7d, 0x49, 0x6f, - 0x6e, 0x61, 0x0b, 0x99, 0x2c, 0xb0, 0x0b, 0xd9, 0x9f, 0xa1, 0x67, 0x0d, 0xdb, 0x9d, 0x9e, 0x34, - 0x51, 0x5c, 0x1c, 0x7e, 0xd8, 0xa3, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x58, 0x8c, 0x46, 0x6a, - 0xf7, 0x02, 0x00, 0x00, + // 453 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x92, 0xcf, 0x6a, 0x14, 0x41, + 0x10, 0xc6, 0x99, 0xd9, 0x28, 0x6e, 0x1b, 0x65, 0x69, 0xfc, 0x13, 0x46, 0xc5, 0x61, 0x41, 0x08, + 0x8b, 0xd3, 0xed, 0xae, 0xe0, 0x61, 0x4f, 0x12, 0x15, 0xf1, 0x10, 0x90, 0xcd, 0x25, 0xe4, 0x12, + 0x7a, 0x7b, 0xca, 0x9e, 0x0e, 0x33, 0x5d, 0xcd, 0x74, 0x6f, 0x92, 0x25, 0xe4, 0xe2, 0xd9, 0x9b, + 0x6f, 0xe0, 0x51, 0x3c, 0xfa, 0x0c, 0x5e, 0x3c, 0x89, 0xe0, 0x13, 0xf8, 0x12, 0xde, 0xa4, 0x67, + 0x27, 0x21, 0xb2, 0x8a, 0xe4, 0x90, 0xd3, 0x54, 0x4d, 0x7f,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/examples/examplepb/echo_service.proto b/examples/examplepb/echo_service.proto index 22465644b75..c47de2464c4 100644 --- a/examples/examplepb/echo_service.proto +++ b/examples/examplepb/echo_service.proto @@ -25,6 +25,13 @@ option (grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger) = { url: "https://github.com/grpc-ecosystem/grpc-gateway"; description: "More about gRPC-Gateway"; } + schemes: "http"; + schemes: "https"; + schemes: "x-foo-scheme"; + consumes: "application/json"; + consumes: "application/x-foo-mime"; + produces: "application/json"; + produces: "application/x-foo-mime"; }; // SimpleMessage represents a simple message sent to the Echo service. diff --git a/examples/examplepb/echo_service.swagger.json b/examples/examplepb/echo_service.swagger.json index 2cc3508961f..6b9d2e013a8 100644 --- a/examples/examplepb/echo_service.swagger.json +++ b/examples/examplepb/echo_service.swagger.json @@ -8,18 +8,25 @@ "name": "gRPC-Gateway project", "url": "https://github.com/grpc-ecosystem/grpc-gateway", "email": "none@example.com" + }, + "externalDocs": { + "description": "More about gRPC-Gateway", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" } }, "host": "localhost", "schemes": [ "http", - "https" + "https", + "x-foo-scheme" ], "consumes": [ - "application/json" + "application/json", + "application/x-foo-mime" ], "produces": [ - "application/json" + "application/json", + "application/x-foo-mime" ], "paths": { "/v1/example/echo/{id}": { diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 981a8378c77..95f9b679882 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -643,9 +643,6 @@ func applyTemplate(p param) (string, error) { if spb.Swagger != "" { s.Swagger = spb.Swagger } - if spb.BasePath != "" { - s.BasePath = spb.BasePath - } if spb.Info != nil { if spb.Info.Title != "" { s.Info.Title = spb.Info.Title @@ -671,7 +668,36 @@ func applyTemplate(p param) (string, error) { if spb.Host != "" { s.Host = spb.Host } - // TODO(ivucica): import the remaining fields + if spb.BasePath != "" { + s.BasePath = spb.BasePath + } + if len(spb.Schemes) > 0 { + s.Schemes = make([]string, len(spb.Schemes)) + copy(s.Schemes, spb.Schemes) + } + if len(spb.Consumes) > 0 { + s.Consumes = make([]string, len(spb.Consumes)) + copy(s.Consumes, spb.Consumes) + } + if len(spb.Produces) > 0 { + s.Produces = make([]string, len(spb.Produces)) + copy(s.Produces, spb.Produces) + } + if spb.ExternalDocs != nil { + // TODO(ivucica): externalDocs does not belong in s.Info according to the spec. + if s.Info.ExternalDocs == nil { + s.Info.ExternalDocs = &swaggerExternalDocumentationObject{} + } + if spb.ExternalDocs.Description != "" { + s.Info.ExternalDocs.Description = spb.ExternalDocs.Description + } + if spb.ExternalDocs.Url != "" { + s.Info.ExternalDocs.URL = spb.ExternalDocs.Url + } + } + + // Additional fields on the OpenAPI v2 spec's "Swagger" object + // should be added here, once supported in the proto. } // We now have rendered the entire swagger object. Write the bytes out to a From 7697bcf8b7cc4a8fed0995965ec61014878281e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Fri, 27 Oct 2017 23:22:56 +0000 Subject: [PATCH 12/26] WIP: ExternalDocs belongs on OpenAPIv2's Swagger object, not on the Info object. --- examples/examplepb/echo_service.swagger.json | 8 ++++---- protoc-gen-swagger/genswagger/template.go | 9 ++++----- protoc-gen-swagger/genswagger/types.go | 2 +- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/examples/examplepb/echo_service.swagger.json b/examples/examplepb/echo_service.swagger.json index 6b9d2e013a8..783d86dc177 100644 --- a/examples/examplepb/echo_service.swagger.json +++ b/examples/examplepb/echo_service.swagger.json @@ -8,10 +8,6 @@ "name": "gRPC-Gateway project", "url": "https://github.com/grpc-ecosystem/grpc-gateway", "email": "none@example.com" - }, - "externalDocs": { - "description": "More about gRPC-Gateway", - "url": "https://github.com/grpc-ecosystem/grpc-gateway" } }, "host": "localhost", @@ -141,5 +137,9 @@ }, "description": "SimpleMessage represents a simple message sent to the Echo service." } + }, + "externalDocs": { + "description": "More about gRPC-Gateway", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 95f9b679882..2d3c55d0495 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -684,15 +684,14 @@ func applyTemplate(p param) (string, error) { copy(s.Produces, spb.Produces) } if spb.ExternalDocs != nil { - // TODO(ivucica): externalDocs does not belong in s.Info according to the spec. - if s.Info.ExternalDocs == nil { - s.Info.ExternalDocs = &swaggerExternalDocumentationObject{} + if s.ExternalDocs == nil { + s.ExternalDocs = &swaggerExternalDocumentationObject{} } if spb.ExternalDocs.Description != "" { - s.Info.ExternalDocs.Description = spb.ExternalDocs.Description + s.ExternalDocs.Description = spb.ExternalDocs.Description } if spb.ExternalDocs.Url != "" { - s.Info.ExternalDocs.URL = spb.ExternalDocs.Url + s.ExternalDocs.URL = spb.ExternalDocs.Url } } diff --git a/protoc-gen-swagger/genswagger/types.go b/protoc-gen-swagger/genswagger/types.go index 05c61b3e87f..5385be97d23 100644 --- a/protoc-gen-swagger/genswagger/types.go +++ b/protoc-gen-swagger/genswagger/types.go @@ -25,7 +25,6 @@ type swaggerInfoObject struct { Contact *swaggerContactObject `json:"contact,omitempty"` License *swaggerLicenseObject `json:"license,omitempty"` - ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"` } // http://swagger.io/specification/#contactObject @@ -58,6 +57,7 @@ type swaggerObject struct { Produces []string `json:"produces"` Paths swaggerPathsObject `json:"paths"` Definitions swaggerDefinitionsObject `json:"definitions"` + ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"` } // http://swagger.io/specification/#pathsObject From 162c3750209b3788155d52cc71bd014ae30a70f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sat, 28 Oct 2017 01:15:14 +0000 Subject: [PATCH 13/26] WIP: Remove use of JSON. Introduce schema and tag object. Support externalDocs on exported schema object. Replace (protocol) scheme strings with enum. --- examples/examplepb/a_bit_of_everything.pb.go | 76 +++++----- examples/examplepb/echo_service.pb.go | 86 +++++------- examples/examplepb/echo_service.proto | 38 ++--- examples/examplepb/echo_service.swagger.json | 16 ++- examples/examplepb/stream.pb.go | 20 +-- protoc-gen-swagger/genswagger/template.go | 73 +++++++--- protoc-gen-swagger/genswagger/types.go | 2 + protoc-gen-swagger/options/annotations.proto | 8 ++ protoc-gen-swagger/options/openapiv2.proto | 137 ++++++++++++++++++- 9 files changed, 312 insertions(+), 144 deletions(-) diff --git a/examples/examplepb/a_bit_of_everything.pb.go b/examples/examplepb/a_bit_of_everything.pb.go index 30afc97d2d6..452ed94ea43 100644 --- a/examples/examplepb/a_bit_of_everything.pb.go +++ b/examples/examplepb/a_bit_of_everything.pb.go @@ -7,11 +7,11 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import _ "google.golang.org/genproto/googleapis/api/annotations" -import google_protobuf1 "github.com/golang/protobuf/ptypes/empty" -import google_protobuf2 "github.com/golang/protobuf/ptypes/duration" +import google_protobuf2 "github.com/golang/protobuf/ptypes/empty" +import google_protobuf3 "github.com/golang/protobuf/ptypes/duration" import grpc_gateway_examples_sub "github.com/grpc-ecosystem/grpc-gateway/examples/sub" import sub2 "github.com/grpc-ecosystem/grpc-gateway/examples/sub2" -import google_protobuf3 "github.com/golang/protobuf/ptypes/timestamp" +import google_protobuf4 "github.com/golang/protobuf/ptypes/timestamp" import ( context "golang.org/x/net/context" @@ -104,7 +104,7 @@ type ABitOfEverything struct { MappedStringValue map[string]string `protobuf:"bytes,23,rep,name=mapped_string_value,json=mappedStringValue" json:"mapped_string_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` MappedNestedValue map[string]*ABitOfEverything_Nested `protobuf:"bytes,24,rep,name=mapped_nested_value,json=mappedNestedValue" json:"mapped_nested_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` NonConventionalNameValue string `protobuf:"bytes,26,opt,name=nonConventionalNameValue" json:"nonConventionalNameValue,omitempty"` - TimestampValue *google_protobuf3.Timestamp `protobuf:"bytes,27,opt,name=timestamp_value,json=timestampValue" json:"timestamp_value,omitempty"` + TimestampValue *google_protobuf4.Timestamp `protobuf:"bytes,27,opt,name=timestamp_value,json=timestampValue" json:"timestamp_value,omitempty"` // repeated enum value. it is comma-separated in query RepeatedEnumValue []NumericEnum `protobuf:"varint,28,rep,packed,name=repeated_enum_value,json=repeatedEnumValue,enum=grpc.gateway.examples.examplepb.NumericEnum" json:"repeated_enum_value,omitempty"` } @@ -119,7 +119,7 @@ type isABitOfEverything_OneofValue interface { } type ABitOfEverything_OneofEmpty struct { - OneofEmpty *google_protobuf1.Empty `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,oneof"` + OneofEmpty *google_protobuf2.Empty `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,oneof"` } type ABitOfEverything_OneofString struct { OneofString string `protobuf:"bytes,21,opt,name=oneof_string,json=oneofString,oneof"` @@ -268,7 +268,7 @@ func (m *ABitOfEverything) GetRepeatedStringValue() []string { return nil } -func (m *ABitOfEverything) GetOneofEmpty() *google_protobuf1.Empty { +func (m *ABitOfEverything) GetOneofEmpty() *google_protobuf2.Empty { if x, ok := m.GetOneofValue().(*ABitOfEverything_OneofEmpty); ok { return x.OneofEmpty } @@ -310,7 +310,7 @@ func (m *ABitOfEverything) GetNonConventionalNameValue() string { return "" } -func (m *ABitOfEverything) GetTimestampValue() *google_protobuf3.Timestamp { +func (m *ABitOfEverything) GetTimestampValue() *google_protobuf4.Timestamp { if m != nil { return m.TimestampValue } @@ -358,7 +358,7 @@ func _ABitOfEverything_OneofUnmarshaler(msg proto.Message, tag, wire int, b *pro if wire != proto.WireBytes { return true, proto.ErrInternalBadWireType } - msg := new(google_protobuf1.Empty) + msg := new(google_protobuf2.Empty) err := b.DecodeMessage(msg) m.OneofValue = &ABitOfEverything_OneofEmpty{msg} return true, err @@ -449,13 +449,13 @@ type ABitOfEverythingServiceClient interface { Create(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) CreateBody(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) Lookup(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*ABitOfEverything, error) - Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) - Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) - GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) + Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) + GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) Echo(ctx context.Context, in *grpc_gateway_examples_sub.StringMessage, opts ...grpc.CallOption) (*grpc_gateway_examples_sub.StringMessage, error) DeepPathEcho(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) - NoBindings(ctx context.Context, in *google_protobuf2.Duration, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) - Timeout(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + NoBindings(ctx context.Context, in *google_protobuf3.Duration, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) + Timeout(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) } type aBitOfEverythingServiceClient struct { @@ -493,8 +493,8 @@ func (c *aBitOfEverythingServiceClient) Lookup(ctx context.Context, in *sub2.IdM return out, nil } -func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { - out := new(google_protobuf1.Empty) +func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { + out := new(google_protobuf2.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/Update", in, out, c.cc, opts...) if err != nil { return nil, err @@ -502,8 +502,8 @@ func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEv return out, nil } -func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { - out := new(google_protobuf1.Empty) +func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { + out := new(google_protobuf2.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/Delete", in, out, c.cc, opts...) if err != nil { return nil, err @@ -511,8 +511,8 @@ func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *sub2.IdM return out, nil } -func (c *aBitOfEverythingServiceClient) GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { - out := new(google_protobuf1.Empty) +func (c *aBitOfEverythingServiceClient) GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { + out := new(google_protobuf2.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/GetQuery", in, out, c.cc, opts...) if err != nil { return nil, err @@ -538,8 +538,8 @@ func (c *aBitOfEverythingServiceClient) DeepPathEcho(ctx context.Context, in *AB return out, nil } -func (c *aBitOfEverythingServiceClient) NoBindings(ctx context.Context, in *google_protobuf2.Duration, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { - out := new(google_protobuf1.Empty) +func (c *aBitOfEverythingServiceClient) NoBindings(ctx context.Context, in *google_protobuf3.Duration, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { + out := new(google_protobuf2.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/NoBindings", in, out, c.cc, opts...) if err != nil { return nil, err @@ -547,8 +547,8 @@ func (c *aBitOfEverythingServiceClient) NoBindings(ctx context.Context, in *goog return out, nil } -func (c *aBitOfEverythingServiceClient) Timeout(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { - out := new(google_protobuf1.Empty) +func (c *aBitOfEverythingServiceClient) Timeout(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { + out := new(google_protobuf2.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/Timeout", in, out, c.cc, opts...) if err != nil { return nil, err @@ -562,13 +562,13 @@ type ABitOfEverythingServiceServer interface { Create(context.Context, *ABitOfEverything) (*ABitOfEverything, error) CreateBody(context.Context, *ABitOfEverything) (*ABitOfEverything, error) Lookup(context.Context, *sub2.IdMessage) (*ABitOfEverything, error) - Update(context.Context, *ABitOfEverything) (*google_protobuf1.Empty, error) - Delete(context.Context, *sub2.IdMessage) (*google_protobuf1.Empty, error) - GetQuery(context.Context, *ABitOfEverything) (*google_protobuf1.Empty, error) + Update(context.Context, *ABitOfEverything) (*google_protobuf2.Empty, error) + Delete(context.Context, *sub2.IdMessage) (*google_protobuf2.Empty, error) + GetQuery(context.Context, *ABitOfEverything) (*google_protobuf2.Empty, error) Echo(context.Context, *grpc_gateway_examples_sub.StringMessage) (*grpc_gateway_examples_sub.StringMessage, error) DeepPathEcho(context.Context, *ABitOfEverything) (*ABitOfEverything, error) - NoBindings(context.Context, *google_protobuf2.Duration) (*google_protobuf1.Empty, error) - Timeout(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error) + NoBindings(context.Context, *google_protobuf3.Duration) (*google_protobuf2.Empty, error) + Timeout(context.Context, *google_protobuf2.Empty) (*google_protobuf2.Empty, error) } func RegisterABitOfEverythingServiceServer(s *grpc.Server, srv ABitOfEverythingServiceServer) { @@ -720,7 +720,7 @@ func _ABitOfEverythingService_DeepPathEcho_Handler(srv interface{}, ctx context. } func _ABitOfEverythingService_NoBindings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(google_protobuf2.Duration) + in := new(google_protobuf3.Duration) if err := dec(in); err != nil { return nil, err } @@ -732,13 +732,13 @@ func _ABitOfEverythingService_NoBindings_Handler(srv interface{}, ctx context.Co FullMethod: "/grpc.gateway.examples.examplepb.ABitOfEverythingService/NoBindings", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ABitOfEverythingServiceServer).NoBindings(ctx, req.(*google_protobuf2.Duration)) + return srv.(ABitOfEverythingServiceServer).NoBindings(ctx, req.(*google_protobuf3.Duration)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(google_protobuf1.Empty) + in := new(google_protobuf2.Empty) if err := dec(in); err != nil { return nil, err } @@ -750,7 +750,7 @@ func _ABitOfEverythingService_Timeout_Handler(srv interface{}, ctx context.Conte FullMethod: "/grpc.gateway.examples.examplepb.ABitOfEverythingService/Timeout", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ABitOfEverythingServiceServer).Timeout(ctx, req.(*google_protobuf1.Empty)) + return srv.(ABitOfEverythingServiceServer).Timeout(ctx, req.(*google_protobuf2.Empty)) } return interceptor(ctx, in, info, handler) } @@ -807,7 +807,7 @@ var _ABitOfEverythingService_serviceDesc = grpc.ServiceDesc{ // Client API for AnotherServiceWithNoBindings service type AnotherServiceWithNoBindingsClient interface { - NoBindings(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + NoBindings(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) } type anotherServiceWithNoBindingsClient struct { @@ -818,8 +818,8 @@ func NewAnotherServiceWithNoBindingsClient(cc *grpc.ClientConn) AnotherServiceWi return &anotherServiceWithNoBindingsClient{cc} } -func (c *anotherServiceWithNoBindingsClient) NoBindings(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { - out := new(google_protobuf1.Empty) +func (c *anotherServiceWithNoBindingsClient) NoBindings(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { + out := new(google_protobuf2.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.AnotherServiceWithNoBindings/NoBindings", in, out, c.cc, opts...) if err != nil { return nil, err @@ -830,7 +830,7 @@ func (c *anotherServiceWithNoBindingsClient) NoBindings(ctx context.Context, in // Server API for AnotherServiceWithNoBindings service type AnotherServiceWithNoBindingsServer interface { - NoBindings(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error) + NoBindings(context.Context, *google_protobuf2.Empty) (*google_protobuf2.Empty, error) } func RegisterAnotherServiceWithNoBindingsServer(s *grpc.Server, srv AnotherServiceWithNoBindingsServer) { @@ -838,7 +838,7 @@ func RegisterAnotherServiceWithNoBindingsServer(s *grpc.Server, srv AnotherServi } func _AnotherServiceWithNoBindings_NoBindings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(google_protobuf1.Empty) + in := new(google_protobuf2.Empty) if err := dec(in); err != nil { return nil, err } @@ -850,7 +850,7 @@ func _AnotherServiceWithNoBindings_NoBindings_Handler(srv interface{}, ctx conte FullMethod: "/grpc.gateway.examples.examplepb.AnotherServiceWithNoBindings/NoBindings", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AnotherServiceWithNoBindingsServer).NoBindings(ctx, req.(*google_protobuf1.Empty)) + return srv.(AnotherServiceWithNoBindingsServer).NoBindings(ctx, req.(*google_protobuf2.Empty)) } return interceptor(ctx, in, info, handler) } diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index 0375c13b061..2581b04e3a3 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -49,13 +49,6 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package // SimpleMessage represents a simple message sent to the Echo service. -// -// OpenAPI: { -// "externalDocs": { -// "url": "http://github.com/grpc-ecosystem/grpc-gateway", -// "description": "Find out more about EchoService" -// } -// } type SimpleMessage struct { // Id represents the message identifier. Id string `protobuf:"bytes,1,opt,name=id" json:"id,omitempty"` @@ -100,13 +93,6 @@ type EchoServiceClient interface { // // The message posted as the id parameter will also be // returned. - // - // OpenAPI: { - // "externalDocs": { - // "url": "http://github.com/grpc-ecosystem/grpc-gateway", - // "description": "Find out more about EchoService" - // } - // } Echo(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) @@ -145,13 +131,6 @@ type EchoServiceServer interface { // // The message posted as the id parameter will also be // returned. - // - // OpenAPI: { - // "externalDocs": { - // "url": "http://github.com/grpc-ecosystem/grpc-gateway", - // "description": "Find out more about EchoService" - // } - // } Echo(context.Context, *SimpleMessage) (*SimpleMessage, error) // EchoBody method receives a simple message and returns it. EchoBody(context.Context, *SimpleMessage) (*SimpleMessage, error) @@ -217,34 +196,39 @@ var _EchoService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/examplepb/echo_service.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 453 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x92, 0xcf, 0x6a, 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 0xf5, 0x30, 0x7b, 0x83, 0x98, 0x39, - 0x59, 0x40, 0x05, 0xa3, 0x9e, 0xb0, 0xb6, 0xd4, 0xb2, 0xb9, 0x19, 0xbe, 0xe7, 0xd0, 0x8c, 0x6e, - 0x9d, 0xfd, 0xb3, 0xd0, 0x56, 0xba, 0x82, 0xf1, 0x92, 0x72, 0xfc, 0x0f, 0x65, 0xfd, 0x8a, 0xdc, - 0xde, 0xc4, 0x1a, 0x52, 0x31, 0xc5, 0x99, 0x4f, 0xcf, 0xee, 0x78, 0xde, 0xdd, 0x76, 0xba, 0xa7, - 0xc6, 0x4f, 0x2f, 0x37, 0x07, 0xfd, 0xf8, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8c, 0xde, 0xfc, - 0x33, 0x66, 0x03, 0x00, 0x00, + // 542 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x4f, 0x6b, 0xd4, 0x40, + 0x18, 0xc6, 0x49, 0x76, 0x11, 0x77, 0xfc, 0xc3, 0x12, 0xfc, 0x53, 0xa2, 0xd2, 0xe9, 0x82, 0x50, + 0x16, 0x93, 0xb1, 0x2b, 0x78, 0xd8, 0x93, 0x54, 0x54, 0x14, 0x0a, 0xba, 0x7b, 0xb0, 0xf6, 0x52, + 0x26, 0x93, 0xb7, 0xc9, 0x94, 0x64, 0xde, 0x90, 0x99, 0x74, 0xbb, 0x94, 0x5e, 0x7a, 0xee, 0xcd, + 0x93, 0x17, 0x05, 0x0f, 0x1e, 0x3c, 0x89, 0x47, 0x3f, 0x82, 0x37, 0x11, 0xfc, 0x04, 0x7e, 0x09, + 0x6f, 0x92, 0x6c, 0x5a, 0xb7, 0x6c, 0x45, 0x16, 0xec, 0x29, 0xef, 0x24, 0xcf, 0x3b, 0x79, 0x9f, + 0xdf, 0x3c, 0x09, 0xb9, 0x0d, 0xbb, 0x3c, 0xcd, 0x12, 0xd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 0x3c, 0x89, 0x51, 0x9b, 0x6e, 0xc3, 0xb2, 0x9b, 0xbd, 0x36, + 0xcf, 0xb2, 0x44, 0x8a, 0xea, 0xc3, 0x63, 0xdb, 0x1a, 0x55, 0xef, 0xda, 0xf4, 0x9d, 0x5d, 0x6f, + 0x0b, 0xd1, 0x4b, 0x65, 0x0a, 0xfd, 0x19, 0x65, 0xff, 0x2f, 0xca, 0xfc, 0x29, 0xb9, 0xbe, 0xf6, + 0x07, 0xd3, 0xb4, 0x9b, 0x79, 0x5d, 0x6c, 0xb4, 0x8e, 0xb3, 0x10, 0x9c, 0xab, 0xfe, 0x0a, 0xf7, + 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xb0, 0xf0, 0xbc, 0xab, 0x04, 0x00, 0x00, } diff --git a/examples/examplepb/echo_service.proto b/examples/examplepb/echo_service.proto index c47de2464c4..363cfa6b5ef 100644 --- a/examples/examplepb/echo_service.proto +++ b/examples/examplepb/echo_service.proto @@ -25,9 +25,9 @@ option (grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger) = { url: "https://github.com/grpc-ecosystem/grpc-gateway"; description: "More about gRPC-Gateway"; } - schemes: "http"; - schemes: "https"; - schemes: "x-foo-scheme"; + schemes: HTTP; + schemes: HTTPS; + schemes: WSS; consumes: "application/json"; consumes: "application/x-foo-mime"; produces: "application/json"; @@ -35,17 +35,16 @@ option (grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger) = { }; // SimpleMessage represents a simple message sent to the Echo service. -// -// OpenAPI: { -// "externalDocs": { -// "url": "http://github.com/grpc-ecosystem/grpc-gateway", -// "description": "Find out more about EchoService" -// } -// } message SimpleMessage { // Id represents the message identifier. string id = 1; int64 num = 2; + option (grpc_gateway.protoc_gen_swagger.options.openapiv2_schema) = { + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about EchoService"; + } + }; } // Echo service responds to incoming echo requests. @@ -54,13 +53,6 @@ service EchoService { // // The message posted as the id parameter will also be // returned. - // - // OpenAPI: { - // "externalDocs": { - // "url": "http://github.com/grpc-ecosystem/grpc-gateway", - // "description": "Find out more about EchoService" - // } - // } rpc Echo(SimpleMessage) returns (SimpleMessage) { option (google.api.http) = { post: "/v1/example/echo/{id}" @@ -70,6 +62,10 @@ service EchoService { }; option (grpc_gateway.protoc_gen_swagger.options.openapiv2_operation) = { deprecated: true + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about SimpleMessage"; + } }; } // EchoBody method receives a simple message and returns it. @@ -79,4 +75,12 @@ service EchoService { body: "*" }; } + + option (grpc_gateway.protoc_gen_swagger.options.openapiv2_tag) = { + description: "Echo service description which should not be used in place of the comment!" + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about EchoService"; + } + }; } diff --git a/examples/examplepb/echo_service.swagger.json b/examples/examplepb/echo_service.swagger.json index 783d86dc177..2f285a67e87 100644 --- a/examples/examplepb/echo_service.swagger.json +++ b/examples/examplepb/echo_service.swagger.json @@ -14,7 +14,7 @@ "schemes": [ "http", "https", - "x-foo-scheme" + "wss" ], "consumes": [ "application/json", @@ -51,8 +51,8 @@ ], "deprecated": true, "externalDocs": { - "description": "Find out more about EchoService", - "url": "http://github.com/grpc-ecosystem/grpc-gateway" + "description": "Find out more about SimpleMessage", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } }, @@ -89,8 +89,8 @@ ], "deprecated": true, "externalDocs": { - "description": "Find out more about EchoService", - "url": "http://github.com/grpc-ecosystem/grpc-gateway" + "description": "Find out more about SimpleMessage", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } }, @@ -135,7 +135,11 @@ "format": "int64" } }, - "description": "SimpleMessage represents a simple message sent to the Echo service." + "description": "SimpleMessage represents a simple message sent to the Echo service.", + "externalDocs": { + "description": "Find out more about EchoService", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } } }, "externalDocs": { diff --git a/examples/examplepb/stream.pb.go b/examples/examplepb/stream.pb.go index 71066ccd964..0fbf67d0aa1 100644 --- a/examples/examplepb/stream.pb.go +++ b/examples/examplepb/stream.pb.go @@ -7,7 +7,7 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import _ "google.golang.org/genproto/googleapis/api/annotations" -import google_protobuf1 "github.com/golang/protobuf/ptypes/empty" +import google_protobuf2 "github.com/golang/protobuf/ptypes/empty" import grpc_gateway_examples_sub "github.com/grpc-ecosystem/grpc-gateway/examples/sub" import ( @@ -32,7 +32,7 @@ const _ = grpc.SupportPackageIsVersion4 type StreamServiceClient interface { BulkCreate(ctx context.Context, opts ...grpc.CallOption) (StreamService_BulkCreateClient, error) - List(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (StreamService_ListClient, error) + List(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (StreamService_ListClient, error) BulkEcho(ctx context.Context, opts ...grpc.CallOption) (StreamService_BulkEchoClient, error) } @@ -55,7 +55,7 @@ func (c *streamServiceClient) BulkCreate(ctx context.Context, opts ...grpc.CallO type StreamService_BulkCreateClient interface { Send(*ABitOfEverything) error - CloseAndRecv() (*google_protobuf1.Empty, error) + CloseAndRecv() (*google_protobuf2.Empty, error) grpc.ClientStream } @@ -67,18 +67,18 @@ func (x *streamServiceBulkCreateClient) Send(m *ABitOfEverything) error { return x.ClientStream.SendMsg(m) } -func (x *streamServiceBulkCreateClient) CloseAndRecv() (*google_protobuf1.Empty, error) { +func (x *streamServiceBulkCreateClient) CloseAndRecv() (*google_protobuf2.Empty, error) { if err := x.ClientStream.CloseSend(); err != nil { return nil, err } - m := new(google_protobuf1.Empty) + m := new(google_protobuf2.Empty) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } return m, nil } -func (c *streamServiceClient) List(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (StreamService_ListClient, error) { +func (c *streamServiceClient) List(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (StreamService_ListClient, error) { stream, err := grpc.NewClientStream(ctx, &_StreamService_serviceDesc.Streams[1], c.cc, "/grpc.gateway.examples.examplepb.StreamService/List", opts...) if err != nil { return nil, err @@ -145,7 +145,7 @@ func (x *streamServiceBulkEchoClient) Recv() (*grpc_gateway_examples_sub.StringM type StreamServiceServer interface { BulkCreate(StreamService_BulkCreateServer) error - List(*google_protobuf1.Empty, StreamService_ListServer) error + List(*google_protobuf2.Empty, StreamService_ListServer) error BulkEcho(StreamService_BulkEchoServer) error } @@ -158,7 +158,7 @@ func _StreamService_BulkCreate_Handler(srv interface{}, stream grpc.ServerStream } type StreamService_BulkCreateServer interface { - SendAndClose(*google_protobuf1.Empty) error + SendAndClose(*google_protobuf2.Empty) error Recv() (*ABitOfEverything, error) grpc.ServerStream } @@ -167,7 +167,7 @@ type streamServiceBulkCreateServer struct { grpc.ServerStream } -func (x *streamServiceBulkCreateServer) SendAndClose(m *google_protobuf1.Empty) error { +func (x *streamServiceBulkCreateServer) SendAndClose(m *google_protobuf2.Empty) error { return x.ServerStream.SendMsg(m) } @@ -180,7 +180,7 @@ func (x *streamServiceBulkCreateServer) Recv() (*ABitOfEverything, error) { } func _StreamService_List_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(google_protobuf1.Empty) + m := new(google_protobuf2.Empty) if err := stream.RecvMsg(m); err != nil { return err } diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 2d3c55d0495..3709d19e3da 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -179,6 +179,25 @@ func renderMessagesAsDefinition(messages messageMap, d swaggerDefinitionsObject, if err := updateSwaggerDataFromComments(&schema, msgComments); err != nil { panic(err) } + opts, err := extractSchemaOptionFromMessageDescriptor(msg.DescriptorProto) + if opts != nil { + if err != nil { + panic(err) + } + if opts.ExternalDocs != nil { + if schema.ExternalDocs == nil { + schema.ExternalDocs = &swaggerExternalDocumentationObject{} + } + if opts.ExternalDocs.Description != "" { + schema.ExternalDocs.Description = opts.ExternalDocs.Description + } + if opts.ExternalDocs.Url != "" { + schema.ExternalDocs.URL = opts.ExternalDocs.Url + } + } + + // TODO(ivucica): add remaining fields of schema object + } for _, f := range msg.Fields { fieldValue := schemaOfField(f, reg) @@ -562,6 +581,17 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re if err != nil { panic(err) } + if opts.ExternalDocs != nil { + if operationObject.ExternalDocs == nil { + operationObject.ExternalDocs = &swaggerExternalDocumentationObject{} + } + if opts.ExternalDocs.Description != "" { + operationObject.ExternalDocs.Description = opts.ExternalDocs.Description + } + if opts.ExternalDocs.Url != "" { + operationObject.ExternalDocs.URL = opts.ExternalDocs.Url + } + } // TODO(ivucica): this would be better supported by looking whether the method is deprecated in the proto file operationObject.Deprecated = opts.Deprecated @@ -673,7 +703,9 @@ func applyTemplate(p param) (string, error) { } if len(spb.Schemes) > 0 { s.Schemes = make([]string, len(spb.Schemes)) - copy(s.Schemes, spb.Schemes) + for i, scheme := range spb.Schemes { + s.Schemes[i] = strings.ToLower(scheme.String()) + } } if len(spb.Consumes) > 0 { s.Consumes = make([]string, len(spb.Consumes)) @@ -716,17 +748,10 @@ func applyTemplate(p param) (string, error) { // the passed swaggerObject, the summary and description are joined by \n\n. // // If there is a field named 'Info', its 'Summary' and 'Description' fields -// will be updated instead. (JSON always gets applied directly to the passed -// object, never to 'Info'.) +// will be updated instead. // // If there is no 'Summary', the same behavior will be attempted on 'Title', // but only if the last character is not a period. -// -// To apply additional Swagger properties, one can pass valid JSON -// in the last paragraph of the comment. The last paragraph needs to start -// with the string 'OpenAPI: '. This JSON gets parsed and applied to -// the passed swaggerObject directly. This lets developers easily apply -// custom properties such as contact details, API base path, et al. func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) error { if len(comment) == 0 { return nil @@ -750,16 +775,7 @@ func updateSwaggerDataFromComments(swaggerObject interface{}, comment string) er usingTitle = true } - // Parse the JSON and apply it. - // TODO(ivucica): apply extras /after/ applying summary - // and description. paragraphs := strings.Split(comment, "\n\n") - if len(paragraphs) > 0 && strings.HasPrefix(strings.TrimLeft(paragraphs[len(paragraphs)-1], " "), "OpenAPI: ") { - if err := json.Unmarshal([]byte(strings.TrimLeft(paragraphs[len(paragraphs)-1], " "))[len("OpenAPI: "):], swaggerObject); err != nil { - return fmt.Errorf("error: %s, parsing: %s", err.Error(), paragraphs[len(paragraphs)-1]) - } - paragraphs = paragraphs[:len(paragraphs)-1] - } // If there is a summary (or summary-equivalent), use the first // paragraph as summary, and the rest as description. @@ -973,6 +989,27 @@ func extractOperationOptionFromMethodDescriptor(meth *pbdescriptor.MethodDescrip return opts, nil } +// extractSchemaOptionFromMessageDescriptor extracts the message of type +// swagger_options.Schema from a given proto message's descriptor. +func extractSchemaOptionFromMessageDescriptor(msg *pbdescriptor.DescriptorProto) (*swagger_options.Schema, error) { + if msg.Options == nil { + return nil, nil + } + if !proto.HasExtension(msg.Options, swagger_options.E_Openapiv2Schema) { + return nil, nil + } + ext, err := proto.GetExtension(msg.Options, swagger_options.E_Openapiv2Schema) + if err != nil { + return nil, err + } + opts, ok := ext.(*swagger_options.Schema) + if !ok { + return nil, fmt.Errorf("extension is %T; want an Schema", ext) + } + return opts, nil +} + + // extractSwaggerOptionFromFileDescriptor extracts the message of type // swagger_options.Swagger from a given proto method's descriptor. func extractSwaggerOptionFromFileDescriptor(file *pbdescriptor.FileDescriptorProto) (*swagger_options.Swagger, error) { diff --git a/protoc-gen-swagger/genswagger/types.go b/protoc-gen-swagger/genswagger/types.go index 5385be97d23..cd1c3563142 100644 --- a/protoc-gen-swagger/genswagger/types.go +++ b/protoc-gen-swagger/genswagger/types.go @@ -171,6 +171,8 @@ type swaggerSchemaObject struct { Description string `json:"description,omitempty"` Title string `json:"title,omitempty"` + + ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"` } // http://swagger.io/specification/#referenceObject diff --git a/protoc-gen-swagger/options/annotations.proto b/protoc-gen-swagger/options/annotations.proto index 25777108033..f79920715eb 100644 --- a/protoc-gen-swagger/options/annotations.proto +++ b/protoc-gen-swagger/options/annotations.proto @@ -15,3 +15,11 @@ extend google.protobuf.MethodOptions { // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID Operation openapiv2_operation = 123456789; } +extend google.protobuf.MessageOptions { + // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID + Schema openapiv2_schema = 123456790; +} +extend google.protobuf.ServiceOptions { + // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID + Tag openapiv2_tag = 123456791; +} diff --git a/protoc-gen-swagger/options/openapiv2.proto b/protoc-gen-swagger/options/openapiv2.proto index a2798cbaad3..6051b960db5 100644 --- a/protoc-gen-swagger/options/openapiv2.proto +++ b/protoc-gen-swagger/options/openapiv2.proto @@ -4,6 +4,8 @@ package grpc_gateway.protoc_gen_swagger.options; option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"; +import "google/protobuf/any.proto"; + // `Swagger` is a representation of OpenAPI v2 specification's Swagger object. // // See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject @@ -14,12 +16,20 @@ message Swagger { Info info = 2; string host = 3; string base_path = 4; - repeated string schemes = 5; + enum SwaggerScheme { + UNKNOWN = 0; + HTTP = 1; + HTTPS = 2; + WS = 3; + WSS = 4; + } + repeated SwaggerScheme schemes = 5; repeated string consumes = 6; repeated string produces = 7; // field 8 is reserved for 'paths'. reserved 8; - // field 9 is reserved for 'definitions'. + // field 9 is reserved for 'definitions', which at this time are already + // exposed as and customizable as proto messages. reserved 9; // field 10 is reserved for 'responses'. reserved 10; @@ -27,7 +37,9 @@ message Swagger { reserved 11; // field 12 is reserved for repeated 'security'. reserved 12; - // field 13 is reserved for repeated 'tags'. + // field 13 is reserved for 'tags', which are supposed to be exposed as and + // customizable as proto services. TODO(ivucica): add processing of proto + // service objects into OpenAPI v2 Tag objects. reserved 13; ExternalDocumentation external_docs = 14; } @@ -85,10 +97,127 @@ message Contact { // `ExternalDocumentation` is a representation of OpenAPI v2 specification's // ExternalDocumentation object. // -// https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject // // TODO(ivucica): document fields message ExternalDocumentation { string description = 1; string url = 2; } + +// `Schema` is a representation of OpenAPI v2 specification's Schema object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject +// +// TODO(ivucica): document fields +message Schema { + JSONSchema json_schema = 1; + string discriminator = 2; + bool read_only = 3; + // field 4 is reserved for 'xml'. + reserved 4; + ExternalDocumentation external_docs = 5; + google.protobuf.Any example = 6; +} + +// `JSONSchema` represents properties from JSON Schema taken, and as used, in +// the OpenAPI v2 spec. +// +// This includes changes made by OpenAPI v2. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject +// +// See also: https://cswr.github.io/JsonSchema/spec/basic_types/, +// https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json +// +// TODO(ivucica): document fields +message JSONSchema { + // field 1 is reserved for '$id', omitted from OpenAPI v2. + reserved 1; + // field 2 is reserved for '$schema', omitted from OpenAPI v2. + reserved 2; + // field 3 is reserved for '$ref', although it is unclear how it would be used. + reserved 3; + // field 4 is reserved for '$comment', omitted from OpenAPI v2. + reserved 4; + string title = 5; + string description = 6; + string default = 7; + // field 8 is reserved for 'readOnly', which has an OpenAPI v2-specific meaning and is defined there. + reserved 8; + // field 9 is reserved for 'examples', which is omitted from OpenAPI v2 in favor of 'example' field. + reserved 9; + double multiple_of = 10; + double maximum = 11; + bool exclusive_maximum = 12; + double minimum = 13; + bool exclusive_minimum = 14; + uint64 max_length = 15; + uint64 min_length = 16; + string pattern = 17; + // field 18 is reserved for 'additionalItems', omitted from OpenAPI v2. + reserved 18; + // field 19 is reserved for 'items', but in OpenAPI-specific way. TODO(ivucica): add 'items'? + reserved 19; + uint64 max_items = 20; + uint64 min_items = 21; + bool unique_items = 22; + // field 23 is reserved for 'contains', omitted from OpenAPI v2. + reserved 23; + uint64 max_properties = 24; + uint64 min_properties = 25; + repeated string required = 26; + // field 27 is reserved for 'additionalProperties', but in OpenAPI-specific way. TODO(ivucica): add 'additionalProperties'? + reserved 27; + // field 28 is reserved for 'definitions', omitted from OpenAPI v2. + reserved 28; + // field 29 is reserved for 'properties', but in OpenAPI-specific way. TODO(ivucica): add 'additionalProperties'? + reserved 29; + // following fields are reserved, as the properties have been omitted from OpenAPI v2: + // patternProperties, dependencies, propertyNames, const + reserved 30 to 33; + // Items in 'array' must be unique. + repeated string array = 34; + + enum JSONSchemaSimpleTypes { + UNKNOWN = 0; + ARRAY = 1; + BOOLEAN = 2; + INTEGER = 3; + NULL = 4; + NUMBER = 5; + OBJECT = 6; + STRING = 7; + } + + repeated JSONSchemaSimpleTypes type = 35; + // following fields are reserved, as the properties have been omitted from OpenAPI v2: + // format, contentMediaType, contentEncoding, if, then, else + reserved 36 to 41; + // field 42 is reserved for 'allOf', but in OpenAPI-specific way. TODO(ivucica): add 'allOf'? + reserved 42; + // following fields are reserved, as the properties have been omitted from OpenAPI v2: + // anyOf, oneOf, not + reserved 43 to 45; +} + +// `Tag` is a representation of OpenAPI v2 specification's Tag object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject +// +// TODO(ivucica): document fields +message Tag { + // field 1 is reserved for 'name'. In our generator, this is (to be) extracted + // from the name of proto service, and thus not exposed to the user, as + // changing tag object's name would break the link to the references to the + // tag in individual operation specifications. + // + // TODO(ivucica): Add 'name' property. Use it to allow override of the name of + // global Tag object, then use that name to reference the tag throughout the + // Swagger file. + reserved 1; + // TODO(ivucica): Description should be extracted from comments on the proto + // service object. + string description = 2; + ExternalDocumentation external_docs = 3; +} From b53579c5e82cb095de5960e0671a8d38c37ecbd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sat, 28 Oct 2017 01:15:49 +0000 Subject: [PATCH 14/26] WIP: Add built annotations.pb.go and openapiv2.pb.go. --- protoc-gen-swagger/options/annotations.pb.go | 84 +++ protoc-gen-swagger/options/openapiv2.pb.go | 739 +++++++++++++++++++ 2 files changed, 823 insertions(+) create mode 100644 protoc-gen-swagger/options/annotations.pb.go create mode 100644 protoc-gen-swagger/options/openapiv2.pb.go diff --git a/protoc-gen-swagger/options/annotations.pb.go b/protoc-gen-swagger/options/annotations.pb.go new file mode 100644 index 00000000000..bf1b5124f35 --- /dev/null +++ b/protoc-gen-swagger/options/annotations.pb.go @@ -0,0 +1,84 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: protoc-gen-swagger/options/annotations.proto + +package options + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import google_protobuf1 "github.com/golang/protobuf/protoc-gen-go/descriptor" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +var E_Openapiv2Swagger = &proto.ExtensionDesc{ + ExtendedType: (*google_protobuf1.FileOptions)(nil), + ExtensionType: (*Swagger)(nil), + Field: 123456788, + Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger", + Tag: "bytes,123456788,opt,name=openapiv2_swagger,json=openapiv2Swagger", + Filename: "protoc-gen-swagger/options/annotations.proto", +} + +var E_Openapiv2Operation = &proto.ExtensionDesc{ + ExtendedType: (*google_protobuf1.MethodOptions)(nil), + ExtensionType: (*Operation)(nil), + Field: 123456789, + Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_operation", + Tag: "bytes,123456789,opt,name=openapiv2_operation,json=openapiv2Operation", + Filename: "protoc-gen-swagger/options/annotations.proto", +} + +var E_Openapiv2Schema = &proto.ExtensionDesc{ + ExtendedType: (*google_protobuf1.MessageOptions)(nil), + ExtensionType: (*Schema)(nil), + Field: 123456790, + Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_schema", + Tag: "bytes,123456790,opt,name=openapiv2_schema,json=openapiv2Schema", + Filename: "protoc-gen-swagger/options/annotations.proto", +} + +var E_Openapiv2Tag = &proto.ExtensionDesc{ + ExtendedType: (*google_protobuf1.ServiceOptions)(nil), + ExtensionType: (*Tag)(nil), + Field: 123456791, + Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_tag", + Tag: "bytes,123456791,opt,name=openapiv2_tag,json=openapiv2Tag", + Filename: "protoc-gen-swagger/options/annotations.proto", +} + +func init() { + proto.RegisterExtension(E_Openapiv2Swagger) + proto.RegisterExtension(E_Openapiv2Operation) + proto.RegisterExtension(E_Openapiv2Schema) + proto.RegisterExtension(E_Openapiv2Tag) +} + +func init() { proto.RegisterFile("protoc-gen-swagger/options/annotations.proto", fileDescriptor1) } + +var fileDescriptor1 = []byte{ + // 326 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x3f, 0x4b, 0x03, 0x41, + 0x10, 0xc5, 0x49, 0x63, 0x71, 0x2a, 0xc6, 0xb3, 0x91, 0x20, 0x9a, 0x4e, 0x91, 0x64, 0x57, 0x62, + 0x77, 0x9d, 0x0a, 0x76, 0x12, 0xb8, 0xa4, 0xb2, 0x09, 0x9b, 0xcd, 0x38, 0x39, 0x48, 0x6e, 0x96, + 0xdd, 0x4d, 0x42, 0x9a, 0x94, 0x7e, 0x02, 0xff, 0x80, 0x5f, 0xd2, 0xaf, 0x20, 0xee, 0xdd, 0xee, + 0x09, 0x46, 0xb9, 0xee, 0x66, 0x6e, 0xde, 0xfb, 0x3d, 0x1e, 0x1b, 0x75, 0x94, 0x26, 0x4b, 0xb2, + 0x8b, 0x90, 0x77, 0xcd, 0x4a, 0x20, 0x82, 0xe6, 0xa4, 0x6c, 0x46, 0xb9, 0xe1, 0x22, 0xcf, 0xc9, + 0x0a, 0xf7, 0xcd, 0xdc, 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0xbb, 0xc7, 0x1b, 0xcc, 0xec, 0x74, + 0x31, 0x66, 0x92, 0xe6, 0xfc, 0xdb, 0xa7, 0x0b, 0x92, 0xcc, 0xda, 0x58, 0x28, 0xc7, 0xd2, 0x96, + 0xff, 0xfd, 0xec, 0xc6, 0x3b, 0xee, 0xdf, 0xf5, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0xda, + 0xd9, 0x54, 0xf2, 0x02, 0x00, 0x00, +} diff --git a/protoc-gen-swagger/options/openapiv2.pb.go b/protoc-gen-swagger/options/openapiv2.pb.go new file mode 100644 index 00000000000..e89b1f8000d --- /dev/null +++ b/protoc-gen-swagger/options/openapiv2.pb.go @@ -0,0 +1,739 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// source: protoc-gen-swagger/options/openapiv2.proto + +/* +Package options is a generated protocol buffer package. + +It is generated from these files: + protoc-gen-swagger/options/openapiv2.proto + protoc-gen-swagger/options/annotations.proto + +It has these top-level messages: + Swagger + Operation + Info + Contact + ExternalDocumentation + Schema + JSONSchema + Tag +*/ +package options + +import proto "github.com/golang/protobuf/proto" +import fmt "fmt" +import math "math" +import google_protobuf "github.com/golang/protobuf/ptypes/any" + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package + +type Swagger_SwaggerScheme int32 + +const ( + Swagger_UNKNOWN Swagger_SwaggerScheme = 0 + Swagger_HTTP Swagger_SwaggerScheme = 1 + Swagger_HTTPS Swagger_SwaggerScheme = 2 + Swagger_WS Swagger_SwaggerScheme = 3 + Swagger_WSS Swagger_SwaggerScheme = 4 +) + +var Swagger_SwaggerScheme_name = map[int32]string{ + 0: "UNKNOWN", + 1: "HTTP", + 2: "HTTPS", + 3: "WS", + 4: "WSS", +} +var Swagger_SwaggerScheme_value = map[string]int32{ + "UNKNOWN": 0, + "HTTP": 1, + "HTTPS": 2, + "WS": 3, + "WSS": 4, +} + +func (x Swagger_SwaggerScheme) String() string { + return proto.EnumName(Swagger_SwaggerScheme_name, int32(x)) +} +func (Swagger_SwaggerScheme) EnumDescriptor() ([]byte, []int) { return fileDescriptor0, []int{0, 0} } + +type JSONSchema_JSONSchemaSimpleTypes int32 + +const ( + JSONSchema_UNKNOWN JSONSchema_JSONSchemaSimpleTypes = 0 + JSONSchema_ARRAY JSONSchema_JSONSchemaSimpleTypes = 1 + JSONSchema_BOOLEAN JSONSchema_JSONSchemaSimpleTypes = 2 + JSONSchema_INTEGER JSONSchema_JSONSchemaSimpleTypes = 3 + JSONSchema_NULL JSONSchema_JSONSchemaSimpleTypes = 4 + JSONSchema_NUMBER JSONSchema_JSONSchemaSimpleTypes = 5 + JSONSchema_OBJECT JSONSchema_JSONSchemaSimpleTypes = 6 + JSONSchema_STRING JSONSchema_JSONSchemaSimpleTypes = 7 +) + +var JSONSchema_JSONSchemaSimpleTypes_name = map[int32]string{ + 0: "UNKNOWN", + 1: "ARRAY", + 2: "BOOLEAN", + 3: "INTEGER", + 4: "NULL", + 5: "NUMBER", + 6: "OBJECT", + 7: "STRING", +} +var JSONSchema_JSONSchemaSimpleTypes_value = map[string]int32{ + "UNKNOWN": 0, + "ARRAY": 1, + "BOOLEAN": 2, + "INTEGER": 3, + "NULL": 4, + "NUMBER": 5, + "OBJECT": 6, + "STRING": 7, +} + +func (x JSONSchema_JSONSchemaSimpleTypes) String() string { + return proto.EnumName(JSONSchema_JSONSchemaSimpleTypes_name, int32(x)) +} +func (JSONSchema_JSONSchemaSimpleTypes) EnumDescriptor() ([]byte, []int) { + return fileDescriptor0, []int{6, 0} +} + +// `Swagger` is a representation of OpenAPI v2 specification's Swagger object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#swaggerObject +// +// TODO(ivucica): document fields +type Swagger struct { + Swagger string `protobuf:"bytes,1,opt,name=swagger" json:"swagger,omitempty"` + Info *Info `protobuf:"bytes,2,opt,name=info" json:"info,omitempty"` + Host string `protobuf:"bytes,3,opt,name=host" json:"host,omitempty"` + BasePath string `protobuf:"bytes,4,opt,name=base_path,json=basePath" json:"base_path,omitempty"` + Schemes []Swagger_SwaggerScheme `protobuf:"varint,5,rep,packed,name=schemes,enum=grpc_gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme" json:"schemes,omitempty"` + Consumes []string `protobuf:"bytes,6,rep,name=consumes" json:"consumes,omitempty"` + Produces []string `protobuf:"bytes,7,rep,name=produces" json:"produces,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,14,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` +} + +func (m *Swagger) Reset() { *m = Swagger{} } +func (m *Swagger) String() string { return proto.CompactTextString(m) } +func (*Swagger) ProtoMessage() {} +func (*Swagger) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{0} } + +func (m *Swagger) GetSwagger() string { + if m != nil { + return m.Swagger + } + return "" +} + +func (m *Swagger) GetInfo() *Info { + if m != nil { + return m.Info + } + return nil +} + +func (m *Swagger) GetHost() string { + if m != nil { + return m.Host + } + return "" +} + +func (m *Swagger) GetBasePath() string { + if m != nil { + return m.BasePath + } + return "" +} + +func (m *Swagger) GetSchemes() []Swagger_SwaggerScheme { + if m != nil { + return m.Schemes + } + return nil +} + +func (m *Swagger) GetConsumes() []string { + if m != nil { + return m.Consumes + } + return nil +} + +func (m *Swagger) GetProduces() []string { + if m != nil { + return m.Produces + } + return nil +} + +func (m *Swagger) GetExternalDocs() *ExternalDocumentation { + if m != nil { + return m.ExternalDocs + } + return nil +} + +// `Operation` is a representation of OpenAPI v2 specification's Operation object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#operationObject +// +// TODO(ivucica): document fields +type Operation struct { + Tags []string `protobuf:"bytes,1,rep,name=tags" json:"tags,omitempty"` + Summary string `protobuf:"bytes,2,opt,name=summary" json:"summary,omitempty"` + Description string `protobuf:"bytes,3,opt,name=description" json:"description,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,4,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` + OperationId string `protobuf:"bytes,5,opt,name=operation_id,json=operationId" json:"operation_id,omitempty"` + Consumes []string `protobuf:"bytes,6,rep,name=consumes" json:"consumes,omitempty"` + Produces []string `protobuf:"bytes,7,rep,name=produces" json:"produces,omitempty"` + Schemes []string `protobuf:"bytes,10,rep,name=schemes" json:"schemes,omitempty"` + Deprecated bool `protobuf:"varint,11,opt,name=deprecated" json:"deprecated,omitempty"` +} + +func (m *Operation) Reset() { *m = Operation{} } +func (m *Operation) String() string { return proto.CompactTextString(m) } +func (*Operation) ProtoMessage() {} +func (*Operation) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{1} } + +func (m *Operation) GetTags() []string { + if m != nil { + return m.Tags + } + return nil +} + +func (m *Operation) GetSummary() string { + if m != nil { + return m.Summary + } + return "" +} + +func (m *Operation) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *Operation) GetExternalDocs() *ExternalDocumentation { + if m != nil { + return m.ExternalDocs + } + return nil +} + +func (m *Operation) GetOperationId() string { + if m != nil { + return m.OperationId + } + return "" +} + +func (m *Operation) GetConsumes() []string { + if m != nil { + return m.Consumes + } + return nil +} + +func (m *Operation) GetProduces() []string { + if m != nil { + return m.Produces + } + return nil +} + +func (m *Operation) GetSchemes() []string { + if m != nil { + return m.Schemes + } + return nil +} + +func (m *Operation) GetDeprecated() bool { + if m != nil { + return m.Deprecated + } + return false +} + +// `Info` is a representation of OpenAPI v2 specification's Info object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#infoObject +// +// TODO(ivucica): document fields +type Info struct { + Title string `protobuf:"bytes,1,opt,name=title" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` + TermsOfService string `protobuf:"bytes,3,opt,name=terms_of_service,json=termsOfService" json:"terms_of_service,omitempty"` + Contact *Contact `protobuf:"bytes,4,opt,name=contact" json:"contact,omitempty"` + Version string `protobuf:"bytes,6,opt,name=version" json:"version,omitempty"` +} + +func (m *Info) Reset() { *m = Info{} } +func (m *Info) String() string { return proto.CompactTextString(m) } +func (*Info) ProtoMessage() {} +func (*Info) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{2} } + +func (m *Info) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *Info) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *Info) GetTermsOfService() string { + if m != nil { + return m.TermsOfService + } + return "" +} + +func (m *Info) GetContact() *Contact { + if m != nil { + return m.Contact + } + return nil +} + +func (m *Info) GetVersion() string { + if m != nil { + return m.Version + } + return "" +} + +// `Contact` is a representation of OpenAPI v2 specification's Contact object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#contactObject +// +// TODO(ivucica): document fields +type Contact struct { + Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url" json:"url,omitempty"` + Email string `protobuf:"bytes,3,opt,name=email" json:"email,omitempty"` +} + +func (m *Contact) Reset() { *m = Contact{} } +func (m *Contact) String() string { return proto.CompactTextString(m) } +func (*Contact) ProtoMessage() {} +func (*Contact) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{3} } + +func (m *Contact) GetName() string { + if m != nil { + return m.Name + } + return "" +} + +func (m *Contact) GetUrl() string { + if m != nil { + return m.Url + } + return "" +} + +func (m *Contact) GetEmail() string { + if m != nil { + return m.Email + } + return "" +} + +// `ExternalDocumentation` is a representation of OpenAPI v2 specification's +// ExternalDocumentation object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#externalDocumentationObject +// +// TODO(ivucica): document fields +type ExternalDocumentation struct { + Description string `protobuf:"bytes,1,opt,name=description" json:"description,omitempty"` + Url string `protobuf:"bytes,2,opt,name=url" json:"url,omitempty"` +} + +func (m *ExternalDocumentation) Reset() { *m = ExternalDocumentation{} } +func (m *ExternalDocumentation) String() string { return proto.CompactTextString(m) } +func (*ExternalDocumentation) ProtoMessage() {} +func (*ExternalDocumentation) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{4} } + +func (m *ExternalDocumentation) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *ExternalDocumentation) GetUrl() string { + if m != nil { + return m.Url + } + return "" +} + +// `Schema` is a representation of OpenAPI v2 specification's Schema object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject +// +// TODO(ivucica): document fields +type Schema struct { + JsonSchema *JSONSchema `protobuf:"bytes,1,opt,name=json_schema,json=jsonSchema" json:"json_schema,omitempty"` + Discriminator string `protobuf:"bytes,2,opt,name=discriminator" json:"discriminator,omitempty"` + ReadOnly bool `protobuf:"varint,3,opt,name=read_only,json=readOnly" json:"read_only,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,5,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` + Example *google_protobuf.Any `protobuf:"bytes,6,opt,name=example" json:"example,omitempty"` +} + +func (m *Schema) Reset() { *m = Schema{} } +func (m *Schema) String() string { return proto.CompactTextString(m) } +func (*Schema) ProtoMessage() {} +func (*Schema) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{5} } + +func (m *Schema) GetJsonSchema() *JSONSchema { + if m != nil { + return m.JsonSchema + } + return nil +} + +func (m *Schema) GetDiscriminator() string { + if m != nil { + return m.Discriminator + } + return "" +} + +func (m *Schema) GetReadOnly() bool { + if m != nil { + return m.ReadOnly + } + return false +} + +func (m *Schema) GetExternalDocs() *ExternalDocumentation { + if m != nil { + return m.ExternalDocs + } + return nil +} + +func (m *Schema) GetExample() *google_protobuf.Any { + if m != nil { + return m.Example + } + return nil +} + +// `JSONSchema` represents properties from JSON Schema taken, and as used, in +// the OpenAPI v2 spec. +// +// This includes changes made by OpenAPI v2. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#schemaObject +// +// See also: https://cswr.github.io/JsonSchema/spec/basic_types/, +// https://github.com/json-schema-org/json-schema-spec/blob/master/schema.json +// +// TODO(ivucica): document fields +type JSONSchema struct { + Title string `protobuf:"bytes,5,opt,name=title" json:"title,omitempty"` + Description string `protobuf:"bytes,6,opt,name=description" json:"description,omitempty"` + Default string `protobuf:"bytes,7,opt,name=default" json:"default,omitempty"` + MultipleOf float64 `protobuf:"fixed64,10,opt,name=multiple_of,json=multipleOf" json:"multiple_of,omitempty"` + Maximum float64 `protobuf:"fixed64,11,opt,name=maximum" json:"maximum,omitempty"` + ExclusiveMaximum bool `protobuf:"varint,12,opt,name=exclusive_maximum,json=exclusiveMaximum" json:"exclusive_maximum,omitempty"` + Minimum float64 `protobuf:"fixed64,13,opt,name=minimum" json:"minimum,omitempty"` + ExclusiveMinimum bool `protobuf:"varint,14,opt,name=exclusive_minimum,json=exclusiveMinimum" json:"exclusive_minimum,omitempty"` + MaxLength uint64 `protobuf:"varint,15,opt,name=max_length,json=maxLength" json:"max_length,omitempty"` + MinLength uint64 `protobuf:"varint,16,opt,name=min_length,json=minLength" json:"min_length,omitempty"` + Pattern string `protobuf:"bytes,17,opt,name=pattern" json:"pattern,omitempty"` + MaxItems uint64 `protobuf:"varint,20,opt,name=max_items,json=maxItems" json:"max_items,omitempty"` + MinItems uint64 `protobuf:"varint,21,opt,name=min_items,json=minItems" json:"min_items,omitempty"` + UniqueItems bool `protobuf:"varint,22,opt,name=unique_items,json=uniqueItems" json:"unique_items,omitempty"` + MaxProperties uint64 `protobuf:"varint,24,opt,name=max_properties,json=maxProperties" json:"max_properties,omitempty"` + MinProperties uint64 `protobuf:"varint,25,opt,name=min_properties,json=minProperties" json:"min_properties,omitempty"` + Required []string `protobuf:"bytes,26,rep,name=required" json:"required,omitempty"` + // Items in 'array' must be unique. + Array []string `protobuf:"bytes,34,rep,name=array" json:"array,omitempty"` + Type []JSONSchema_JSONSchemaSimpleTypes `protobuf:"varint,35,rep,packed,name=type,enum=grpc_gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes" json:"type,omitempty"` +} + +func (m *JSONSchema) Reset() { *m = JSONSchema{} } +func (m *JSONSchema) String() string { return proto.CompactTextString(m) } +func (*JSONSchema) ProtoMessage() {} +func (*JSONSchema) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{6} } + +func (m *JSONSchema) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *JSONSchema) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *JSONSchema) GetDefault() string { + if m != nil { + return m.Default + } + return "" +} + +func (m *JSONSchema) GetMultipleOf() float64 { + if m != nil { + return m.MultipleOf + } + return 0 +} + +func (m *JSONSchema) GetMaximum() float64 { + if m != nil { + return m.Maximum + } + return 0 +} + +func (m *JSONSchema) GetExclusiveMaximum() bool { + if m != nil { + return m.ExclusiveMaximum + } + return false +} + +func (m *JSONSchema) GetMinimum() float64 { + if m != nil { + return m.Minimum + } + return 0 +} + +func (m *JSONSchema) GetExclusiveMinimum() bool { + if m != nil { + return m.ExclusiveMinimum + } + return false +} + +func (m *JSONSchema) GetMaxLength() uint64 { + if m != nil { + return m.MaxLength + } + return 0 +} + +func (m *JSONSchema) GetMinLength() uint64 { + if m != nil { + return m.MinLength + } + return 0 +} + +func (m *JSONSchema) GetPattern() string { + if m != nil { + return m.Pattern + } + return "" +} + +func (m *JSONSchema) GetMaxItems() uint64 { + if m != nil { + return m.MaxItems + } + return 0 +} + +func (m *JSONSchema) GetMinItems() uint64 { + if m != nil { + return m.MinItems + } + return 0 +} + +func (m *JSONSchema) GetUniqueItems() bool { + if m != nil { + return m.UniqueItems + } + return false +} + +func (m *JSONSchema) GetMaxProperties() uint64 { + if m != nil { + return m.MaxProperties + } + return 0 +} + +func (m *JSONSchema) GetMinProperties() uint64 { + if m != nil { + return m.MinProperties + } + return 0 +} + +func (m *JSONSchema) GetRequired() []string { + if m != nil { + return m.Required + } + return nil +} + +func (m *JSONSchema) GetArray() []string { + if m != nil { + return m.Array + } + return nil +} + +func (m *JSONSchema) GetType() []JSONSchema_JSONSchemaSimpleTypes { + if m != nil { + return m.Type + } + return nil +} + +// `Tag` is a representation of OpenAPI v2 specification's Tag object. +// +// See: https://github.com/OAI/OpenAPI-Specification/blob/3.0.0/versions/2.0.md#tagObject +// +// TODO(ivucica): document fields +type Tag struct { + // TODO(ivucica): Description should be extracted from comments on the proto + // service object. + Description string `protobuf:"bytes,2,opt,name=description" json:"description,omitempty"` + ExternalDocs *ExternalDocumentation `protobuf:"bytes,3,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` +} + +func (m *Tag) Reset() { *m = Tag{} } +func (m *Tag) String() string { return proto.CompactTextString(m) } +func (*Tag) ProtoMessage() {} +func (*Tag) Descriptor() ([]byte, []int) { return fileDescriptor0, []int{7} } + +func (m *Tag) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *Tag) GetExternalDocs() *ExternalDocumentation { + if m != nil { + return m.ExternalDocs + } + return nil +} + +func init() { + proto.RegisterType((*Swagger)(nil), "grpc_gateway.protoc_gen_swagger.options.Swagger") + proto.RegisterType((*Operation)(nil), "grpc_gateway.protoc_gen_swagger.options.Operation") + proto.RegisterType((*Info)(nil), "grpc_gateway.protoc_gen_swagger.options.Info") + proto.RegisterType((*Contact)(nil), "grpc_gateway.protoc_gen_swagger.options.Contact") + proto.RegisterType((*ExternalDocumentation)(nil), "grpc_gateway.protoc_gen_swagger.options.ExternalDocumentation") + proto.RegisterType((*Schema)(nil), "grpc_gateway.protoc_gen_swagger.options.Schema") + proto.RegisterType((*JSONSchema)(nil), "grpc_gateway.protoc_gen_swagger.options.JSONSchema") + proto.RegisterType((*Tag)(nil), "grpc_gateway.protoc_gen_swagger.options.Tag") + proto.RegisterEnum("grpc_gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme", Swagger_SwaggerScheme_name, Swagger_SwaggerScheme_value) + proto.RegisterEnum("grpc_gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes", JSONSchema_JSONSchemaSimpleTypes_name, JSONSchema_JSONSchemaSimpleTypes_value) +} + +func init() { proto.RegisterFile("protoc-gen-swagger/options/openapiv2.proto", fileDescriptor0) } + +var fileDescriptor0 = []byte{ + // 1175 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xed, 0x6e, 0xdb, 0x36, + 0x17, 0x7e, 0x65, 0xd3, 0x16, 0x7d, 0x6c, 0xe7, 0x65, 0xd5, 0x74, 0x53, 0xd3, 0x8f, 0xb9, 0x5e, + 0x87, 0x19, 0x2d, 0xe2, 0x0c, 0xe9, 0xff, 0x01, 0x49, 0x67, 0x74, 0x51, 0x53, 0xbb, 0x90, 0x5d, + 0x74, 0x1b, 0x30, 0x08, 0x8c, 0x4c, 0x3b, 0x1c, 0x24, 0x4a, 0x95, 0xa8, 0xd4, 0xbe, 0x8d, 0x5d, + 0xcf, 0x2e, 0x63, 0xf7, 0xb0, 0x3b, 0xd8, 0x8f, 0xfd, 0x1a, 0x48, 0x51, 0xf9, 0x72, 0x37, 0x04, + 0x45, 0xf7, 0xcb, 0x3c, 0xcf, 0x73, 0xce, 0x23, 0x9e, 0x0f, 0x92, 0x86, 0x27, 0x69, 0x96, 0xc8, + 0x24, 0xdc, 0x5d, 0x32, 0xb1, 0x9b, 0xbf, 0xa7, 0xcb, 0x25, 0xcb, 0xf6, 0x92, 0x54, 0xf2, 0x44, + 0xe4, 0x7b, 0x49, 0xca, 0x04, 0x4d, 0xf9, 0xd9, 0xfe, 0x50, 0x3b, 0x39, 0x5f, 0x2f, 0xb3, 0x34, + 0x0c, 0x96, 0x54, 0xb2, 0xf7, 0x74, 0x5d, 0x62, 0x61, 0xb0, 0x64, 0x22, 0x30,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4, 0x74, 0xf3, 0xda, 0xfb, 0xdb, 0xc3, 0xf2, 0x0d, 0x18, 0x56, 0x6f, 0xc0, 0xf0, 0x40, + 0xac, 0xfd, 0xca, 0xc9, 0x43, 0x18, 0x91, 0x46, 0xff, 0xaf, 0x26, 0xc0, 0x45, 0xe2, 0x17, 0xf3, + 0xda, 0xf8, 0x97, 0x79, 0x6d, 0x6e, 0xf6, 0xc5, 0x05, 0x7b, 0xce, 0x16, 0xb4, 0x88, 0xa4, 0x6b, + 0x97, 0x93, 0x63, 0x4c, 0xe7, 0x0b, 0x68, 0xc7, 0x45, 0x24, 0x79, 0x1a, 0xb1, 0x20, 0x59, 0xb8, + 0xd0, 0xb3, 0x06, 0x96, 0x0f, 0x15, 0x34, 0x59, 0xa8, 0xd0, 0x98, 0xae, 0x78, 0x5c, 0xc4, 0xfa, + 0x68, 0x59, 0x7e, 0x65, 0x3a, 0x4f, 0xe1, 0x16, 0x5b, 0x85, 0x51, 0x91, 0xf3, 0x33, 0x16, 0x54, + 0x3e, 0x1d, 0x5d, 0x5b, 0x72, 0x4e, 0xbc, 0x32, 0xce, 0x4a, 0x86, 0x0b, 0xed, 0xd2, 0x35, 0x32, + 0xa5, 0x79, 0x4d, 0xc6, 0xf8, 0x6c, 0x5d, 0x97, 0x31, 0xce, 0x0f, 0x00, 0x62, 0xba, 0x0a, 0x22, + 0x26, 0x96, 0xf2, 0xd4, 0xfd, 0x7f, 0xcf, 0x1a, 0x20, 0xbf, 0x15, 0xd3, 0xd5, 0xb1, 0x06, 0x34, + 0xcd, 0x45, 0x45, 0x13, 0x43, 0x73, 0x61, 0x68, 0x17, 0xec, 0x94, 0x4a, 0xd5, 0x14, 0xf7, 0x56, + 0x59, 0x06, 0x63, 0xaa, 0xf9, 0x50, 0xba, 0x5c, 0xb2, 0x38, 0x77, 0xb7, 0x75, 0x1c, 0x8e, 0xe9, + 0xea, 0x48, 0xd9, 0x9a, 0xe4, 0xc2, 0x90, 0x77, 0x0c, 0xc9, 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ae, 0xeb, + 0x67, 0x16, 0x91, 0xc6, 0xb5, 0x0b, 0xdf, 0x21, 0xb7, 0x3d, 0x84, 0x6f, 0x93, 0x6d, 0x0f, 0xe1, + 0xcf, 0x89, 0xeb, 0x21, 0x7c, 0x8f, 0xdc, 0xf7, 0x10, 0xbe, 0x4f, 0x1e, 0x78, 0x08, 0x3f, 0x20, + 0x0f, 0x3d, 0x84, 0x1f, 0x92, 0xbe, 0x87, 0xf0, 0x63, 0xf2, 0xc4, 0x43, 0xf8, 0x09, 0x79, 0xea, + 0x21, 0xfc, 0x94, 0x0c, 0xfb, 0xbf, 0x5a, 0x50, 0x9f, 0xd1, 0xe5, 0x0d, 0xde, 0x83, 0x8d, 0x1b, + 0xa4, 0xfe, 0xe9, 0x6f, 0x90, 0x32, 0xdd, 0xc3, 0xe7, 0x3f, 0x1d, 0x2c, 0xb9, 0x3c, 0x2d, 0x4e, + 0x86, 0x61, 0x12, 0xef, 0x29, 0xfd, 0x5d, 0x16, 0x26, 0xf9, 0x3a, 0x97, 0xcc, 0x98, 0xe6, 0x73, + 0x7b, 0xff, 0xfc, 0xbf, 0xf5, 0xa4, 0xa9, 0xb9, 0x67, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, 0xb7, + 0xe2, 0xf7, 0x42, 0xdc, 0x0a, 0x00, 0x00, +} From 60d116f52f95daaf4e4b13577eef575753dc7a88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sat, 28 Oct 2017 01:25:10 +0000 Subject: [PATCH 15/26] WIP: go fmt on protoc-gen-swagger. --- protoc-gen-swagger/genswagger/template.go | 33 +++++++++++------------ protoc-gen-swagger/genswagger/types.go | 22 +++++++-------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 3709d19e3da..30f65f3053d 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -179,25 +179,25 @@ func renderMessagesAsDefinition(messages messageMap, d swaggerDefinitionsObject, if err := updateSwaggerDataFromComments(&schema, msgComments); err != nil { panic(err) } - opts, err := extractSchemaOptionFromMessageDescriptor(msg.DescriptorProto) - if opts != nil { - if err != nil { - panic(err) - } - if opts.ExternalDocs != nil { - if schema.ExternalDocs == nil { - schema.ExternalDocs = &swaggerExternalDocumentationObject{} - } - if opts.ExternalDocs.Description != "" { - schema.ExternalDocs.Description = opts.ExternalDocs.Description + opts, err := extractSchemaOptionFromMessageDescriptor(msg.DescriptorProto) + if opts != nil { + if err != nil { + panic(err) } - if opts.ExternalDocs.Url != "" { - schema.ExternalDocs.URL = opts.ExternalDocs.Url + if opts.ExternalDocs != nil { + if schema.ExternalDocs == nil { + schema.ExternalDocs = &swaggerExternalDocumentationObject{} + } + if opts.ExternalDocs.Description != "" { + schema.ExternalDocs.Description = opts.ExternalDocs.Description + } + if opts.ExternalDocs.Url != "" { + schema.ExternalDocs.URL = opts.ExternalDocs.Url + } } - } - // TODO(ivucica): add remaining fields of schema object - } + // TODO(ivucica): add remaining fields of schema object + } for _, f := range msg.Fields { fieldValue := schemaOfField(f, reg) @@ -1009,7 +1009,6 @@ func extractSchemaOptionFromMessageDescriptor(msg *pbdescriptor.DescriptorProto) return opts, nil } - // extractSwaggerOptionFromFileDescriptor extracts the message of type // swagger_options.Swagger from a given proto method's descriptor. func extractSwaggerOptionFromFileDescriptor(file *pbdescriptor.FileDescriptorProto) (*swagger_options.Swagger, error) { diff --git a/protoc-gen-swagger/genswagger/types.go b/protoc-gen-swagger/genswagger/types.go index cd1c3563142..7263e66b7e0 100644 --- a/protoc-gen-swagger/genswagger/types.go +++ b/protoc-gen-swagger/genswagger/types.go @@ -23,8 +23,8 @@ type swaggerInfoObject struct { TermsOfService string `json:"termsOfService,omitempty"` Version string `json:"version"` - Contact *swaggerContactObject `json:"contact,omitempty"` - License *swaggerLicenseObject `json:"license,omitempty"` + Contact *swaggerContactObject `json:"contact,omitempty"` + License *swaggerLicenseObject `json:"license,omitempty"` } // http://swagger.io/specification/#contactObject @@ -48,15 +48,15 @@ type swaggerExternalDocumentationObject struct { // http://swagger.io/specification/#swaggerObject type swaggerObject struct { - Swagger string `json:"swagger"` - Info swaggerInfoObject `json:"info"` - Host string `json:"host,omitempty"` - BasePath string `json:"basePath,omitempty"` - Schemes []string `json:"schemes"` - Consumes []string `json:"consumes"` - Produces []string `json:"produces"` - Paths swaggerPathsObject `json:"paths"` - Definitions swaggerDefinitionsObject `json:"definitions"` + Swagger string `json:"swagger"` + Info swaggerInfoObject `json:"info"` + Host string `json:"host,omitempty"` + BasePath string `json:"basePath,omitempty"` + Schemes []string `json:"schemes"` + Consumes []string `json:"consumes"` + Produces []string `json:"produces"` + Paths swaggerPathsObject `json:"paths"` + Definitions swaggerDefinitionsObject `json:"definitions"` ExternalDocs *swaggerExternalDocumentationObject `json:"externalDocs,omitempty"` } From d509096b65e4f106e83dc817d076939989c4fb74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sat, 28 Oct 2017 01:57:58 +0000 Subject: [PATCH 16/26] WIP: Provide a more unique operation ID in case of additional bindings. This doesn't resolve the problem of multiple services having same operation IDs. That can be dealt with sometime in the future, however. --- .../a_bit_of_everything.swagger.json | 4 +- examples/examplepb/echo_service.pb.go | 70 +++++++++---------- examples/examplepb/echo_service.swagger.json | 2 +- protoc-gen-swagger/genswagger/template.go | 13 ++-- 4 files changed, 47 insertions(+), 42 deletions(-) diff --git a/examples/examplepb/a_bit_of_everything.swagger.json b/examples/examplepb/a_bit_of_everything.swagger.json index 052b256b505..97d984a0bb1 100644 --- a/examples/examplepb/a_bit_of_everything.swagger.json +++ b/examples/examplepb/a_bit_of_everything.swagger.json @@ -498,7 +498,7 @@ }, "/v2/example/echo": { "get": { - "operationId": "Echo", + "operationId": "Echo3", "responses": { "200": { "description": "", @@ -520,7 +520,7 @@ ] }, "post": { - "operationId": "Echo", + "operationId": "Echo2", "responses": { "200": { "description": "", diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index 2581b04e3a3..b27e78e7167 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -196,39 +196,39 @@ var _EchoService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/examplepb/echo_service.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 542 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x4f, 0x6b, 0xd4, 0x40, - 0x18, 0xc6, 0x49, 0x76, 0x11, 0x77, 0xfc, 0xc3, 0x12, 0xfc, 0x53, 0xa2, 0xd2, 0xe9, 0x82, 0x50, - 0x16, 0x93, 0xb1, 0x2b, 0x78, 0xd8, 0x93, 0x54, 0x54, 0x14, 0x0a, 0xba, 0x7b, 0xb0, 0xf6, 0x52, - 0x26, 0x93, 0xb7, 0xc9, 0x94, 0x64, 0xde, 0x90, 0x99, 0x74, 0xbb, 0x94, 0x5e, 0x7a, 0xee, 0xcd, - 0x93, 0x17, 0x05, 0x0f, 0x1e, 0x3c, 0x89, 0x47, 0x3f, 0x82, 0x37, 0x11, 0xfc, 0x04, 0x7e, 0x09, - 0x6f, 0x92, 0x6c, 0x5a, 0xb7, 0x6c, 0x45, 0x16, 0xec, 0x29, 0xef, 0x24, 0xcf, 0x3b, 0x79, 0x9f, - 0xdf, 0x3c, 0x09, 0xb9, 0x0d, 0xbb, 0x3c, 0xcd, 0x12, 0xd0, 0xac, 0x2e, 0xb2, 0x80, 0x81, 0x88, - 0x71, 0x53, 0x43, 0xbe, 0x23, 0x05, 0xf8, 0x59, 0x8e, 0x06, 0x9d, 0xc5, 0x28, 0xcf, 0x84, 0x1f, - 0x71, 0x03, 0x23, 0x3e, 0xf6, 0x8f, 0x7a, 0xfc, 0xe3, 0x1e, 0xf7, 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19, 0x65, 0xff, 0x2f, 0xca, 0xfc, 0x29, 0xb9, 0xbe, 0xf6, - 0x07, 0xd3, 0xb4, 0x9b, 0x79, 0x5d, 0x6c, 0xb4, 0x8e, 0xb3, 0x10, 0x9c, 0xab, 0xfe, 0x0a, 0xf7, - 0x7e, 0x07, 0x00, 0x00, 0xff, 0xff, 0xf7, 0xb0, 0xf0, 0xbc, 0xab, 0x04, 0x00, 0x00, + // 535 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x4f, 0x6b, 0xd4, 0x4e, + 0x18, 0xc7, 0x49, 0x76, 0xf9, 0xf1, 0xeb, 0xf8, 0x87, 0x25, 0xf8, 0xa7, 0x44, 0xa5, 0xd3, 0x05, + 0xa1, 0x2c, 0x26, 0x63, 0x57, 0xf0, 0xb0, 0x27, 0xa9, 0xa8, 0x28, 0x14, 0x74, 0xf7, 0x60, 0xed, + 0xa5, 0x24, 0x93, 0xa7, 0xc9, 0x94, 0xcd, 0x3c, 0x43, 0x66, 0xd2, 0xed, 0x52, 0x7a, 0xe9, 0xb9, + 0xb7, 0x9e, 0x3c, 0x09, 0x82, 0x1e, 0x3c, 0x7a, 0xf4, 0x25, 0x78, 0x13, 0xc1, 0x57, 0xe0, 0x9b, + 0xf0, 0x26, 0x93, 0x4d, 0xeb, 0x96, 0xad, 0xc8, 0x82, 0x9e, 0xf2, 0x4c, 0xf2, 0x7d, 0x26, 0xcf, + 0xf7, 0x33, 0xdf, 0x84, 0xdc, 0x86, 0xbd, 0x28, 0x57, 0x43, 0xd0, 0xac, 0x2e, 0x54, 0xcc, 0x80, + 0x67, 0xb8, 0xa5, 0xa1, 0xd8, 0x15, 0x1c, 0x42, 0x55, 0xa0, 0x41, 0x6f, 0x29, 0x2d, 0x14, 0x0f, + 0xd3, 0xc8, 0xc0, 0x28, 0x1a, 0x87, 0x27, 0x3d, 0xe1, 0x69, 0x8f, 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5c, 0x5f, 0xff, 0xc5, 0x66, 0xda, 0xc2, 0xbc, 0xa3, 0x6f, + 0x2e, 0x9c, 0x06, 0x20, 0xfe, 0xaf, 0xfa, 0x15, 0xdc, 0xfb, 0x19, 0x00, 0x00, 0xff, 0xff, 0x36, + 0xc6, 0xd0, 0x6e, 0xa0, 0x04, 0x00, 0x00, } diff --git a/examples/examplepb/echo_service.swagger.json b/examples/examplepb/echo_service.swagger.json index 2f285a67e87..680600df4c3 100644 --- a/examples/examplepb/echo_service.swagger.json +++ b/examples/examplepb/echo_service.swagger.json @@ -60,7 +60,7 @@ "get": { "summary": "Echo method receives a simple message and returns it.", "description": "The message posted as the id parameter will also be\nreturned.", - "operationId": "Echo", + "operationId": "Echo2", "responses": { "200": { "description": "", diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 30f65f3053d..3492556d30c 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -474,7 +474,7 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re // Correctness of svcIdx and methIdx depends on 'services' containing the services in the same order as the 'file.Service' array. for svcIdx, svc := range services { for methIdx, meth := range svc.Methods { - for _, b := range meth.Bindings { + for bIdx, b := range meth.Bindings { // Iterate over all the swagger parameters parameters := swaggerParametersObject{} for _, parameter := range b.PathParams { @@ -549,9 +549,8 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re desc += "(streaming responses)" } operationObject := &swaggerOperationObject{ - Tags: []string{svc.GetName()}, - OperationID: fmt.Sprintf("%s", meth.GetName()), - Parameters: parameters, + Tags: []string{svc.GetName()}, + Parameters: parameters, Responses: swaggerResponsesObject{ "200": swaggerResponseObject{ Description: desc, @@ -563,6 +562,12 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re }, }, } + if bIdx == 0 { + operationObject.OperationID = fmt.Sprintf("%s", meth.GetName()) + } else { + // OperationID must be unique in an OpenAPI v2 definition. + operationObject.OperationID = fmt.Sprintf("%s%d", meth.GetName(), bIdx+1) + } // Fill reference map with referenced request messages for _, param := range operationObject.Parameters { From 39496207f08d4610e9b322c70965a9a511e1a76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sat, 28 Oct 2017 01:58:52 +0000 Subject: [PATCH 17/26] WIP: Try to fix integration test by removing 'host' from the Swagger object. --- examples/examplepb/echo_service.proto | 2 +- examples/examplepb/echo_service.swagger.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/examplepb/echo_service.proto b/examples/examplepb/echo_service.proto index 363cfa6b5ef..19d37ef70e2 100644 --- a/examples/examplepb/echo_service.proto +++ b/examples/examplepb/echo_service.proto @@ -20,7 +20,7 @@ option (grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger) = { email: "none@example.com"; }; }; - host: "localhost"; + //host: "localhost"; external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway"; description: "More about gRPC-Gateway"; diff --git a/examples/examplepb/echo_service.swagger.json b/examples/examplepb/echo_service.swagger.json index 680600df4c3..146f59fb252 100644 --- a/examples/examplepb/echo_service.swagger.json +++ b/examples/examplepb/echo_service.swagger.json @@ -10,7 +10,6 @@ "email": "none@example.com" } }, - "host": "localhost", "schemes": [ "http", "https", From a386e970d9c6e886c4a3689c5ef3f74ed6973c2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sun, 29 Oct 2017 13:40:39 +0000 Subject: [PATCH 18/26] WIP: Remove swaggerExtrasRegexp. --- protoc-gen-swagger/genswagger/template.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 3492556d30c..373059a57c7 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -16,8 +16,6 @@ import ( swagger_options "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" ) -var swaggerExtrasRegexp = regexp.MustCompile(`(?s)^(.*[^\s])[\s]*[\s]*(.*)$`) - func listEnumNames(enum *descriptor.Enum) (names []string) { for _, value := range enum.GetValue() { names = append(names, value.GetName()) From 290f7774e81bc5451f9fb5e66de1da4459a2b1ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sun, 29 Oct 2017 13:47:15 +0000 Subject: [PATCH 19/26] WIP: Move error checking for extractSchemaOptionFromMessageDescriptor out of check for opts != nil. --- protoc-gen-swagger/genswagger/template.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/protoc-gen-swagger/genswagger/template.go b/protoc-gen-swagger/genswagger/template.go index 373059a57c7..344d0bee12c 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -178,10 +178,10 @@ func renderMessagesAsDefinition(messages messageMap, d swaggerDefinitionsObject, panic(err) } opts, err := extractSchemaOptionFromMessageDescriptor(msg.DescriptorProto) + if err != nil { + panic(err) + } if opts != nil { - if err != nil { - panic(err) - } if opts.ExternalDocs != nil { if schema.ExternalDocs == nil { schema.ExternalDocs = &swaggerExternalDocumentationObject{} From 97ee19b02370c25c00c7fc0c7528f89343acb078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Sun, 29 Oct 2017 15:07:20 +0000 Subject: [PATCH 20/26] WIP: Fix typo: 'want a Schema'. --- 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 344d0bee12c..4503f46a2e2 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -1007,7 +1007,7 @@ func extractSchemaOptionFromMessageDescriptor(msg *pbdescriptor.DescriptorProto) } opts, ok := ext.(*swagger_options.Schema) if !ok { - return nil, fmt.Errorf("extension is %T; want an Schema", ext) + return nil, fmt.Errorf("extension is %T; want a Schema", ext) } return opts, nil } From ceb4c4e13d1adbbeaffa670610ae83edebc704e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Wed, 1 Nov 2017 16:15:03 +0000 Subject: [PATCH 21/26] Assign IDs for proto options extensions. --- protoc-gen-swagger/options/annotations.pb.go | 59 ++++++++++---------- protoc-gen-swagger/options/annotations.proto | 16 +++--- 2 files changed, 37 insertions(+), 38 deletions(-) diff --git a/protoc-gen-swagger/options/annotations.pb.go b/protoc-gen-swagger/options/annotations.pb.go index bf1b5124f35..d2444311f1f 100644 --- a/protoc-gen-swagger/options/annotations.pb.go +++ b/protoc-gen-swagger/options/annotations.pb.go @@ -16,36 +16,36 @@ var _ = math.Inf var E_Openapiv2Swagger = &proto.ExtensionDesc{ ExtendedType: (*google_protobuf1.FileOptions)(nil), ExtensionType: (*Swagger)(nil), - Field: 123456788, + Field: 1042, Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger", - Tag: "bytes,123456788,opt,name=openapiv2_swagger,json=openapiv2Swagger", + Tag: "bytes,1042,opt,name=openapiv2_swagger,json=openapiv2Swagger", Filename: "protoc-gen-swagger/options/annotations.proto", } var E_Openapiv2Operation = &proto.ExtensionDesc{ ExtendedType: (*google_protobuf1.MethodOptions)(nil), ExtensionType: (*Operation)(nil), - Field: 123456789, + Field: 1042, Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_operation", - Tag: "bytes,123456789,opt,name=openapiv2_operation,json=openapiv2Operation", + Tag: "bytes,1042,opt,name=openapiv2_operation,json=openapiv2Operation", Filename: "protoc-gen-swagger/options/annotations.proto", } var E_Openapiv2Schema = &proto.ExtensionDesc{ ExtendedType: (*google_protobuf1.MessageOptions)(nil), ExtensionType: (*Schema)(nil), - Field: 123456790, + Field: 1042, Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_schema", - Tag: "bytes,123456790,opt,name=openapiv2_schema,json=openapiv2Schema", + Tag: "bytes,1042,opt,name=openapiv2_schema,json=openapiv2Schema", Filename: "protoc-gen-swagger/options/annotations.proto", } var E_Openapiv2Tag = &proto.ExtensionDesc{ ExtendedType: (*google_protobuf1.ServiceOptions)(nil), ExtensionType: (*Tag)(nil), - Field: 123456791, + Field: 1042, Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_tag", - Tag: "bytes,123456791,opt,name=openapiv2_tag,json=openapiv2Tag", + Tag: "bytes,1042,opt,name=openapiv2_tag,json=openapiv2Tag", Filename: "protoc-gen-swagger/options/annotations.proto", } @@ -59,26 +59,25 @@ func init() { func init() { proto.RegisterFile("protoc-gen-swagger/options/annotations.proto", fileDescriptor1) } var fileDescriptor1 = []byte{ - // 326 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x3f, 0x4b, 0x03, 0x41, - 0x10, 0xc5, 0x49, 0x63, 0x71, 0x2a, 0xc6, 0xb3, 0x91, 0x20, 0x9a, 0x4e, 0x91, 0x64, 0x57, 0x62, - 0x77, 0x9d, 0x0a, 0x76, 0x12, 0xb8, 0xa4, 0xb2, 0x09, 0x9b, 0xcd, 0x38, 0x39, 0x48, 0x6e, 0x96, - 0xdd, 0x4d, 0x42, 0x9a, 0x94, 0x7e, 0x02, 0xff, 0x80, 0x5f, 0xd2, 0xaf, 0x20, 0xee, 0xdd, 0xee, - 0x09, 0x46, 0xb9, 0xee, 0x66, 0x6e, 0xde, 0xfb, 0x3d, 0x1e, 0x1b, 0x75, 0x94, 0x26, 0x4b, 0xb2, - 0x8b, 0x90, 0x77, 0xcd, 0x4a, 0x20, 0x82, 0xe6, 0xa4, 0x6c, 0x46, 0xb9, 0xe1, 0x22, 0xcf, 0xc9, - 0x0a, 0xf7, 0xcd, 0xdc, 0x59, 0x7c, 0x8e, 0x5a, 0xc9, 0x11, 0x0a, 0x0b,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0x92, 0xe6, 0xfc, 0xdb, 0xa7, 0x0b, 0x92, 0xcc, 0xda, 0x58, 0x28, 0xc7, 0xd2, 0x96, - 0xff, 0xfd, 0xec, 0xc6, 0x3b, 0xee, 0xdf, 0xf5, 0x57, 0x00, 0x00, 0x00, 0xff, 0xff, 0x0f, 0xda, - 0xd9, 0x54, 0xf2, 0x02, 0x00, 0x00, + // 311 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x92, 0x41, 0x4b, 0x03, 0x31, + 0x10, 0x85, 0xe9, 0x45, 0x64, 0x55, 0xac, 0xeb, 0x45, 0x8a, 0x68, 0x6f, 0x8a, 0xb4, 0x89, 0xd4, + 0xdb, 0xde, 0x54, 0xf0, 0x26, 0x85, 0x6d, 0x4f, 0x5e, 0x4a, 0x9a, 0x8e, 0xd3, 0x40, 0x9b, 0x09, + 0x49, 0xda, 0x52, 0xe8, 0xd1, 0x5f, 0xe0, 0x2f, 0x16, 0x93, 0xed, 0x56, 0xd6, 0x2a, 0x7b, 0xdb, + 0x99, 0x9d, 0xf7, 0xbe, 0xc7, 0x23, 0x49, 0xc7, 0x58, 0xf2, 0x24, 0xbb, 0x08, 0xba, 0xeb, 0x56, + 0x02, 0x11, 0x2c, 0x27, 0xe3, 0x15, 0x69, 0xc7, 0x85, 0xd6, 0xe4, 0x45, 0xf8, 0x66, 0xe1, 0x2c, + 0xbd, 0x41, 0x6b, 0xe4, 0x08, 0x85, 0x87, 0x95, 0x58, 0xc7, 0x9d, 0x1c, 0x21, 0xe8, 0x51, 0x21, + 0x65, 0x85, 0xb4, 0x75, 0xf7, 0x8f, 0x2d, 0x19, 0xd0, 0xc2, 0xa8, 0x65, 0x2f, 0x1a, 0xb4, 0xda, + 0x48, 0x84, 0x33, 0xe0, 0x61, 0x1a, 0x2f, 0xde, 0xf9, 0x04, 0x9c, 0xb4, 0xca, 0x78, 0xb2, 0xf1, + 0x22, 0xdb, 0x24, 0x67, 0xa5, 0x68, 0x8b, 0x4a, 0x2f, 0x59, 0xd4, 0xb1, 0xad, 0x8e, 0xbd, 0xa8, + 0x19, 0xf4, 0x23, 0xe4, 0xe2, 0xf3, 0xb0, 0xdd, 0xb8, 0x3d, 0xea, 0xdd, 0xb3, 0x9a, 0x89, 0xd9, + 0x20, 0xce, 0x79, 0xb3, 0x24, 0x15, 0x9b, 0xec, 0xa3, 0x91, 0x9c, 0xef, 0xf0, 0x64, 0xc0, 0x86, + 0x4e, 0xd2, 0xab, 0x5f, 0x01, 0x5e, 0xc1, 0x4f, 0x69, 0x52, 0x89, 0xd0, 0xab, 0x1d, 0xa1, 0xbf, + 0xb5, 0xce, 0xd3, 0x92, 0x57, 0xee, 0xb2, 0x4d, 0xd2, 0xfc, 0x51, 0x82, 0x9c, 0xc2, 0x5c, 0xa4, + 0xd7, 0x7b, 0x22, 0x38, 0x27, 0xb0, 0x5a, 0x03, 0xaf, 0x5f, 0x43, 0x30, 0xce, 0x4f, 0x77, 0x2d, + 0x84, 0x45, 0xe6, 0x92, 0x93, 0x1d, 0xdd, 0x0b, 0xdc, 0x83, 0x1e, 0x80, 0x5d, 0x2a, 0x59, 0x45, + 0x77, 0x6a, 0xa3, 0x87, 0x02, 0xf3, 0xe3, 0x12, 0x32, 0x14, 0xf8, 0xf4, 0xfc, 0xf6, 0x88, 0xca, + 0x4f, 0x17, 0x63, 0x26, 0x69, 0xce, 0xbf, 0x7d, 0xba, 0x20, 0xc9, 0xad, 0x9d, 0x87, 0x62, 0x2c, + 0x6c, 0xf9, 0xdf, 0xcf, 0x6d, 0x7c, 0x10, 0xfe, 0x3d, 0x7c, 0x05, 0x00, 0x00, 0xff, 0xff, 0x83, + 0x43, 0x41, 0xa3, 0xea, 0x02, 0x00, 0x00, } diff --git a/protoc-gen-swagger/options/annotations.proto b/protoc-gen-swagger/options/annotations.proto index f79920715eb..d71a275e924 100644 --- a/protoc-gen-swagger/options/annotations.proto +++ b/protoc-gen-swagger/options/annotations.proto @@ -8,18 +8,18 @@ import "protoc-gen-swagger/options/openapiv2.proto"; import "google/protobuf/descriptor.proto"; extend google.protobuf.FileOptions { - // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID - Swagger openapiv2_swagger = 123456788; + // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + Swagger openapiv2_swagger = 1042; } extend google.protobuf.MethodOptions { - // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID - Operation openapiv2_operation = 123456789; + // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + Operation openapiv2_operation = 1042; } extend google.protobuf.MessageOptions { - // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID - Schema openapiv2_schema = 123456790; + // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + Schema openapiv2_schema = 1042; } extend google.protobuf.ServiceOptions { - // TODO(ivucica): ask protobuf-global-extension-registry@google.com to assign ID - Tag openapiv2_tag = 123456791; + // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + Tag openapiv2_tag = 1042; } From 099fda525e868f6b0c967299d71c2d5a801d163c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Wed, 1 Nov 2017 19:20:37 +0000 Subject: [PATCH 22/26] Move test definitions for options-based extension to Swagger output file from echo service to a bit of everything service. --- examples/examplepb/a_bit_of_everything.pb.go | 275 ++++++++++-------- examples/examplepb/a_bit_of_everything.proto | 64 ++++ .../a_bit_of_everything.swagger.json | 59 +++- examples/examplepb/echo_service.pb.go | 54 ++-- examples/examplepb/echo_service.proto | 46 --- examples/examplepb/echo_service.swagger.json | 40 +-- examples/examplepb/stream.pb.go | 20 +- 7 files changed, 302 insertions(+), 256 deletions(-) diff --git a/examples/examplepb/a_bit_of_everything.pb.go b/examples/examplepb/a_bit_of_everything.pb.go index 452ed94ea43..2727fba7b07 100644 --- a/examples/examplepb/a_bit_of_everything.pb.go +++ b/examples/examplepb/a_bit_of_everything.pb.go @@ -7,11 +7,12 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import _ "google.golang.org/genproto/googleapis/api/annotations" -import google_protobuf2 "github.com/golang/protobuf/ptypes/empty" -import google_protobuf3 "github.com/golang/protobuf/ptypes/duration" +import google_protobuf1 "github.com/golang/protobuf/ptypes/empty" +import google_protobuf2 "github.com/golang/protobuf/ptypes/duration" import grpc_gateway_examples_sub "github.com/grpc-ecosystem/grpc-gateway/examples/sub" import sub2 "github.com/grpc-ecosystem/grpc-gateway/examples/sub2" -import google_protobuf4 "github.com/golang/protobuf/ptypes/timestamp" +import google_protobuf3 "github.com/golang/protobuf/ptypes/timestamp" +import _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" import ( context "golang.org/x/net/context" @@ -104,7 +105,7 @@ type ABitOfEverything struct { MappedStringValue map[string]string `protobuf:"bytes,23,rep,name=mapped_string_value,json=mappedStringValue" json:"mapped_string_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` MappedNestedValue map[string]*ABitOfEverything_Nested `protobuf:"bytes,24,rep,name=mapped_nested_value,json=mappedNestedValue" json:"mapped_nested_value,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` NonConventionalNameValue string `protobuf:"bytes,26,opt,name=nonConventionalNameValue" json:"nonConventionalNameValue,omitempty"` - TimestampValue *google_protobuf4.Timestamp `protobuf:"bytes,27,opt,name=timestamp_value,json=timestampValue" json:"timestamp_value,omitempty"` + TimestampValue *google_protobuf3.Timestamp `protobuf:"bytes,27,opt,name=timestamp_value,json=timestampValue" json:"timestamp_value,omitempty"` // repeated enum value. it is comma-separated in query RepeatedEnumValue []NumericEnum `protobuf:"varint,28,rep,packed,name=repeated_enum_value,json=repeatedEnumValue,enum=grpc.gateway.examples.examplepb.NumericEnum" json:"repeated_enum_value,omitempty"` } @@ -119,7 +120,7 @@ type isABitOfEverything_OneofValue interface { } type ABitOfEverything_OneofEmpty struct { - OneofEmpty *google_protobuf2.Empty `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,oneof"` + OneofEmpty *google_protobuf1.Empty `protobuf:"bytes,20,opt,name=oneof_empty,json=oneofEmpty,oneof"` } type ABitOfEverything_OneofString struct { OneofString string `protobuf:"bytes,21,opt,name=oneof_string,json=oneofString,oneof"` @@ -268,7 +269,7 @@ func (m *ABitOfEverything) GetRepeatedStringValue() []string { return nil } -func (m *ABitOfEverything) GetOneofEmpty() *google_protobuf2.Empty { +func (m *ABitOfEverything) GetOneofEmpty() *google_protobuf1.Empty { if x, ok := m.GetOneofValue().(*ABitOfEverything_OneofEmpty); ok { return x.OneofEmpty } @@ -310,7 +311,7 @@ func (m *ABitOfEverything) GetNonConventionalNameValue() string { return "" } -func (m *ABitOfEverything) GetTimestampValue() *google_protobuf4.Timestamp { +func (m *ABitOfEverything) GetTimestampValue() *google_protobuf3.Timestamp { if m != nil { return m.TimestampValue } @@ -358,7 +359,7 @@ func _ABitOfEverything_OneofUnmarshaler(msg proto.Message, tag, wire int, b *pro if wire != proto.WireBytes { return true, proto.ErrInternalBadWireType } - msg := new(google_protobuf2.Empty) + msg := new(google_protobuf1.Empty) err := b.DecodeMessage(msg) m.OneofValue = &ABitOfEverything_OneofEmpty{msg} return true, err @@ -449,13 +450,20 @@ type ABitOfEverythingServiceClient interface { Create(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) CreateBody(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) Lookup(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*ABitOfEverything, error) - Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) - Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) - GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) + Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + // Echo allows posting a StringMessage value. + // + // It also exposes multiple bindings. + // + // This makes it useful when validating that the OpenAPI v2 API + // description exposes documentation correctly on all paths + // defined as additional_bindings in the proto. Echo(ctx context.Context, in *grpc_gateway_examples_sub.StringMessage, opts ...grpc.CallOption) (*grpc_gateway_examples_sub.StringMessage, error) DeepPathEcho(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) - NoBindings(ctx context.Context, in *google_protobuf3.Duration, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) - Timeout(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) + NoBindings(ctx context.Context, in *google_protobuf2.Duration, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) + Timeout(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) } type aBitOfEverythingServiceClient struct { @@ -493,8 +501,8 @@ func (c *aBitOfEverythingServiceClient) Lookup(ctx context.Context, in *sub2.IdM return out, nil } -func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { - out := new(google_protobuf2.Empty) +func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/Update", in, out, c.cc, opts...) if err != nil { return nil, err @@ -502,8 +510,8 @@ func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEv return out, nil } -func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { - out := new(google_protobuf2.Empty) +func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *sub2.IdMessage, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/Delete", in, out, c.cc, opts...) if err != nil { return nil, err @@ -511,8 +519,8 @@ func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *sub2.IdM return out, nil } -func (c *aBitOfEverythingServiceClient) GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { - out := new(google_protobuf2.Empty) +func (c *aBitOfEverythingServiceClient) GetQuery(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/GetQuery", in, out, c.cc, opts...) if err != nil { return nil, err @@ -538,8 +546,8 @@ func (c *aBitOfEverythingServiceClient) DeepPathEcho(ctx context.Context, in *AB return out, nil } -func (c *aBitOfEverythingServiceClient) NoBindings(ctx context.Context, in *google_protobuf3.Duration, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { - out := new(google_protobuf2.Empty) +func (c *aBitOfEverythingServiceClient) NoBindings(ctx context.Context, in *google_protobuf2.Duration, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/NoBindings", in, out, c.cc, opts...) if err != nil { return nil, err @@ -547,8 +555,8 @@ func (c *aBitOfEverythingServiceClient) NoBindings(ctx context.Context, in *goog return out, nil } -func (c *aBitOfEverythingServiceClient) Timeout(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { - out := new(google_protobuf2.Empty) +func (c *aBitOfEverythingServiceClient) Timeout(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.ABitOfEverythingService/Timeout", in, out, c.cc, opts...) if err != nil { return nil, err @@ -562,13 +570,20 @@ type ABitOfEverythingServiceServer interface { Create(context.Context, *ABitOfEverything) (*ABitOfEverything, error) CreateBody(context.Context, *ABitOfEverything) (*ABitOfEverything, error) Lookup(context.Context, *sub2.IdMessage) (*ABitOfEverything, error) - Update(context.Context, *ABitOfEverything) (*google_protobuf2.Empty, error) - Delete(context.Context, *sub2.IdMessage) (*google_protobuf2.Empty, error) - GetQuery(context.Context, *ABitOfEverything) (*google_protobuf2.Empty, error) + Update(context.Context, *ABitOfEverything) (*google_protobuf1.Empty, error) + Delete(context.Context, *sub2.IdMessage) (*google_protobuf1.Empty, error) + GetQuery(context.Context, *ABitOfEverything) (*google_protobuf1.Empty, error) + // Echo allows posting a StringMessage value. + // + // It also exposes multiple bindings. + // + // This makes it useful when validating that the OpenAPI v2 API + // description exposes documentation correctly on all paths + // defined as additional_bindings in the proto. Echo(context.Context, *grpc_gateway_examples_sub.StringMessage) (*grpc_gateway_examples_sub.StringMessage, error) DeepPathEcho(context.Context, *ABitOfEverything) (*ABitOfEverything, error) - NoBindings(context.Context, *google_protobuf3.Duration) (*google_protobuf2.Empty, error) - Timeout(context.Context, *google_protobuf2.Empty) (*google_protobuf2.Empty, error) + NoBindings(context.Context, *google_protobuf2.Duration) (*google_protobuf1.Empty, error) + Timeout(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error) } func RegisterABitOfEverythingServiceServer(s *grpc.Server, srv ABitOfEverythingServiceServer) { @@ -720,7 +735,7 @@ func _ABitOfEverythingService_DeepPathEcho_Handler(srv interface{}, ctx context. } func _ABitOfEverythingService_NoBindings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(google_protobuf3.Duration) + in := new(google_protobuf2.Duration) if err := dec(in); err != nil { return nil, err } @@ -732,13 +747,13 @@ func _ABitOfEverythingService_NoBindings_Handler(srv interface{}, ctx context.Co FullMethod: "/grpc.gateway.examples.examplepb.ABitOfEverythingService/NoBindings", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ABitOfEverythingServiceServer).NoBindings(ctx, req.(*google_protobuf3.Duration)) + return srv.(ABitOfEverythingServiceServer).NoBindings(ctx, req.(*google_protobuf2.Duration)) } return interceptor(ctx, in, info, handler) } func _ABitOfEverythingService_Timeout_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(google_protobuf2.Empty) + in := new(google_protobuf1.Empty) if err := dec(in); err != nil { return nil, err } @@ -750,7 +765,7 @@ func _ABitOfEverythingService_Timeout_Handler(srv interface{}, ctx context.Conte FullMethod: "/grpc.gateway.examples.examplepb.ABitOfEverythingService/Timeout", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ABitOfEverythingServiceServer).Timeout(ctx, req.(*google_protobuf2.Empty)) + return srv.(ABitOfEverythingServiceServer).Timeout(ctx, req.(*google_protobuf1.Empty)) } return interceptor(ctx, in, info, handler) } @@ -807,7 +822,7 @@ var _ABitOfEverythingService_serviceDesc = grpc.ServiceDesc{ // Client API for AnotherServiceWithNoBindings service type AnotherServiceWithNoBindingsClient interface { - NoBindings(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) + NoBindings(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) } type anotherServiceWithNoBindingsClient struct { @@ -818,8 +833,8 @@ func NewAnotherServiceWithNoBindingsClient(cc *grpc.ClientConn) AnotherServiceWi return &anotherServiceWithNoBindingsClient{cc} } -func (c *anotherServiceWithNoBindingsClient) NoBindings(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (*google_protobuf2.Empty, error) { - out := new(google_protobuf2.Empty) +func (c *anotherServiceWithNoBindingsClient) NoBindings(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (*google_protobuf1.Empty, error) { + out := new(google_protobuf1.Empty) err := grpc.Invoke(ctx, "/grpc.gateway.examples.examplepb.AnotherServiceWithNoBindings/NoBindings", in, out, c.cc, opts...) if err != nil { return nil, err @@ -830,7 +845,7 @@ func (c *anotherServiceWithNoBindingsClient) NoBindings(ctx context.Context, in // Server API for AnotherServiceWithNoBindings service type AnotherServiceWithNoBindingsServer interface { - NoBindings(context.Context, *google_protobuf2.Empty) (*google_protobuf2.Empty, error) + NoBindings(context.Context, *google_protobuf1.Empty) (*google_protobuf1.Empty, error) } func RegisterAnotherServiceWithNoBindingsServer(s *grpc.Server, srv AnotherServiceWithNoBindingsServer) { @@ -838,7 +853,7 @@ func RegisterAnotherServiceWithNoBindingsServer(s *grpc.Server, srv AnotherServi } func _AnotherServiceWithNoBindings_NoBindings_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(google_protobuf2.Empty) + in := new(google_protobuf1.Empty) if err := dec(in); err != nil { return nil, err } @@ -850,7 +865,7 @@ func _AnotherServiceWithNoBindings_NoBindings_Handler(srv interface{}, ctx conte FullMethod: "/grpc.gateway.examples.examplepb.AnotherServiceWithNoBindings/NoBindings", } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(AnotherServiceWithNoBindingsServer).NoBindings(ctx, req.(*google_protobuf2.Empty)) + return srv.(AnotherServiceWithNoBindingsServer).NoBindings(ctx, req.(*google_protobuf1.Empty)) } return interceptor(ctx, in, info, handler) } @@ -871,87 +886,105 @@ var _AnotherServiceWithNoBindings_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/examplepb/a_bit_of_everything.proto", fileDescriptor1) } var fileDescriptor1 = []byte{ - // 1297 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xcf, 0xd8, 0x89, 0x13, 0x3f, 0xc7, 0x89, 0x33, 0x69, 0x53, 0xd7, 0x2d, 0x64, 0x71, 0x01, - 0xad, 0x42, 0xb5, 0xab, 0xba, 0x15, 0x6a, 0x23, 0x41, 0x95, 0x34, 0x86, 0x22, 0xda, 0xb4, 0xdd, - 0xfe, 0x41, 0x8a, 0x5a, 0xac, 0xb5, 0x3d, 0xb6, 0x57, 0xf1, 0xee, 0x2c, 0xbb, 0xb3, 0x26, 0x96, - 0x31, 0x07, 0x0e, 0x5c, 0x38, 0x72, 0xef, 0x05, 0x09, 0x71, 0xe1, 0xc8, 0x19, 0xbe, 0x03, 0x5f, - 0x81, 0x03, 0x1f, 0x03, 0xed, 0xcc, 0xec, 0x76, 0xd7, 0x89, 0xe5, 0x26, 0x45, 0xbd, 0xed, 0xcc, - 0x7b, 0xef, 0xf7, 0x7b, 0x7f, 0xe6, 0xbd, 0x99, 0x85, 0xab, 0xe4, 0xc8, 0xb4, 0xdd, 0x3e, 0xf1, - 0x75, 0xf9, 0xe1, 0x36, 0x75, 0xb3, 0xd1, 0xb4, 0x58, 0x83, 0x76, 0x1a, 0x64, 0x40, 0xbc, 0x21, - 0xeb, 0x59, 0x4e, 0x57, 0x73, 0x3d, 0xca, 0x28, 0xde, 0xec, 0x7a, 0x6e, 0x4b, 0xeb, 0x9a, 0x8c, - 0x7c, 0x6b, 0x0e, 0xb5, 0xc8, 0x54, 0x8b, 0x4d, 0x2b, 0x97, 0xbb, 0x94, 0x76, 0xfb, 0x44, 0x37, - 0x5d, 0x4b, 0x37, 0x1d, 0x87, 0x32, 0x93, 0x59, 0xd4, 0xf1, 0x85, 0x79, 0xe5, 0x92, 0x94, 0xf2, - 0x55, 0x33, 0xe8, 0xe8, 0xc4, 0x76, 0xd9, 0x50, 0x0a, 0xdf, 0x9d, 0x14, 0xb6, 0x03, 0x8f, 0x5b, - 0x4b, 0x79, 0x25, 0xf6, 0xd4, 0x0f, 0x9a, 0xba, 0x4d, 0x7c, 0xdf, 0xec, 0x92, 0x08, 0x38, 0x29, - 0xab, 0x4d, 0x08, 0x37, 0x27, 0x81, 0x99, 0x65, 0x13, 0x9f, 0x99, 0xb6, 0x2b, 0x14, 0xaa, 0x7f, - 0xad, 0x42, 0x69, 0x67, 0xd7, 0x62, 0x0f, 0x3a, 0xf5, 0x38, 0x60, 0xfc, 0x02, 0x8a, 0xbe, 0xe5, - 0x74, 0xfb, 0xa4, 0xe1, 0x10, 0x9f, 0x91, 0x76, 0xf9, 0xa2, 0x82, 0xd4, 0x42, 0xed, 0xa6, 0x36, - 0x23, 0x05, 0xda, 0x24, 0x92, 0xb6, 0xcf, 0xed, 0x8d, 0x65, 0x01, 0x27, 0x56, 0x18, 0xc3, 0x7c, - 0x10, 0x58, 0xed, 0x32, 0x52, 0x90, 0x9a, 0x37, 0xf8, 0x37, 0x7e, 0x08, 0x39, 0xc9, 0x95, 0x51, - 0xb2, 0x6f, 0xc4, 0x25, 0x71, 0xf0, 0x26, 0x14, 0x3a, 0x7d, 0x6a, 0xb2, 0xc6, 0xc0, 0xec, 0x07, - 0xa4, 0x9c, 0x55, 0x90, 0x9a, 0x31, 0x80, 0x6f, 0x3d, 0x0b, 0x77, 0xf0, 0x7b, 0xb0, 0xdc, 0xa6, - 0x41, 0xb3, 0x4f, 0xa4, 0xc6, 0xbc, 0x82, 0x54, 0x64, 0x14, 0xc4, 0x9e, 0x50, 0xd9, 0x84, 0x82, - 0xe5, 0xb0, 0x8f, 0x6f, 0x48, 0x8d, 0x05, 0x05, 0xa9, 0x59, 0x03, 0xf8, 0x56, 0x8c, 0x11, 0x24, - 0x35, 0x72, 0x0a, 0x52, 0xe7, 0x8d, 0x42, 0x90, 0x50, 0x11, 0x18, 0xd7, 0x6b, 0x52, 0x63, 0x51, - 0x41, 0xea, 0x02, 0xc7, 0xb8, 0x5e, 0x13, 0x0a, 0x57, 0xa0, 0xd8, 0xb1, 0x8e, 0x48, 0x3b, 0x06, - 0x59, 0x52, 0x90, 0x9a, 0x33, 0x96, 0xe5, 0x66, 0x5a, 0x29, 0xc6, 0xc9, 0x2b, 0x48, 0x5d, 0x94, - 0x4a, 0x11, 0xd2, 0x3b, 0x00, 0x4d, 0x4a, 0xfb, 0x52, 0x03, 0x14, 0xa4, 0x2e, 0x19, 0xf9, 0x70, - 0x27, 0x76, 0xd6, 0x67, 0x9e, 0xe5, 0x74, 0xa5, 0x42, 0x81, 0xe7, 0xbf, 0x20, 0xf6, 0x52, 0xf1, - 0xc4, 0x2c, 0x45, 0x05, 0xa9, 0x45, 0x11, 0x4f, 0x44, 0xf2, 0x25, 0x00, 0x71, 0x02, 0x5b, 0x2a, - 0xac, 0x28, 0x48, 0x5d, 0xa9, 0x5d, 0x9d, 0x59, 0xad, 0xfd, 0xc0, 0x26, 0x9e, 0xd5, 0xaa, 0x3b, - 0x81, 0x6d, 0xe4, 0x43, 0x7b, 0x01, 0xf6, 0x01, 0xac, 0xf8, 0xe9, 0xb8, 0x56, 0x15, 0xa4, 0xae, - 0x1a, 0x45, 0x3f, 0x15, 0x58, 0xac, 0x16, 0xe7, 0xa8, 0xa4, 0x20, 0xb5, 0x14, 0xa9, 0x25, 0xaa, - 0xe1, 0x27, 0xbd, 0x5f, 0x53, 0x90, 0xba, 0x66, 0x14, 0xfc, 0x84, 0xf7, 0x52, 0x25, 0xc6, 0xc1, - 0x0a, 0x52, 0xb1, 0x50, 0x89, 0x50, 0x6a, 0x70, 0xde, 0x23, 0x2e, 0x31, 0x19, 0x69, 0x37, 0x52, - 0xf9, 0x5a, 0x57, 0xb2, 0x6a, 0xde, 0x58, 0x8f, 0x84, 0x8f, 0x13, 0x79, 0xbb, 0x05, 0x05, 0xea, - 0x90, 0x70, 0x6c, 0x84, 0x5d, 0x5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76, 0x0b, 0x07, 0xf9, 0x38, 0xb3, 0xcd, - 0x1c, 0x17, 0x5f, 0xff, 0x2f, 0x00, 0x00, 0xff, 0xff, 0xab, 0xe5, 0x92, 0x0d, 0xc9, 0x0f, 0x00, - 0x00, + // 1590 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x57, 0xcf, 0x6f, 0x1b, 0xc5, + 0x17, 0xcf, 0xd8, 0x89, 0x13, 0x8f, 0xf3, 0xc3, 0x99, 0xb4, 0xa9, 0xeb, 0xe6, 0xfb, 0xcd, 0xd4, + 0x2d, 0x68, 0x15, 0xe2, 0x5d, 0xe2, 0x56, 0xa8, 0xb5, 0x04, 0xc5, 0x49, 0xdc, 0x1f, 0xa2, 0x4d, + 0xdb, 0xed, 0x0f, 0xaa, 0xd0, 0x12, 0xad, 0xed, 0xb1, 0xbd, 0x8d, 0x77, 0x67, 0xd9, 0x9d, 0x4d, + 0x63, 0x19, 0x73, 0xe0, 0x80, 0xd4, 0x6b, 0xb8, 0x21, 0xd1, 0x0b, 0x12, 0x02, 0x09, 0x8e, 0x9c, + 0x38, 0x70, 0xe7, 0xca, 0x5f, 0x80, 0xc4, 0x1f, 0x82, 0x76, 0x66, 0x77, 0xb3, 0xb6, 0x63, 0xa5, + 0x4e, 0x51, 0x4f, 0xde, 0x99, 0xf9, 0xbc, 0xcf, 0xe7, 0xbd, 0x37, 0xf3, 0xde, 0x8c, 0xe1, 0x2a, + 0xd9, 0xd7, 0x0c, 0xab, 0x45, 0x1c, 0xc5, 0xff, 0xb0, 0x2a, 0x8a, 0xb6, 0x53, 0xd1, 0xd9, 0x0e, + 0xad, 0xef, 0x90, 0x3d, 0x62, 0xb7, 0x59, 0x53, 0x37, 0x1b, 0xb2, 0x65, 0x53, 0x46, 0xd1, 0x72, + 0xc3, 0xb6, 0xaa, 0x72, 0x43, 0x63, 0xe4, 0x85, 0xd6, 0x96, 0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c5, 0x54, 0xc8, 0xa7, 0x1e, 0x7b, 0x33, 0xe8, 0x3c, 0x9c, 0xae, 0x51, 0xb7, 0xd2, 0x22, 0x3e, + 0x62, 0x1c, 0x03, 0x09, 0xa8, 0x29, 0x31, 0x27, 0x20, 0xcb, 0x30, 0xa5, 0x9b, 0xec, 0x83, 0xcb, + 0x3e, 0x62, 0x02, 0x03, 0x29, 0xae, 0x42, 0x3e, 0x15, 0x72, 0xb8, 0x51, 0x44, 0x02, 0x03, 0x69, + 0x5c, 0x4d, 0xb9, 0x11, 0x88, 0xe0, 0xb8, 0x54, 0xf0, 0x11, 0x93, 0x18, 0x48, 0x13, 0x9c, 0xe3, + 0x52, 0x41, 0x00, 0x2e, 0xc0, 0x99, 0xba, 0xbe, 0x4f, 0x6a, 0x21, 0xc9, 0x14, 0x06, 0x52, 0x42, + 0x9d, 0xf6, 0x27, 0x7b, 0x41, 0x21, 0x4f, 0x12, 0x03, 0x69, 0xd2, 0x07, 0x05, 0x4c, 0xff, 0x83, + 0xb0, 0x42, 0x69, 0xcb, 0x47, 0x40, 0x0c, 0xa4, 0x29, 0x35, 0xe9, 0xcd, 0x84, 0xce, 0x3a, 0xcc, + 0xd6, 0xcd, 0x86, 0x0f, 0x48, 0xf1, 0xfc, 0xa7, 0xc4, 0x5c, 0x4f, 0x3c, 0xa1, 0xca, 0x0c, 0x06, + 0xd2, 0x8c, 0x88, 0x27, 0x10, 0xf9, 0x04, 0x42, 0x62, 0xba, 0x86, 0x0f, 0x98, 0xc5, 0x40, 0x9a, + 0x2d, 0xac, 0x1e, 0xbb, 0x5b, 0x5b, 0xae, 0x41, 0x6c, 0xbd, 0x5a, 0x36, 0x5d, 0x43, 0x4d, 0x7a, + 0xf6, 0x82, 0xec, 0x1d, 0x38, 0xeb, 0xf4, 0xc6, 0x35, 0x87, 0x81, 0x34, 0xa7, 0xce, 0x38, 0x3d, + 0x81, 0x85, 0xb0, 0x30, 0x47, 0x69, 0x0c, 0xa4, 0x74, 0x00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xe7, 0xb3, 0xf7, 0xe1, 0xf2, 0x51, 0x35, 0xe5, 0x6d, + 0x66, 0x70, 0x01, 0x8f, 0x78, 0xee, 0x0a, 0x9f, 0xc3, 0xa5, 0x92, 0x49, 0x59, 0x93, 0xd8, 0x3e, + 0xc3, 0xa7, 0x3a, 0x6b, 0x46, 0xd2, 0xfd, 0x51, 0x4f, 0xf2, 0x47, 0x4d, 0xde, 0xd8, 0xfa, 0xcf, + 0xb1, 0x83, 0xd2, 0x77, 0x31, 0xc4, 0xe0, 0x42, 0x09, 0xaf, 0xeb, 0xcc, 0x0b, 0x30, 0x72, 0x36, + 0x9e, 0xc0, 0x53, 0x0d, 0xf5, 0xde, 0x46, 0xfe, 0x86, 0xf0, 0x06, 0x5b, 0x36, 0x7d, 0x4e, 0xaa, + 0x6c, 0xd4, 0x28, 0xb2, 0x69, 0x93, 0x9a, 0xe4, 0x63, 0x7f, 0x77, 0x3c, 0x74, 0x21, 0xbe, 0x26, + 0xbf, 0xbf, 0x12, 0x07, 0xb1, 0xf1, 0x42, 0x5a, 0xb3, 0xac, 0x96, 0x5e, 0xe5, 0xa9, 0x54, 0x9e, + 0x3b, 0xd4, 0x2c, 0x2c, 0x46, 0x67, 0xf6, 0xf3, 0x75, 0x4a, 0xf3, 0x86, 0x6e, 0x90, 0xe2, 0x00, + 0xb2, 0x38, 0x04, 0x69, 0xdf, 0x82, 0x67, 0xee, 0x1c, 0xe6, 0x3f, 0x1a, 0xc2, 0xa8, 0xae, 0x6f, + 0x27, 0xc3, 0xd2, 0xa9, 0x24, 0x78, 0xf6, 0x2e, 0xfd, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x88, 0x7d, + 0xbe, 0x6f, 0xd5, 0x12, 0x00, 0x00, } diff --git a/examples/examplepb/a_bit_of_everything.proto b/examples/examplepb/a_bit_of_everything.proto index 91e561e06a8..a129d624932 100644 --- a/examples/examplepb/a_bit_of_everything.proto +++ b/examples/examplepb/a_bit_of_everything.proto @@ -8,10 +8,43 @@ import "google/protobuf/duration.proto"; import "examples/sub/message.proto"; import "examples/sub2/message.proto"; import "google/protobuf/timestamp.proto"; +import "protoc-gen-swagger/options/annotations.proto"; + +option (grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger) = { + info: { + title: "A Bit of Everything"; + version: "1.0"; + contact: { + name: "gRPC-Gateway project"; + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + email: "none@example.com"; + }; + }; + // Overwriting host entry breaks tests, so this is not done here. + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "More about gRPC-Gateway"; + } + schemes: HTTP; + schemes: HTTPS; + schemes: WSS; + consumes: "application/json"; + consumes: "application/x-foo-mime"; + produces: "application/json"; + produces: "application/x-foo-mime"; +}; + // Intentionaly complicated message type to cover much features of Protobuf. // NEXT ID: 27 message ABitOfEverything { + option (grpc_gateway.protoc_gen_swagger.options.openapiv2_schema) = { + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about ABitOfEverything"; + } + }; + // Nested is nested type. message Nested { // name is nested field. @@ -72,7 +105,18 @@ enum NumericEnum { ONE = 1; } +// ABitOfEverything service is used to validate that APIs with complicated +// proto messages and URL templates are still processed correctly. service ABitOfEverythingService { + + option (grpc_gateway.protoc_gen_swagger.options.openapiv2_tag) = { + description: "ABitOfEverythingService description -- which should not be used in place of the documentation comment!" + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about EchoService"; + } + }; + rpc Create(ABitOfEverything) returns (ABitOfEverything) { // TODO add enum_value option (google.api.http) = { @@ -105,7 +149,21 @@ service ABitOfEverythingService { option (google.api.http) = { get: "/v1/example/a_bit_of_everything/query/{uuid}" }; + option (grpc_gateway.protoc_gen_swagger.options.openapiv2_operation) = { + deprecated: true // For testing purposes. + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more about GetQuery"; + } + }; } + // Echo allows posting a StringMessage value. + // + // It also exposes multiple bindings. + // + // This makes it useful when validating that the OpenAPI v2 API + // description exposes documentation correctly on all paths + // defined as additional_bindings in the proto. rpc Echo(grpc.gateway.examples.sub.StringMessage) returns (grpc.gateway.examples.sub.StringMessage) { option (google.api.http) = { get: "/v1/example/a_bit_of_everything/echo/{value}" @@ -117,6 +175,12 @@ service ABitOfEverythingService { get: "/v2/example/echo" } }; + option (grpc_gateway.protoc_gen_swagger.options.openapiv2_operation) = { + external_docs: { + url: "https://github.com/grpc-ecosystem/grpc-gateway"; + description: "Find out more Echo"; + } + }; } rpc DeepPathEcho(ABitOfEverything) returns (ABitOfEverything) { option (google.api.http) = { diff --git a/examples/examplepb/a_bit_of_everything.swagger.json b/examples/examplepb/a_bit_of_everything.swagger.json index 97d984a0bb1..c42cd34ed13 100644 --- a/examples/examplepb/a_bit_of_everything.swagger.json +++ b/examples/examplepb/a_bit_of_everything.swagger.json @@ -1,18 +1,26 @@ { "swagger": "2.0", "info": { - "title": "examples/examplepb/a_bit_of_everything.proto", - "version": "version not set" + "title": "A Bit of Everything", + "version": "1.0", + "contact": { + "name": "gRPC-Gateway project", + "url": "https://github.com/grpc-ecosystem/grpc-gateway", + "email": "none@example.com" + } }, "schemes": [ "http", - "https" + "https", + "wss" ], "consumes": [ - "application/json" + "application/json", + "application/x-foo-mime" ], "produces": [ - "application/json" + "application/json", + "application/x-foo-mime" ], "paths": { "/v1/example/a_bit_of_everything": { @@ -43,6 +51,8 @@ }, "/v1/example/a_bit_of_everything/echo/{value}": { "get": { + "summary": "Echo allows posting a StringMessage value.", + "description": "It also exposes multiple bindings.\n\nThis makes it useful when validating that the OpenAPI v2 API\ndescription exposes documentation correctly on all paths\ndefined as additional_bindings in the proto.", "operationId": "Echo", "responses": { "200": { @@ -62,7 +72,11 @@ ], "tags": [ "ABitOfEverythingService" - ] + ], + "externalDocs": { + "description": "Find out more Echo", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } } }, "/v1/example/a_bit_of_everything/query/{uuid}": { @@ -264,7 +278,12 @@ ], "tags": [ "ABitOfEverythingService" - ] + ], + "deprecated": true, + "externalDocs": { + "description": "Find out more about GetQuery", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } } }, "/v1/example/a_bit_of_everything/{float_value}/{double_value}/{int64_value}/separator/{uint64_value}/{int32_value}/{fixed64_value}/{fixed32_value}/{bool_value}/{string_value}/{uint32_value}/{sfixed32_value}/{sfixed64_value}/{sint32_value}/{sint64_value}/{nonConventionalNameValue}": { @@ -498,6 +517,8 @@ }, "/v2/example/echo": { "get": { + "summary": "Echo allows posting a StringMessage value.", + "description": "It also exposes multiple bindings.\n\nThis makes it useful when validating that the OpenAPI v2 API\ndescription exposes documentation correctly on all paths\ndefined as additional_bindings in the proto.", "operationId": "Echo3", "responses": { "200": { @@ -517,9 +538,15 @@ ], "tags": [ "ABitOfEverythingService" - ] + ], + "externalDocs": { + "description": "Find out more Echo", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } }, "post": { + "summary": "Echo allows posting a StringMessage value.", + "description": "It also exposes multiple bindings.\n\nThis makes it useful when validating that the OpenAPI v2 API\ndescription exposes documentation correctly on all paths\ndefined as additional_bindings in the proto.", "operationId": "Echo2", "responses": { "200": { @@ -541,7 +568,11 @@ ], "tags": [ "ABitOfEverythingService" - ] + ], + "externalDocs": { + "description": "Find out more Echo", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } } }, "/v2/example/timeout": { @@ -707,7 +738,11 @@ "title": "repeated enum value. it is comma-separated in query" } }, - "title": "Intentionaly complicated message type to cover much features of Protobuf.\nNEXT ID: 27" + "title": "Intentionaly complicated message type to cover much features of Protobuf.\nNEXT ID: 27", + "externalDocs": { + "description": "Find out more about ABitOfEverything", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" + } }, "examplepbNumericEnum": { "type": "string", @@ -731,5 +766,9 @@ } } } + }, + "externalDocs": { + "description": "More about gRPC-Gateway", + "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index b27e78e7167..f4b5f3b5caa 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -30,7 +30,6 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import _ "google.golang.org/genproto/googleapis/api/annotations" -import _ "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options" import ( context "golang.org/x/net/context" @@ -196,39 +195,22 @@ var _EchoService_serviceDesc = grpc.ServiceDesc{ func init() { proto.RegisterFile("examples/examplepb/echo_service.proto", fileDescriptor0) } var fileDescriptor0 = []byte{ - // 535 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x94, 0x4f, 0x6b, 0xd4, 0x4e, - 0x18, 0xc7, 0x49, 0x76, 0xf9, 0xf1, 0xeb, 0xf8, 0x87, 0x25, 0xf8, 0xa7, 0x44, 0xa5, 0xd3, 0x05, - 0xa1, 0x2c, 0x26, 0x63, 0x57, 0xf0, 0xb0, 0x27, 0xa9, 0xa8, 0x28, 0x14, 0x74, 0xf7, 0x60, 0xed, - 0xa5, 0x24, 0x93, 0xa7, 0xc9, 0x94, 0xcd, 0x3c, 0x43, 0x66, 0xd2, 0xed, 0x52, 0x7a, 0xe9, 0xb9, - 0xb7, 0x9e, 0x3c, 0x09, 0x82, 0x1e, 0x3c, 0x7a, 0xf4, 0x25, 0x78, 0x13, 0xc1, 0x57, 0xe0, 0x9b, - 0xf0, 0x26, 0x93, 0x4d, 0xeb, 0x96, 0xad, 0xc8, 0x82, 0x9e, 0xf2, 0x4c, 0xf2, 0x7d, 0x26, 0xcf, - 0xf7, 0x33, 0xdf, 0x84, 0xdc, 0x86, 0xbd, 0x28, 0x57, 0x43, 0xd0, 0xac, 0x2e, 0x54, 0xcc, 0x80, - 0x67, 0xb8, 0xa5, 0xa1, 0xd8, 0x15, 0x1c, 0x42, 0x55, 0xa0, 0x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, 0xce, 0x5e, 0xb0, 0x8d, 0x18, 0xe4, 0x22, 0x87, 0xde, 0x8c, - 0xb2, 0xf7, 0x1b, 0x65, 0xf1, 0x94, 0x5c, 0x5f, 0xff, 0xc5, 0x66, 0xda, 0xc2, 0xbc, 0xa3, 0x6f, - 0x2e, 0x9c, 0x06, 0x20, 0xfe, 0xaf, 0xfa, 0x15, 0xdc, 0xfb, 0x19, 0x00, 0x00, 0xff, 0xff, 0x36, - 0xc6, 0xd0, 0x6e, 0xa0, 0x04, 0x00, 0x00, + // 257 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0xad, 0x48, 0xcc, + 0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0x87, 0x32, 0x0a, 0x92, 0xf4, 0x53, 0x93, 0x33, 0xf2, 0xe3, 0x8b, + 0x53, 0x8b, 0xca, 0x32, 0x93, 0x53, 0xf5, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, 0x85, 0xe4, 0xd3, 0x8b, + 0x0a, 0x92, 0xf5, 0xd2, 0x13, 0x4b, 0x52, 0xcb, 0x13, 0x2b, 0xf5, 0x60, 0x7a, 0xf4, 0xe0, 0x7a, + 0xa4, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, 0x32, 0xf5, 0x13, 0xf3, 0xf2, + 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0x21, 0xda, 0x95, 0x0c, 0xb9, 0x78, 0x83, 0x33, + 0x41, 0x2a, 0x7d, 0x53, 0x8b, 0x8b, 0x13, 0xd3, 0x53, 0x85, 0xf8, 0xb8, 0x98, 0x32, 0x53, 0x24, + 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x98, 0x32, 0x53, 0x84, 0x04, 0xb8, 0x98, 0xf3, 0x4a, 0x73, + 0x25, 0x98, 0x14, 0x18, 0x35, 0x98, 0x83, 0x40, 0x4c, 0xa3, 0xc3, 0x4c, 0x5c, 0xdc, 0xae, 0xc9, + 0x19, 0xf9, 0xc1, 0x10, 0x77, 0x08, 0x2d, 0x61, 0xe4, 0x62, 0x01, 0xf1, 0x85, 0xf4, 0xf4, 0x08, + 0xb8, 0x45, 0x0f, 0xc5, 0x2a, 0x29, 0x12, 0xd5, 0x2b, 0xd9, 0x34, 0x5d, 0x7e, 0x32, 0x99, 0xc9, + 0x4c, 0x49, 0x54, 0xbf, 0xcc, 0x10, 0x16, 0x28, 0xe0, 0x20, 0xd1, 0xaf, 0xce, 0x4c, 0xa9, 0x8d, + 0x92, 0x15, 0x92, 0xc6, 0x2a, 0xa1, 0x5f, 0x9d, 0x57, 0x9a, 0x5b, 0x2b, 0xd4, 0xc3, 0xc8, 0xc5, + 0x01, 0x72, 0xa6, 0x53, 0x7e, 0x4a, 0x25, 0xcd, 0x9d, 0xaa, 0x00, 0x76, 0xaa, 0x14, 0xa6, 0x53, + 0xe3, 0x93, 0xf2, 0x53, 0x2a, 0xad, 0x18, 0xb5, 0x9c, 0xb8, 0xa3, 0x38, 0xe1, 0x9a, 0x93, 0xd8, + 0xc0, 0x91, 0x61, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xf8, 0x6e, 0x70, 0xce, 0xf4, 0x01, 0x00, + 0x00, } diff --git a/examples/examplepb/echo_service.proto b/examples/examplepb/echo_service.proto index 19d37ef70e2..0a7a6fa7f49 100644 --- a/examples/examplepb/echo_service.proto +++ b/examples/examplepb/echo_service.proto @@ -8,43 +8,12 @@ option go_package = "examplepb"; package grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; -import "protoc-gen-swagger/options/annotations.proto"; - -option (grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger) = { - info: { - title: "Echo Service"; - version: "1.0"; - contact: { - name: "gRPC-Gateway project"; - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - email: "none@example.com"; - }; - }; - //host: "localhost"; - external_docs: { - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - description: "More about gRPC-Gateway"; - } - schemes: HTTP; - schemes: HTTPS; - schemes: WSS; - consumes: "application/json"; - consumes: "application/x-foo-mime"; - produces: "application/json"; - produces: "application/x-foo-mime"; -}; // SimpleMessage represents a simple message sent to the Echo service. message SimpleMessage { // Id represents the message identifier. string id = 1; int64 num = 2; - option (grpc_gateway.protoc_gen_swagger.options.openapiv2_schema) = { - external_docs: { - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - description: "Find out more about EchoService"; - } - }; } // Echo service responds to incoming echo requests. @@ -60,13 +29,6 @@ service EchoService { get: "/v1/example/echo/{id}/{num}" } }; - option (grpc_gateway.protoc_gen_swagger.options.openapiv2_operation) = { - deprecated: true - external_docs: { - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - description: "Find out more about SimpleMessage"; - } - }; } // EchoBody method receives a simple message and returns it. rpc EchoBody(SimpleMessage) returns (SimpleMessage) { @@ -75,12 +37,4 @@ service EchoService { body: "*" }; } - - option (grpc_gateway.protoc_gen_swagger.options.openapiv2_tag) = { - description: "Echo service description which should not be used in place of the comment!" - external_docs: { - url: "https://github.com/grpc-ecosystem/grpc-gateway"; - description: "Find out more about EchoService"; - } - }; } diff --git a/examples/examplepb/echo_service.swagger.json b/examples/examplepb/echo_service.swagger.json index 146f59fb252..cf617932212 100644 --- a/examples/examplepb/echo_service.swagger.json +++ b/examples/examplepb/echo_service.swagger.json @@ -3,25 +3,17 @@ "info": { "title": "Echo Service", "description": "Echo Service API consists of a single service which returns\na message.", - "version": "1.0", - "contact": { - "name": "gRPC-Gateway project", - "url": "https://github.com/grpc-ecosystem/grpc-gateway", - "email": "none@example.com" - } + "version": "version not set" }, "schemes": [ "http", - "https", - "wss" + "https" ], "consumes": [ - "application/json", - "application/x-foo-mime" + "application/json" ], "produces": [ - "application/json", - "application/x-foo-mime" + "application/json" ], "paths": { "/v1/example/echo/{id}": { @@ -47,12 +39,7 @@ ], "tags": [ "EchoService" - ], - "deprecated": true, - "externalDocs": { - "description": "Find out more about SimpleMessage", - "url": "https://github.com/grpc-ecosystem/grpc-gateway" - } + ] } }, "/v1/example/echo/{id}/{num}": { @@ -85,12 +72,7 @@ ], "tags": [ "EchoService" - ], - "deprecated": true, - "externalDocs": { - "description": "Find out more about SimpleMessage", - "url": "https://github.com/grpc-ecosystem/grpc-gateway" - } + ] } }, "/v1/example/echo_body": { @@ -134,15 +116,7 @@ "format": "int64" } }, - "description": "SimpleMessage represents a simple message sent to the Echo service.", - "externalDocs": { - "description": "Find out more about EchoService", - "url": "https://github.com/grpc-ecosystem/grpc-gateway" - } + "description": "SimpleMessage represents a simple message sent to the Echo service." } - }, - "externalDocs": { - "description": "More about gRPC-Gateway", - "url": "https://github.com/grpc-ecosystem/grpc-gateway" } } diff --git a/examples/examplepb/stream.pb.go b/examples/examplepb/stream.pb.go index 0fbf67d0aa1..71066ccd964 100644 --- a/examples/examplepb/stream.pb.go +++ b/examples/examplepb/stream.pb.go @@ -7,7 +7,7 @@ import proto "github.com/golang/protobuf/proto" import fmt "fmt" import math "math" import _ "google.golang.org/genproto/googleapis/api/annotations" -import google_protobuf2 "github.com/golang/protobuf/ptypes/empty" +import google_protobuf1 "github.com/golang/protobuf/ptypes/empty" import grpc_gateway_examples_sub "github.com/grpc-ecosystem/grpc-gateway/examples/sub" import ( @@ -32,7 +32,7 @@ const _ = grpc.SupportPackageIsVersion4 type StreamServiceClient interface { BulkCreate(ctx context.Context, opts ...grpc.CallOption) (StreamService_BulkCreateClient, error) - List(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (StreamService_ListClient, error) + List(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (StreamService_ListClient, error) BulkEcho(ctx context.Context, opts ...grpc.CallOption) (StreamService_BulkEchoClient, error) } @@ -55,7 +55,7 @@ func (c *streamServiceClient) BulkCreate(ctx context.Context, opts ...grpc.CallO type StreamService_BulkCreateClient interface { Send(*ABitOfEverything) error - CloseAndRecv() (*google_protobuf2.Empty, error) + CloseAndRecv() (*google_protobuf1.Empty, error) grpc.ClientStream } @@ -67,18 +67,18 @@ func (x *streamServiceBulkCreateClient) Send(m *ABitOfEverything) error { return x.ClientStream.SendMsg(m) } -func (x *streamServiceBulkCreateClient) CloseAndRecv() (*google_protobuf2.Empty, error) { +func (x *streamServiceBulkCreateClient) CloseAndRecv() (*google_protobuf1.Empty, error) { if err := x.ClientStream.CloseSend(); err != nil { return nil, err } - m := new(google_protobuf2.Empty) + m := new(google_protobuf1.Empty) if err := x.ClientStream.RecvMsg(m); err != nil { return nil, err } return m, nil } -func (c *streamServiceClient) List(ctx context.Context, in *google_protobuf2.Empty, opts ...grpc.CallOption) (StreamService_ListClient, error) { +func (c *streamServiceClient) List(ctx context.Context, in *google_protobuf1.Empty, opts ...grpc.CallOption) (StreamService_ListClient, error) { stream, err := grpc.NewClientStream(ctx, &_StreamService_serviceDesc.Streams[1], c.cc, "/grpc.gateway.examples.examplepb.StreamService/List", opts...) if err != nil { return nil, err @@ -145,7 +145,7 @@ func (x *streamServiceBulkEchoClient) Recv() (*grpc_gateway_examples_sub.StringM type StreamServiceServer interface { BulkCreate(StreamService_BulkCreateServer) error - List(*google_protobuf2.Empty, StreamService_ListServer) error + List(*google_protobuf1.Empty, StreamService_ListServer) error BulkEcho(StreamService_BulkEchoServer) error } @@ -158,7 +158,7 @@ func _StreamService_BulkCreate_Handler(srv interface{}, stream grpc.ServerStream } type StreamService_BulkCreateServer interface { - SendAndClose(*google_protobuf2.Empty) error + SendAndClose(*google_protobuf1.Empty) error Recv() (*ABitOfEverything, error) grpc.ServerStream } @@ -167,7 +167,7 @@ type streamServiceBulkCreateServer struct { grpc.ServerStream } -func (x *streamServiceBulkCreateServer) SendAndClose(m *google_protobuf2.Empty) error { +func (x *streamServiceBulkCreateServer) SendAndClose(m *google_protobuf1.Empty) error { return x.ServerStream.SendMsg(m) } @@ -180,7 +180,7 @@ func (x *streamServiceBulkCreateServer) Recv() (*ABitOfEverything, error) { } func _StreamService_List_Handler(srv interface{}, stream grpc.ServerStream) error { - m := new(google_protobuf2.Empty) + m := new(google_protobuf1.Empty) if err := stream.RecvMsg(m); err != nil { return err } From d7b0ba46e4f5d74474bc9626ceca766b4cdb25b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Thu, 2 Nov 2017 10:32:56 +0000 Subject: [PATCH 23/26] Undo commenting out dependency on EXAMPLE_CLIENT_SRCS. I do not have swagger-codegen installed, so that was broken for me while developing. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 516aef076e1..c6a645e0ef7 100644 --- a/Makefile +++ b/Makefile @@ -126,7 +126,7 @@ $(ABE_EXAMPLE_SRCS): $(ABE_EXAMPLE_SPEC) $(EXAMPLE_CLIENT_DIR)/abe/git_push.sh \ $(EXAMPLE_CLIENT_DIR)/abe/.travis.yml -examples: $(EXAMPLE_SVCSRCS) $(EXAMPLE_GWSRCS) $(EXAMPLE_DEPSRCS) $(EXAMPLE_SWAGGERSRCS) #$(EXAMPLE_CLIENT_SRCS) +examples: $(EXAMPLE_SVCSRCS) $(EXAMPLE_GWSRCS) $(EXAMPLE_DEPSRCS) $(EXAMPLE_SWAGGERSRCS) $(EXAMPLE_CLIENT_SRCS) test: examples go test -race $(PKG)/... From d7a9a692867d1dc028ea0ea3574c3ce3c01010e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Thu, 2 Nov 2017 11:06:53 +0000 Subject: [PATCH 24/26] Change the proto package to start with 'grpc.gateway', as seems to be the approach elsewhere. --- examples/examplepb/a_bit_of_everything.proto | 10 +- protoc-gen-swagger/options/annotations.pb.go | 36 ++-- protoc-gen-swagger/options/annotations.proto | 2 +- protoc-gen-swagger/options/openapiv2.pb.go | 166 +++++++++---------- protoc-gen-swagger/options/openapiv2.proto | 2 +- 5 files changed, 108 insertions(+), 108 deletions(-) diff --git a/examples/examplepb/a_bit_of_everything.proto b/examples/examplepb/a_bit_of_everything.proto index a129d624932..6250bdd4381 100644 --- a/examples/examplepb/a_bit_of_everything.proto +++ b/examples/examplepb/a_bit_of_everything.proto @@ -10,7 +10,7 @@ import "examples/sub2/message.proto"; import "google/protobuf/timestamp.proto"; import "protoc-gen-swagger/options/annotations.proto"; -option (grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger) = { +option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = { info: { title: "A Bit of Everything"; version: "1.0"; @@ -38,7 +38,7 @@ option (grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger) = { // Intentionaly complicated message type to cover much features of Protobuf. // NEXT ID: 27 message ABitOfEverything { - option (grpc_gateway.protoc_gen_swagger.options.openapiv2_schema) = { + option (grpc.gateway.protoc_gen_swagger.options.openapiv2_schema) = { external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway"; description: "Find out more about ABitOfEverything"; @@ -109,7 +109,7 @@ enum NumericEnum { // proto messages and URL templates are still processed correctly. service ABitOfEverythingService { - option (grpc_gateway.protoc_gen_swagger.options.openapiv2_tag) = { + option (grpc.gateway.protoc_gen_swagger.options.openapiv2_tag) = { description: "ABitOfEverythingService description -- which should not be used in place of the documentation comment!" external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway"; @@ -149,7 +149,7 @@ service ABitOfEverythingService { option (google.api.http) = { get: "/v1/example/a_bit_of_everything/query/{uuid}" }; - option (grpc_gateway.protoc_gen_swagger.options.openapiv2_operation) = { + option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = { deprecated: true // For testing purposes. external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway"; @@ -175,7 +175,7 @@ service ABitOfEverythingService { get: "/v2/example/echo" } }; - option (grpc_gateway.protoc_gen_swagger.options.openapiv2_operation) = { + option (grpc.gateway.protoc_gen_swagger.options.openapiv2_operation) = { external_docs: { url: "https://github.com/grpc-ecosystem/grpc-gateway"; description: "Find out more Echo"; diff --git a/protoc-gen-swagger/options/annotations.pb.go b/protoc-gen-swagger/options/annotations.pb.go index d2444311f1f..7bc93b91c63 100644 --- a/protoc-gen-swagger/options/annotations.pb.go +++ b/protoc-gen-swagger/options/annotations.pb.go @@ -17,7 +17,7 @@ var E_Openapiv2Swagger = &proto.ExtensionDesc{ ExtendedType: (*google_protobuf1.FileOptions)(nil), ExtensionType: (*Swagger)(nil), Field: 1042, - Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_swagger", + Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger", Tag: "bytes,1042,opt,name=openapiv2_swagger,json=openapiv2Swagger", Filename: "protoc-gen-swagger/options/annotations.proto", } @@ -26,7 +26,7 @@ var E_Openapiv2Operation = &proto.ExtensionDesc{ ExtendedType: (*google_protobuf1.MethodOptions)(nil), ExtensionType: (*Operation)(nil), Field: 1042, - Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_operation", + Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_operation", Tag: "bytes,1042,opt,name=openapiv2_operation,json=openapiv2Operation", Filename: "protoc-gen-swagger/options/annotations.proto", } @@ -35,7 +35,7 @@ var E_Openapiv2Schema = &proto.ExtensionDesc{ ExtendedType: (*google_protobuf1.MessageOptions)(nil), ExtensionType: (*Schema)(nil), Field: 1042, - Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_schema", + Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_schema", Tag: "bytes,1042,opt,name=openapiv2_schema,json=openapiv2Schema", Filename: "protoc-gen-swagger/options/annotations.proto", } @@ -44,7 +44,7 @@ var E_Openapiv2Tag = &proto.ExtensionDesc{ ExtendedType: (*google_protobuf1.ServiceOptions)(nil), ExtensionType: (*Tag)(nil), Field: 1042, - Name: "grpc_gateway.protoc_gen_swagger.options.openapiv2_tag", + Name: "grpc.gateway.protoc_gen_swagger.options.openapiv2_tag", Tag: "bytes,1042,opt,name=openapiv2_tag,json=openapiv2Tag", Filename: "protoc-gen-swagger/options/annotations.proto", } @@ -66,18 +66,18 @@ var fileDescriptor1 = []byte{ 0x49, 0xda, 0x52, 0xe8, 0xd1, 0x5f, 0xe0, 0x2f, 0x16, 0x93, 0xed, 0x56, 0xd6, 0x2a, 0x7b, 0xdb, 0x99, 0x9d, 0xf7, 0xbe, 0xc7, 0x23, 0x49, 0xc7, 0x58, 0xf2, 0x24, 0xbb, 0x08, 0xba, 0xeb, 0x56, 0x02, 0x11, 0x2c, 0x27, 0xe3, 0x15, 0x69, 0xc7, 0x85, 0xd6, 0xe4, 0x45, 0xf8, 0x66, 0xe1, 0x2c, - 0xbd, 0x41, 0x6b, 0xe4, 0x08, 0x85, 0x87, 0x95, 0x58, 0xc7, 0x9d, 0x1c, 0x21, 0xe8, 0x51, 0x21, - 0x65, 0x85, 0xb4, 0x75, 0xf7, 0x8f, 0x2d, 0x19, 0xd0, 0xc2, 0xa8, 0x65, 0x2f, 0x1a, 0xb4, 0xda, - 0x48, 0x84, 0x33, 0xe0, 0x61, 0x1a, 0x2f, 0xde, 0xf9, 0x04, 0x9c, 0xb4, 0xca, 0x78, 0xb2, 0xf1, - 0x22, 0xdb, 0x24, 0x67, 0xa5, 0x68, 0x8b, 0x4a, 0x2f, 0x59, 0xd4, 0xb1, 0xad, 0x8e, 0xbd, 0xa8, - 0x19, 0xf4, 0x23, 0xe4, 0xe2, 0xf3, 0xb0, 0xdd, 0xb8, 0x3d, 0xea, 0xdd, 0xb3, 0x9a, 0x89, 0xd9, - 0x20, 0xce, 0x79, 0xb3, 0x24, 0x15, 0x9b, 0xec, 0xa3, 0x91, 0x9c, 0xef, 0xf0, 0x64, 0xc0, 0x86, - 0x4e, 0xd2, 0xab, 0x5f, 0x01, 0x5e, 0xc1, 0x4f, 0x69, 0x52, 0x89, 0xd0, 0xab, 0x1d, 0xa1, 0xbf, - 0xb5, 0xce, 0xd3, 0x92, 0x57, 0xee, 0xb2, 0x4d, 0xd2, 0xfc, 0x51, 0x82, 0x9c, 0xc2, 0x5c, 0xa4, - 0xd7, 0x7b, 0x22, 0x38, 0x27, 0xb0, 0x5a, 0x03, 0xaf, 0x5f, 0x43, 0x30, 0xce, 0x4f, 0x77, 0x2d, - 0x84, 0x45, 0xe6, 0x92, 0x93, 0x1d, 0xdd, 0x0b, 0xdc, 0x83, 0x1e, 0x80, 0x5d, 0x2a, 0x59, 0x45, - 0x77, 0x6a, 0xa3, 0x87, 0x02, 0xf3, 0xe3, 0x12, 0x32, 0x14, 0xf8, 0xf4, 0xfc, 0xf6, 0x88, 0xca, - 0x4f, 0x17, 0x63, 0x26, 0x69, 0xce, 0xbf, 0x7d, 0xba, 0x20, 0xc9, 0xad, 0x9d, 0x87, 0x62, 0x2c, - 0x6c, 0xf9, 0xdf, 0xcf, 0x6d, 0x7c, 0x10, 0xfe, 0x3d, 0x7c, 0x05, 0x00, 0x00, 0xff, 0xff, 0x83, - 0x43, 0x41, 0xa3, 0xea, 0x02, 0x00, 0x00, + 0xbd, 0x41, 0x6b, 0x24, 0x43, 0xe1, 0x61, 0x25, 0xd6, 0x71, 0x27, 0x47, 0x08, 0x7a, 0x54, 0x48, + 0x59, 0x21, 0x6d, 0xdd, 0xfd, 0x63, 0x4b, 0x06, 0xb4, 0x30, 0x6a, 0xd9, 0x8b, 0x06, 0xad, 0x36, + 0x12, 0xe1, 0x0c, 0x78, 0x98, 0xc6, 0x8b, 0x77, 0x3e, 0x01, 0x27, 0xad, 0x32, 0x9e, 0x6c, 0xbc, + 0xc8, 0x36, 0xc9, 0x59, 0x29, 0xda, 0xa2, 0xd2, 0x4b, 0x16, 0x75, 0x6c, 0xab, 0x63, 0x2f, 0x6a, + 0x06, 0xfd, 0x08, 0xb9, 0xf8, 0x3c, 0x6c, 0x37, 0x6e, 0x8f, 0x7a, 0xf7, 0xac, 0x66, 0x62, 0x36, + 0x88, 0x73, 0xde, 0x2c, 0x49, 0xc5, 0x26, 0xfb, 0x68, 0x24, 0xe7, 0x3b, 0x3c, 0x19, 0xb0, 0xa1, + 0x93, 0xf4, 0xea, 0x57, 0x80, 0x57, 0xf0, 0x53, 0x9a, 0x54, 0x22, 0xf4, 0x6a, 0x47, 0xe8, 0x6f, + 0xad, 0xf3, 0xb4, 0xe4, 0x95, 0xbb, 0x6c, 0x93, 0x34, 0x7f, 0x94, 0x20, 0xa7, 0x30, 0x17, 0xe9, + 0xf5, 0x9e, 0x08, 0xce, 0x09, 0xac, 0xd6, 0xc0, 0xeb, 0xd7, 0x10, 0x8c, 0xf3, 0xd3, 0x5d, 0x0b, + 0x61, 0x91, 0xb9, 0xe4, 0x64, 0x47, 0xf7, 0x02, 0xf7, 0xa0, 0x07, 0x60, 0x97, 0x4a, 0x56, 0xd1, + 0x9d, 0xda, 0xe8, 0xa1, 0xc0, 0xfc, 0xb8, 0x84, 0x0c, 0x05, 0x3e, 0x3d, 0xbf, 0x3d, 0xa2, 0xf2, + 0xd3, 0xc5, 0x98, 0x49, 0x9a, 0xf3, 0x6f, 0x9f, 0x2e, 0x48, 0x72, 0x6b, 0xe7, 0xa1, 0x18, 0x0b, + 0x5b, 0xfe, 0xf7, 0x73, 0x1b, 0x1f, 0x84, 0x7f, 0x0f, 0x5f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x80, + 0x7f, 0xc1, 0x6a, 0xea, 0x02, 0x00, 0x00, } diff --git a/protoc-gen-swagger/options/annotations.proto b/protoc-gen-swagger/options/annotations.proto index d71a275e924..877470d6c8c 100644 --- a/protoc-gen-swagger/options/annotations.proto +++ b/protoc-gen-swagger/options/annotations.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package grpc_gateway.protoc_gen_swagger.options; +package grpc.gateway.protoc_gen_swagger.options; option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"; diff --git a/protoc-gen-swagger/options/openapiv2.pb.go b/protoc-gen-swagger/options/openapiv2.pb.go index e89b1f8000d..7564c52e500 100644 --- a/protoc-gen-swagger/options/openapiv2.pb.go +++ b/protoc-gen-swagger/options/openapiv2.pb.go @@ -117,7 +117,7 @@ type Swagger struct { Info *Info `protobuf:"bytes,2,opt,name=info" json:"info,omitempty"` Host string `protobuf:"bytes,3,opt,name=host" json:"host,omitempty"` BasePath string `protobuf:"bytes,4,opt,name=base_path,json=basePath" json:"base_path,omitempty"` - Schemes []Swagger_SwaggerScheme `protobuf:"varint,5,rep,packed,name=schemes,enum=grpc_gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme" json:"schemes,omitempty"` + Schemes []Swagger_SwaggerScheme `protobuf:"varint,5,rep,packed,name=schemes,enum=grpc.gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme" json:"schemes,omitempty"` Consumes []string `protobuf:"bytes,6,rep,name=consumes" json:"consumes,omitempty"` Produces []string `protobuf:"bytes,7,rep,name=produces" json:"produces,omitempty"` ExternalDocs *ExternalDocumentation `protobuf:"bytes,14,opt,name=external_docs,json=externalDocs" json:"external_docs,omitempty"` @@ -473,7 +473,7 @@ type JSONSchema struct { Required []string `protobuf:"bytes,26,rep,name=required" json:"required,omitempty"` // Items in 'array' must be unique. Array []string `protobuf:"bytes,34,rep,name=array" json:"array,omitempty"` - Type []JSONSchema_JSONSchemaSimpleTypes `protobuf:"varint,35,rep,packed,name=type,enum=grpc_gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes" json:"type,omitempty"` + Type []JSONSchema_JSONSchemaSimpleTypes `protobuf:"varint,35,rep,packed,name=type,enum=grpc.gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes" json:"type,omitempty"` } func (m *JSONSchema) Reset() { *m = JSONSchema{} } @@ -646,16 +646,16 @@ func (m *Tag) GetExternalDocs() *ExternalDocumentation { } func init() { - proto.RegisterType((*Swagger)(nil), "grpc_gateway.protoc_gen_swagger.options.Swagger") - proto.RegisterType((*Operation)(nil), "grpc_gateway.protoc_gen_swagger.options.Operation") - proto.RegisterType((*Info)(nil), "grpc_gateway.protoc_gen_swagger.options.Info") - proto.RegisterType((*Contact)(nil), "grpc_gateway.protoc_gen_swagger.options.Contact") - proto.RegisterType((*ExternalDocumentation)(nil), "grpc_gateway.protoc_gen_swagger.options.ExternalDocumentation") - proto.RegisterType((*Schema)(nil), "grpc_gateway.protoc_gen_swagger.options.Schema") - proto.RegisterType((*JSONSchema)(nil), "grpc_gateway.protoc_gen_swagger.options.JSONSchema") - proto.RegisterType((*Tag)(nil), "grpc_gateway.protoc_gen_swagger.options.Tag") - proto.RegisterEnum("grpc_gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme", Swagger_SwaggerScheme_name, Swagger_SwaggerScheme_value) - proto.RegisterEnum("grpc_gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes", JSONSchema_JSONSchemaSimpleTypes_name, JSONSchema_JSONSchemaSimpleTypes_value) + proto.RegisterType((*Swagger)(nil), "grpc.gateway.protoc_gen_swagger.options.Swagger") + proto.RegisterType((*Operation)(nil), "grpc.gateway.protoc_gen_swagger.options.Operation") + proto.RegisterType((*Info)(nil), "grpc.gateway.protoc_gen_swagger.options.Info") + proto.RegisterType((*Contact)(nil), "grpc.gateway.protoc_gen_swagger.options.Contact") + proto.RegisterType((*ExternalDocumentation)(nil), "grpc.gateway.protoc_gen_swagger.options.ExternalDocumentation") + proto.RegisterType((*Schema)(nil), "grpc.gateway.protoc_gen_swagger.options.Schema") + proto.RegisterType((*JSONSchema)(nil), "grpc.gateway.protoc_gen_swagger.options.JSONSchema") + proto.RegisterType((*Tag)(nil), "grpc.gateway.protoc_gen_swagger.options.Tag") + proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.Swagger_SwaggerScheme", Swagger_SwaggerScheme_name, Swagger_SwaggerScheme_value) + proto.RegisterEnum("grpc.gateway.protoc_gen_swagger.options.JSONSchema_JSONSchemaSimpleTypes", JSONSchema_JSONSchemaSimpleTypes_name, JSONSchema_JSONSchemaSimpleTypes_value) } func init() { proto.RegisterFile("protoc-gen-swagger/options/openapiv2.proto", fileDescriptor0) } @@ -663,77 +663,77 @@ func init() { proto.RegisterFile("protoc-gen-swagger/options/openapiv2.proto", f var fileDescriptor0 = []byte{ // 1175 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xed, 0x6e, 0xdb, 0x36, - 0x17, 0x7e, 0x65, 0xd3, 0x16, 0x7d, 0x6c, 0xe7, 0x65, 0xd5, 0x74, 0x53, 0xd3, 0x8f, 0xb9, 0x5e, + 0x17, 0x7e, 0x65, 0xd3, 0x36, 0x7d, 0x6c, 0xe7, 0x65, 0xd5, 0x74, 0x63, 0xd3, 0x8f, 0xb9, 0x5e, 0x87, 0x19, 0x2d, 0xe2, 0x0c, 0xe9, 0xff, 0x01, 0x49, 0x67, 0x74, 0x51, 0x53, 0xbb, 0x90, 0x5d, - 0x74, 0x1b, 0x30, 0x08, 0x8c, 0x4c, 0x3b, 0x1c, 0x24, 0x4a, 0x95, 0xa8, 0xd4, 0xbe, 0x8d, 0x5d, + 0x74, 0x1b, 0x30, 0x18, 0x8c, 0x4c, 0x3b, 0x1c, 0x24, 0x4a, 0x95, 0xa8, 0xd4, 0xbe, 0x8d, 0x5d, 0xcf, 0x2e, 0x63, 0xf7, 0xb0, 0x3b, 0xd8, 0x8f, 0xfd, 0x1a, 0x48, 0x51, 0xf9, 0x72, 0x37, 0x04, - 0x45, 0xf7, 0xcb, 0x3c, 0xcf, 0x73, 0xce, 0x23, 0x9e, 0x0f, 0x92, 0x86, 0x27, 0x69, 0x96, 0xc8, - 0x24, 0xdc, 0x5d, 0x32, 0xb1, 0x9b, 0xbf, 0xa7, 0xcb, 0x25, 0xcb, 0xf6, 0x92, 0x54, 0xf2, 0x44, - 0xe4, 0x7b, 0x49, 0xca, 0x04, 0x4d, 0xf9, 0xd9, 0xfe, 0x50, 0x3b, 0x39, 0x5f, 0x2f, 0xb3, 0x34, - 0x0c, 0x96, 0x54, 0x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, 0x38, 0x1a, 0x43, 0xb0, 0xd9, 0x8a, 0xc6, - 0x69, 0xc4, 0x74, 0xf3, 0xda, 0xfb, 0xdb, 0xc3, 0xf2, 0x0d, 0x18, 0x56, 0x6f, 0xc0, 0xf0, 0x40, - 0xac, 0xfd, 0xca, 0xc9, 0x43, 0x18, 0x91, 0x46, 0xff, 0xaf, 0x26, 0xc0, 0x45, 0xe2, 0x17, 0xf3, - 0xda, 0xf8, 0x97, 0x79, 0x6d, 0x6e, 0xf6, 0xc5, 0x05, 0x7b, 0xce, 0x16, 0xb4, 0x88, 0xa4, 0x6b, - 0x97, 0x93, 0x63, 0x4c, 0xe7, 0x0b, 0x68, 0xc7, 0x45, 0x24, 0x79, 0x1a, 0xb1, 0x20, 0x59, 0xb8, - 0xd0, 0xb3, 0x06, 0x96, 0x0f, 0x15, 0x34, 0x59, 0xa8, 0xd0, 0x98, 0xae, 0x78, 0x5c, 0xc4, 0xfa, - 0x68, 0x59, 0x7e, 0x65, 0x3a, 0x4f, 0xe1, 0x16, 0x5b, 0x85, 0x51, 0x91, 0xf3, 0x33, 0x16, 0x54, - 0x3e, 0x1d, 0x5d, 0x5b, 0x72, 0x4e, 0xbc, 0x32, 0xce, 0x4a, 0x86, 0x0b, 0xed, 0xd2, 0x35, 0x32, - 0xa5, 0x79, 0x4d, 0xc6, 0xf8, 0x6c, 0x5d, 0x97, 0x31, 0xce, 0x0f, 0x00, 0x62, 0xba, 0x0a, 0x22, - 0x26, 0x96, 0xf2, 0xd4, 0xfd, 0x7f, 0xcf, 0x1a, 0x20, 0xbf, 0x15, 0xd3, 0xd5, 0xb1, 0x06, 0x34, - 0xcd, 0x45, 0x45, 0x13, 0x43, 0x73, 0x61, 0x68, 0x17, 0xec, 0x94, 0x4a, 0xd5, 0x14, 0xf7, 0x56, - 0x59, 0x06, 0x63, 0xaa, 0xf9, 0x50, 0xba, 0x5c, 0xb2, 0x38, 0x77, 0xb7, 0x75, 0x1c, 0x8e, 0xe9, - 0xea, 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 0x93, 0xa9, 0x7f, + 0x34, 0x7a, 0x41, 0x1a, 0x1e, 0xc2, 0x0e, 0xa9, 0x78, 0x08, 0x57, 0x48, 0xd5, 0x43, 0xb8, 0x6a, + 0x9e, 0x59, 0x44, 0x6a, 0xd7, 0x2e, 0x7c, 0x97, 0xdc, 0xf6, 0x10, 0xbe, 0x4d, 0xb6, 0x3d, 0x84, + 0x3f, 0x27, 0xd4, 0x43, 0xf8, 0x1e, 0xb9, 0xef, 0x21, 0x7c, 0x9f, 0x3c, 0xf0, 0x10, 0x7e, 0x40, + 0x1e, 0x7a, 0x08, 0x3f, 0x24, 0x3d, 0x0f, 0xe1, 0xc7, 0xe4, 0x89, 0x87, 0xf0, 0x13, 0xf2, 0xd4, + 0x43, 0xf8, 0x29, 0x19, 0xf4, 0x7e, 0x75, 0xa0, 0x3a, 0x65, 0xcb, 0x1b, 0xbc, 0x07, 0x1b, 0x37, + 0x48, 0xf5, 0xd3, 0xdf, 0x20, 0x45, 0xba, 0x87, 0xcf, 0x7f, 0x3a, 0x58, 0x0a, 0x75, 0x9a, 0x9f, + 0x0c, 0x82, 0x38, 0xda, 0xd3, 0xfa, 0xbb, 0x3c, 0x88, 0xb3, 0x75, 0xa6, 0xb8, 0x35, 0xed, 0xe7, + 0xf6, 0xfe, 0xf9, 0x7f, 0xeb, 0x49, 0xdd, 0x70, 0xcf, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0xf8, + 0x2b, 0xe7, 0x47, 0xdc, 0x0a, 0x00, 0x00, } diff --git a/protoc-gen-swagger/options/openapiv2.proto b/protoc-gen-swagger/options/openapiv2.proto index 6051b960db5..6c1854613dd 100644 --- a/protoc-gen-swagger/options/openapiv2.proto +++ b/protoc-gen-swagger/options/openapiv2.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -package grpc_gateway.protoc_gen_swagger.options; +package grpc.gateway.protoc_gen_swagger.options; option go_package = "github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger/options"; From 84c30462afc465cb974b586ec076b0ee044cbc58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Thu, 2 Nov 2017 11:11:45 +0000 Subject: [PATCH 25/26] Add a comment about all IDs being ok to be the same. --- protoc-gen-swagger/options/annotations.proto | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/protoc-gen-swagger/options/annotations.proto b/protoc-gen-swagger/options/annotations.proto index 877470d6c8c..8746192b7a8 100644 --- a/protoc-gen-swagger/options/annotations.proto +++ b/protoc-gen-swagger/options/annotations.proto @@ -9,17 +9,29 @@ import "google/protobuf/descriptor.proto"; extend google.protobuf.FileOptions { // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. Swagger openapiv2_swagger = 1042; } extend google.protobuf.MethodOptions { // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. Operation openapiv2_operation = 1042; } extend google.protobuf.MessageOptions { // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. Schema openapiv2_schema = 1042; } extend google.protobuf.ServiceOptions { // ID assigned by protobuf-global-extension-registry@google.com for grpc-gateway project. + // + // All IDs are the same, as assigned. It is okay that they are the same, as they extend + // different descriptor messages. Tag openapiv2_tag = 1042; } From a543b9ea624108fa6b4441dbbe57a2018ddcc143 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Vu=C4=8Dica?= Date: Thu, 2 Nov 2017 11:13:11 +0000 Subject: [PATCH 26/26] Regenerated Swagger-generated clients. --- .../clients/abe/a_bit_of_everything_nested.go | 6 +- .../abe/a_bit_of_everything_service_api.go | 70 +++++++++++-------- examples/clients/abe/api_client.go | 6 +- examples/clients/abe/api_response.go | 6 +- examples/clients/abe/configuration.go | 6 +- .../abe/examplepb_a_bit_of_everything.go | 6 +- .../clients/abe/examplepb_numeric_enum.go | 6 +- examples/clients/abe/nested_deep_enum.go | 6 +- examples/clients/abe/protobuf_empty.go | 6 +- examples/clients/abe/sub_string_message.go | 6 +- examples/clients/echo/echo_service_api.go | 36 +++++----- 11 files changed, 87 insertions(+), 73 deletions(-) diff --git a/examples/clients/abe/a_bit_of_everything_nested.go b/examples/clients/abe/a_bit_of_everything_nested.go index 909f478b7dc..095e8c5f118 100644 --- a/examples/clients/abe/a_bit_of_everything_nested.go +++ b/examples/clients/abe/a_bit_of_everything_nested.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/a_bit_of_everything_service_api.go b/examples/clients/abe/a_bit_of_everything_service_api.go index 669a12aed76..d66b34f54b2 100644 --- a/examples/clients/abe/a_bit_of_everything_service_api.go +++ b/examples/clients/abe/a_bit_of_everything_service_api.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ @@ -91,7 +91,7 @@ func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -101,6 +101,7 @@ func (a ABitOfEverythingServiceApi) Create(floatValue float32, doubleValue float // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -150,7 +151,7 @@ func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) ( } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -160,6 +161,7 @@ func (a ABitOfEverythingServiceApi) CreateBody(body ExamplepbABitOfEverything) ( // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -213,7 +215,7 @@ func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body E } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -223,6 +225,7 @@ func (a ABitOfEverythingServiceApi) DeepPathEcho(singleNestedName string, body E // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -275,7 +278,7 @@ func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIRes } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -285,6 +288,7 @@ func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIRes // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -311,7 +315,8 @@ func (a ABitOfEverythingServiceApi) Delete(uuid string) (*ProtobufEmpty, *APIRes } /** - * + * Echo allows posting a StringMessage value. + * It also exposes multiple bindings. This makes it useful when validating that the OpenAPI v2 API description exposes documentation correctly on all paths defined as additional_bindings in the proto. * * @param value * @return *SubStringMessage @@ -335,7 +340,7 @@ func (a ABitOfEverythingServiceApi) Echo(value string) (*SubStringMessage, *APIR } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -345,6 +350,7 @@ func (a ABitOfEverythingServiceApi) Echo(value string) (*SubStringMessage, *APIR // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -371,14 +377,15 @@ func (a ABitOfEverythingServiceApi) Echo(value string) (*SubStringMessage, *APIR } /** - * + * Echo allows posting a StringMessage value. + * It also exposes multiple bindings. This makes it useful when validating that the OpenAPI v2 API description exposes documentation correctly on all paths defined as additional_bindings in the proto. * - * @param value + * @param body * @return *SubStringMessage */ -func (a ABitOfEverythingServiceApi) Echo_1(value string) (*SubStringMessage, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Echo2(body string) (*SubStringMessage, *APIResponse, error) { - var localVarHttpMethod = strings.ToUpper("Get") + var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables localVarPath := a.Configuration.BasePath + "/v2/example/echo" @@ -392,10 +399,9 @@ func (a ABitOfEverythingServiceApi) Echo_1(value string) (*SubStringMessage, *AP for key := range a.Configuration.DefaultHeader { localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] } - localVarQueryParams.Add("value", a.Configuration.APIClient.ParameterToString(value, "")) // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -405,6 +411,7 @@ func (a ABitOfEverythingServiceApi) Echo_1(value string) (*SubStringMessage, *AP // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -412,12 +419,14 @@ func (a ABitOfEverythingServiceApi) Echo_1(value string) (*SubStringMessage, *AP if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } + // body params + localVarPostBody = &body var successPayload = new(SubStringMessage) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo_0", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + var localVarAPIResponse = &APIResponse{Operation: "Echo2", Method: localVarHttpMethod, RequestURL: localVarURL.String()} if localVarHttpResponse != nil { localVarAPIResponse.Response = localVarHttpResponse.RawResponse localVarAPIResponse.Payload = localVarHttpResponse.Body() @@ -431,14 +440,15 @@ func (a ABitOfEverythingServiceApi) Echo_1(value string) (*SubStringMessage, *AP } /** - * + * Echo allows posting a StringMessage value. + * It also exposes multiple bindings. This makes it useful when validating that the OpenAPI v2 API description exposes documentation correctly on all paths defined as additional_bindings in the proto. * - * @param body + * @param value * @return *SubStringMessage */ -func (a ABitOfEverythingServiceApi) Echo_2(body string) (*SubStringMessage, *APIResponse, error) { +func (a ABitOfEverythingServiceApi) Echo3(value string) (*SubStringMessage, *APIResponse, error) { - var localVarHttpMethod = strings.ToUpper("Post") + var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables localVarPath := a.Configuration.BasePath + "/v2/example/echo" @@ -452,9 +462,10 @@ func (a ABitOfEverythingServiceApi) Echo_2(body string) (*SubStringMessage, *API for key := range a.Configuration.DefaultHeader { localVarHeaderParams[key] = a.Configuration.DefaultHeader[key] } + localVarQueryParams.Add("value", a.Configuration.APIClient.ParameterToString(value, "")) // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -464,6 +475,7 @@ func (a ABitOfEverythingServiceApi) Echo_2(body string) (*SubStringMessage, *API // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -471,14 +483,12 @@ func (a ABitOfEverythingServiceApi) Echo_2(body string) (*SubStringMessage, *API if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - // body params - localVarPostBody = &body var successPayload = new(SubStringMessage) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo_1", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + var localVarAPIResponse = &APIResponse{Operation: "Echo3", Method: localVarHttpMethod, RequestURL: localVarURL.String()} if localVarHttpResponse != nil { localVarAPIResponse.Response = localVarHttpResponse.RawResponse localVarAPIResponse.Payload = localVarHttpResponse.Body() @@ -566,7 +576,7 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, singleNestedName strin // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -576,6 +586,7 @@ func (a ABitOfEverythingServiceApi) GetQuery(uuid string, singleNestedName strin // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -626,7 +637,7 @@ func (a ABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEveryth } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -636,6 +647,7 @@ func (a ABitOfEverythingServiceApi) Lookup(uuid string) (*ExamplepbABitOfEveryth // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -684,7 +696,7 @@ func (a ABitOfEverythingServiceApi) Timeout() (*ProtobufEmpty, *APIResponse, err } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -694,6 +706,7 @@ func (a ABitOfEverythingServiceApi) Timeout() (*ProtobufEmpty, *APIResponse, err // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header @@ -745,7 +758,7 @@ func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEver } // to determine the Content-Type header - localVarHttpContentTypes := []string{ "application/json", } + localVarHttpContentTypes := []string{ "application/json", "application/x-foo-mime", } // set Content-Type header localVarHttpContentType := a.Configuration.APIClient.SelectHeaderContentType(localVarHttpContentTypes) @@ -755,6 +768,7 @@ func (a ABitOfEverythingServiceApi) Update(uuid string, body ExamplepbABitOfEver // to determine the Accept header localVarHttpHeaderAccepts := []string{ "application/json", + "application/x-foo-mime", } // set Accept header diff --git a/examples/clients/abe/api_client.go b/examples/clients/abe/api_client.go index 2825dd48e13..bf3e21a9fb1 100644 --- a/examples/clients/abe/api_client.go +++ b/examples/clients/abe/api_client.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/api_response.go b/examples/clients/abe/api_response.go index 8c14424b574..ee1315f513c 100644 --- a/examples/clients/abe/api_response.go +++ b/examples/clients/abe/api_response.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/configuration.go b/examples/clients/abe/configuration.go index 5cacaadcb9d..ccc319c34aa 100644 --- a/examples/clients/abe/configuration.go +++ b/examples/clients/abe/configuration.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/examplepb_a_bit_of_everything.go b/examples/clients/abe/examplepb_a_bit_of_everything.go index 338ac379878..d8775d9c863 100644 --- a/examples/clients/abe/examplepb_a_bit_of_everything.go +++ b/examples/clients/abe/examplepb_a_bit_of_everything.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/examplepb_numeric_enum.go b/examples/clients/abe/examplepb_numeric_enum.go index bfb776292b3..e953bbe34e8 100644 --- a/examples/clients/abe/examplepb_numeric_enum.go +++ b/examples/clients/abe/examplepb_numeric_enum.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/nested_deep_enum.go b/examples/clients/abe/nested_deep_enum.go index 50bf6235a29..e5fc17d50a4 100644 --- a/examples/clients/abe/nested_deep_enum.go +++ b/examples/clients/abe/nested_deep_enum.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/protobuf_empty.go b/examples/clients/abe/protobuf_empty.go index 0cf664849d2..97c7bf612b8 100644 --- a/examples/clients/abe/protobuf_empty.go +++ b/examples/clients/abe/protobuf_empty.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/abe/sub_string_message.go b/examples/clients/abe/sub_string_message.go index 0331c7abb94..2a0874fc5fa 100644 --- a/examples/clients/abe/sub_string_message.go +++ b/examples/clients/abe/sub_string_message.go @@ -1,10 +1,10 @@ /* - * examples/examplepb/a_bit_of_everything.proto + * A Bit of Everything * * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) * - * OpenAPI spec version: version not set - * + * OpenAPI spec version: 1.0 + * Contact: none@example.com * Generated by: https://github.com/swagger-api/swagger-codegen.git */ diff --git a/examples/clients/echo/echo_service_api.go b/examples/clients/echo/echo_service_api.go index a37a837adb2..1f562327d3d 100644 --- a/examples/clients/echo/echo_service_api.go +++ b/examples/clients/echo/echo_service_api.go @@ -99,16 +99,20 @@ func (a EchoServiceApi) Echo(id string) (*ExamplepbSimpleMessage, *APIResponse, } /** - * EchoBody method receives a simple message and returns it. + * Echo method receives a simple message and returns it. + * The message posted as the id parameter will also be returned. * - * @param body + * @param id + * @param num * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) Echo2(id string, num string) (*ExamplepbSimpleMessage, *APIResponse, error) { - var localVarHttpMethod = strings.ToUpper("Post") + var localVarHttpMethod = strings.ToUpper("Get") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo_body" + localVarPath := a.Configuration.BasePath + "/v1/example/echo/{id}/{num}" + localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) + localVarPath = strings.Replace(localVarPath, "{"+"num"+"}", fmt.Sprintf("%v", num), -1) localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -139,14 +143,12 @@ func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleM if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } - // body params - localVarPostBody = &body var successPayload = new(ExamplepbSimpleMessage) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "EchoBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + var localVarAPIResponse = &APIResponse{Operation: "Echo2", Method: localVarHttpMethod, RequestURL: localVarURL.String()} if localVarHttpResponse != nil { localVarAPIResponse.Response = localVarHttpResponse.RawResponse localVarAPIResponse.Payload = localVarHttpResponse.Body() @@ -160,20 +162,16 @@ func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleM } /** - * Echo method receives a simple message and returns it. - * The message posted as the id parameter will also be returned. + * EchoBody method receives a simple message and returns it. * - * @param id - * @param num + * @param body * @return *ExamplepbSimpleMessage */ -func (a EchoServiceApi) Echo_1(id string, num string) (*ExamplepbSimpleMessage, *APIResponse, error) { +func (a EchoServiceApi) EchoBody(body ExamplepbSimpleMessage) (*ExamplepbSimpleMessage, *APIResponse, error) { - var localVarHttpMethod = strings.ToUpper("Get") + var localVarHttpMethod = strings.ToUpper("Post") // create path and map variables - localVarPath := a.Configuration.BasePath + "/v1/example/echo/{id}/{num}" - localVarPath = strings.Replace(localVarPath, "{"+"id"+"}", fmt.Sprintf("%v", id), -1) - localVarPath = strings.Replace(localVarPath, "{"+"num"+"}", fmt.Sprintf("%v", num), -1) + localVarPath := a.Configuration.BasePath + "/v1/example/echo_body" localVarHeaderParams := make(map[string]string) localVarQueryParams := url.Values{} @@ -204,12 +202,14 @@ func (a EchoServiceApi) Echo_1(id string, num string) (*ExamplepbSimpleMessage, if localVarHttpHeaderAccept != "" { localVarHeaderParams["Accept"] = localVarHttpHeaderAccept } + // body params + localVarPostBody = &body var successPayload = new(ExamplepbSimpleMessage) localVarHttpResponse, err := a.Configuration.APIClient.CallAPI(localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFileName, localVarFileBytes) var localVarURL, _ = url.Parse(localVarPath) localVarURL.RawQuery = localVarQueryParams.Encode() - var localVarAPIResponse = &APIResponse{Operation: "Echo_0", Method: localVarHttpMethod, RequestURL: localVarURL.String()} + var localVarAPIResponse = &APIResponse{Operation: "EchoBody", Method: localVarHttpMethod, RequestURL: localVarURL.String()} if localVarHttpResponse != nil { localVarAPIResponse.Response = localVarHttpResponse.RawResponse localVarAPIResponse.Payload = localVarHttpResponse.Body()