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

Merging swagger specs (for multiple protos belonging to same package) fails to emit summary for some RPCs #1387

Closed
ashutshkumr opened this issue May 24, 2020 · 1 comment

Comments

@ashutshkumr
Copy link

Steps:

Generate stubs like so (for protos/yaml defined further below):

common="-I/usr/local/include -I${GOPATH}/pkg/mod/ -Isample -I${GOPATH}/src"
spec=sample/services.yaml
gwopt="logtostderr=true,allow_delete_body=true,grpc_api_configuration=${spec}"
swopt="${gwopt},json_names_for_fields=true,allow_merge=true"

protoc $common --plugin=$GOPATH/bin/protoc-gen-go \
    --go_out=plugins=grpc:$GOPATH/src sample/*.proto

protoc $common --plugin=$GOPATH/bin/protoc-gen-grpc-gateway \
    --grpc-gateway_out=${gwopt}:$GOPATH/src sample/*.proto

protoc $common --plugin=$GOPATH/bin/protoc-gen-swagger \
    --swagger_out=${swopt}:sample/ sample/*.proto

sample/a.proto

syntax = "proto3";

package sample;

import "google/protobuf/empty.proto";

// Message A
message MsgA {
    // Success or error code
    int32 code = 1;
    // Descriptive success or error message
    string message = 2;
}

// Service for Message A
service MsgAService {
    // RPC for getting Message A
    rpc GetMsgA (google.protobuf.Empty) returns (MsgA) {}
}

sample/b.proto

syntax = "proto3";

package sample;

import "google/protobuf/empty.proto";

// Message B
message MsgB {
    // Success or error code
    int32 code = 1;
    // Descriptive success or error message
    string message = 2;
}

// Service for Message B
service MsgBService {
    // RPC for getting Message B
    rpc GetMsgB (google.protobuf.Empty) returns (MsgB) {}
}

sample/services.yaml

type: google.api.Service
config_version: 3

http:
    rules:
    - selector: sample.MsgAService.GetMsgA
      get: /api/msga
    - selector: sample.MsgBService.GetMsgB
      get: /api/msgb

Issue:

summary key is missing for /api/msgb in following portion of the generated spec.

  "paths": {
    "/api/msga": {
      "get": {
        "summary": "RPC for getting Message A",
        "operationId": "MsgAService_GetMsgA",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/sampleMsgA"
            }
          },
          "default": {
            "description": "An unexpected error response",
            "schema": {
              "$ref": "#/definitions/runtimeError"
            }
          }
        },
        "tags": [
          "MsgAService"
        ]
      }
    },
    "/api/msgb": {
      "get": {
        "operationId": "MsgBService_GetMsgB",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/sampleMsgB"
            }
          },
          "default": {
            "description": "An unexpected error response",
            "schema": {
              "$ref": "#/definitions/runtimeError"
            }
          }
        },
        "tags": [
          "MsgBService"
        ]
      }
    }
  }
@johanbrandhorst
Copy link
Collaborator

Hi, thanks for the bug report, I'd rather we just reopen the other issue. Could you cross post your report there?

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