Closed
Description
Hello,
I now have a problem that when the swagger document is generated, the required fields are invalid.
- test.proto:
syntax = "proto3";
package test;
import "protoc-gen-swagger/options/annotations.proto";
import "google/api/annotations.proto";
service TestService {
rpc GetProject(ProjectRequest) returns (ProjectResponse) {
option (google.api.http) = {
get : "/projects"
};
}
}
message ProjectRequest {
option (grpc.gateway.protoc_gen_swagger.options.openapiv2_schema) = {
json_schema: {
required: [ "project_id" ];
};
};
int64 project_id = 1;
}
message ProjectResponse {
}
- command
protoc -I=. -I=$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway \
-I=$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \
--grpc-gateway_out=logtostderr=true:. \
--go_out=plugins=grpc:. \
--swagger_out=logtostderr=true:. \
./test.proto
- test.swagger.json:
{
"swagger": "2.0",
"info": {
"title": "test.proto",
"version": "version not set"
},
"schemes": [
"http",
"https"
],
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"paths": {
"/projects": {
"get": {
"operationId": "GetProject",
"responses": {
"200": {
"description": "",
"schema": {
"$ref": "#/definitions/testProjectResponse"
}
}
},
"parameters": [
{
"name": "project_id",
"in": "query",
"required": false,
"type": "string",
"format": "int64"
}
],
"tags": [
"TestService"
]
}
}
},
"definitions": {
"testProjectResponse": {
"type": "object"
}
}
}
I hope parameters (project_id) is true, but got false...
Expected results, etc.
"parameters": [
{
"name": "project_id",
"in": "query",
"required": true,
"type": "string",
"format": "int64"
}
],
How can I solve this problem ?