Closed
Description
protoc-gen-swagger appears to have an issue where an entity is omitted from the definitions when a field is specified for the body rather than *
.
Reproduce with the following code:
example.proto
syntax = "proto3";
package example;
import "google/api/annotations.proto";
service ExampleService {
rpc DoSomething(DoSomethingRequest) returns (DoSomethingResponse) {
option (google.api.http) = {
post: "/do-something/{id}"
body: "data"
};
}
}
message ExtraData {
string foo = 1;
}
message DoSomethingRequest {
string id = 1;
ExtraData data = 2;
}
message DoSomethingResponse {
string bar = 1;
}
Generate the code:
protoc -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=plugins=grpc:. --swagger_out=logtostderr=true:. ./example.proto
Results in:
{
"swagger": "2.0",
"info": {
"title": "example.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/do-something/{id}": {
"post": {
"operationId": "DoSomething",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/exampleDoSomethingResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
},
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/exampleExtraData"
}
}
],
"tags": [
"ExampleService"
]
}
}
},
"definitions": {
"exampleDoSomethingResponse": {
"type": "object",
"properties": {
"bar": {
"type": "string"
}
}
}
}
}
Note that there is a $ref to #/definitions/exampleExtraData
but it does not appear in the definitions.
edit: actually I don't know if the body attribute is relevant.
Metadata
Metadata
Assignees
Labels
No labels