Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Swagger description using proto comments. #1552

Closed
neoduan opened this issue Jul 26, 2020 · 1 comment
Closed

Generate Swagger description using proto comments. #1552

neoduan opened this issue Jul 26, 2020 · 1 comment

Comments

@neoduan
Copy link

neoduan commented Jul 26, 2020

when using the comment req's param, but the generated swagger file has not description field?

here is proto file:

syntax = "proto3";
package demoprj;
import "google/api/annotations.proto";
import "protoc-gen-swagger/options/annotations.proto";

option (grpc.gateway.protoc_gen_swagger.options.openapiv2_swagger) = {
    host: "127.0.0.1:8301"
};

message Req {
    string param = 1; //req's param
}


message Rsp {}

// Demoprj
service Demoprj {

    // method's comment
    rpc Method (Req) returns (Rsp) {
        option (google.api.http) = {
            get: "/v1/method"
        };
    }
}

here is the generate swagger json file:

 "/v1/method": {
      "get": {
        "operationId": "Demoprj_Method",
        "parameters": [
          {
            "in": "query",
            "name": "param",
            "required": false,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/demoprjRsp"
            }
          },
          "default": {
            "description": "An unexpected error response",
            "schema": {
              "$ref": "#/definitions/runtimeError"
            }
          }
        },
        "summary": "method's comment",
        "tags": [
          "Demoprj"
        ]
      }
    },
@johanbrandhorst
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants