Skip to content

Commit

Permalink
Change from 'Swagger: ' to 'OpenAPI: ' prefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
ivucica committed May 7, 2016
1 parent 01efa6a commit d0713ed
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions examples/examplepb/echo_service.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/examplepb/echo_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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/gengo/grpc-gateway",
// "description": "Find out more about EchoService"
Expand All @@ -46,7 +46,7 @@ service EchoService {
// 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"
Expand Down
6 changes: 3 additions & 3 deletions protoc-gen-swagger/genswagger/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,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 {
Expand Down Expand Up @@ -582,8 +582,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]
Expand Down

0 comments on commit d0713ed

Please sign in to comment.