grpc-ecosystem/grpc-gateway

Comments of rpc method gets copied if multiple services are present in a proto file.

開放

#746 建立於 2018年9月5日

 (8 則留言) (3 個反應) (0 位負責人)Go (2,250 個分叉)batch import
bughelp wantedopenapi

倉庫指標

星標
 (16,971 顆星)
PR 合併指標
 (PR 指標待抓取)

描述

I have a proto file which consists of multiple services. When I generate the swagger json file from it, the comment which are mentioned for the first service gets copied down to the second service in the json file.

Here is the proto file:

syntax = "proto3";

import "google/api/annotations.proto";

service SampleService1{
    // Comment 1
    rpc Method (Empty) returns (Empty){
        option (google.api.http) = {
            get : "/api/method1"
        };
    }
}

service SampleService2{
    // Comment 2
    rpc Method (Empty) returns (Empty){
        option (google.api.http) = {
            get : "/api/method2"
        };
    }
}

message Empty {}

Here is the generated swagger json file:

{
    "paths": {
        "/api/method1": {
            "get": {
                "operationId": "Method",
                "responses": {
                    "200": {
                        "description": "",
                        "schema": {
                            "$ref": "#/definitions/Empty"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {}
                    }
                },
                "tags": [
                    "SampleService1"
                ],
                "summary": "Comment 1"
            }
        },
        "/api/method2": {
            "get": {
                "operationId": "Method",
                "responses": {
                    "200": {
                        "description": "",
                        "schema": {
                            "$ref": "#/definitions/Empty"
                        }
                    },
                    "404": {
                        "description": "Not Found",
                        "schema": {}
                    }
                },
                "tags": [
                    "SampleService2"
                ],
                "summary": "Comment 1"
            }
        }
    },
    "schemes": [
        "http",
        "https"
    ],
    "tags": [
        {
            "name": "SampleService1",
            "description": "Description"
        },
        {
            "name": "SampleService2",
            "description": "Description"
        }
    ],
    "basePath": "/",
    "host": "localhost:3000",
    "definitions": {
        "Empty": {
            "type": "object"
        }
    },
    "swagger": "2.0"
}

Can anyone help in fixing this issue ?

I don't want the comments to get copied. The comments should be present as it is in json file for their respective rpc methods under their respective services.

貢獻者指南