Skip to content

Commit

Permalink
Merge pull request #109 from t-yuki/fix/swagger-multimethods
Browse files Browse the repository at this point in the history
fixes missing swagger operation objects
  • Loading branch information
yugui committed Feb 25, 2016
2 parents b94f713 + d414032 commit fd69e19
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 1 deletion.
81 changes: 81 additions & 0 deletions examples/examplepb/streamless_everything.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,31 @@
"tags": [
"ABitOfEverythingService"
]
},
"post": {
"summary": "ABitOfEverythingService.CreateBody",
"operationId": "CreateBody",
"responses": {
"default": {
"description": "Description",
"schema": {
"$ref": "#/definitions/examplepbABitOfEverything"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/examplepbABitOfEverything"
}
}
],
"tags": [
"ABitOfEverythingService"
]
}
},
"/v1/example/a_bit_of_everything/bulk": {
Expand Down Expand Up @@ -230,6 +255,30 @@
}
},
"/v1/example/a_bit_of_everything/{uuid}": {
"get": {
"summary": "ABitOfEverythingService.Lookup",
"operationId": "Lookup",
"responses": {
"default": {
"description": "Description",
"schema": {
"$ref": "#/definitions/examplepbABitOfEverything"
}
}
},
"parameters": [
{
"name": "uuid",
"in": "path",
"required": true,
"type": "string",
"format": "string"
}
],
"tags": [
"ABitOfEverythingService"
]
},
"delete": {
"summary": "ABitOfEverythingService.Delete",
"operationId": "Delete",
Expand All @@ -253,6 +302,38 @@
"tags": [
"ABitOfEverythingService"
]
},
"put": {
"summary": "ABitOfEverythingService.Update",
"operationId": "Update",
"responses": {
"default": {
"description": "Description",
"schema": {
"$ref": "#/definitions/examplepbEmptyMessage"
}
}
},
"parameters": [
{
"name": "uuid",
"in": "path",
"required": true,
"type": "string",
"format": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/examplepbABitOfEverything"
}
}
],
"tags": [
"ABitOfEverythingService"
]
}
}
},
Expand Down
5 changes: 4 additions & 1 deletion protoc-gen-swagger/genswagger/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,10 @@ func renderServices(services []*descriptor.Service, paths swaggerPathsObject, re
})
}

pathItemObject := swaggerPathItemObject{}
pathItemObject, ok := paths[templateToSwaggerPath(b.PathTmpl.Template)]
if !ok {
pathItemObject = swaggerPathItemObject{}
}
operationObject := &swaggerOperationObject{
Summary: fmt.Sprintf("%s.%s", svc.GetName(), meth.GetName()),
Tags: []string{svc.GetName()},
Expand Down

0 comments on commit fd69e19

Please sign in to comment.