grpc-ecosystem/grpc-gateway

protoc-gen-openapiv2: don't emit body objects containing only nested path parameters

Open

#2,624 建立於 2022年4月4日

在 GitHub 查看
 (8 留言) (3 反應) (0 負責人)Go (16,971 star) (2,250 fork)batch import
buggood first issuehelp wantedopenapi

描述

🚀 Feature

When path parameters are all part of a message in the body protoc-gen-openapiv2 emits a body property that is an empty object. While technically the field id is selected by body: "*" its sole field value is a path parameter and id is emitted as body object without properties.

service EntityService {
  rpc DeleteEntity(DeleteEntityRequest) returns (DeleteEntityResponse) {
    option (google.api.http) = {
      delete: "/entities/{id.value}"
      body: "*"
    };
  }
}

// message Entity {
//      EntityId id = 1;
//      etc.
// }

message EntityId {
        string value = 1;
}

message DeleteEntityRequest {
        EntityId id = 1;
        string other_field = 2;
}

message DeleteEntityResponse {}
    "/entities/{id.value}": {
      "delete": {
        "operationId": "EntityService_DeleteEntity",
        "responses": {
          "200": {
            "description": "A successful response.",
            "schema": {
              "$ref": "#/definitions/testingDeleteEntityResponse"
            }
          }
        },
        "parameters": [
          {
            "name": "id.value",
            "in": "path",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "object"     <---
                },
                "otherField": {
                  "type": "string"
                }
              }
            }
          }
        ]
      }
    }

貢獻者指南

protoc-gen-openapiv2: don't emit body objects containing only nested path parameters · grpc-ecosystem/grpc-gateway#2624 | Good First Issue