From e3b11c1a5a35ac03ea87f3b53f2fa1d7f7578190 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] 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 53cee5173b6..06cef88e7df 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -10,7 +10,7 @@ Echo Service Echo Service API consists of a single service which returns a message. -Swagger: { +OpenAPI: { "info": { "title": "Echo Service", "version": "1.0", @@ -67,7 +67,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" @@ -103,7 +103,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" @@ -148,7 +148,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 2a63dca63bb..56b8bdc56c4 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" @@ -46,7 +46,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 3174812a907..85bacf1f7af 100644 --- a/protoc-gen-swagger/genswagger/template.go +++ b/protoc-gen-swagger/genswagger/template.go @@ -509,7 +509,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 { @@ -539,8 +539,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]