Skip to content

Is it possible to have a PathItem.Parameter as a ref? #416

Open
@Anthony-Bible

Description

@Anthony-Bible

Similar to #25, but in the reverse I want to be able to render to a ref:

paths:
  /test:
    get:
      operationId: getTest
      parameters:
        - $ref: '#/components/parameters/test' # This here

But it seems like the only potential option is possibly resolving the ref to the full yaml currently? The problem with this is we may use the ref in many places so that could increase our Openapi file by thousands of lines.

Just for a full picture, we're doing a protobuf to openapi spec and using this library to render the openapi:

This is the rpc:

  rpc GetUser(GetUserRequest) returns (User) {
    option (google.api.http) = {get: "/users"};
    option (google.api.method_signature) = "name";
    option (gnostic.openapi.v3.operation) = {
      description: "Get a user" // this will overwrite the comment above the rpc
      tags: "users" // this is used to group the operations in the gnostic.openapi spec, by default it only contains the service name
      operation_id: "GetUsers" // this by default is service_name + '_' + method_name

      // This refers to the header defined in the document option above, it will automatically document the header when converted to gnostic.openapi/json spec
      // it's currently commented out until our generation tool has support for it, once support is enabled we will uncomment this
      parameters: {reference: {_ref: "#/components/parameters/filter_mask"}}"#/components/parameters/filter_mask"
      };
}

We would like to render it like:

...
paths:
  /users:
    get:
      description: Get a User
      operation_id: GetUsers
      parameters:
        - $ref: "#/components/parameters/filter_mask"

The closest I can find is creating a proxy schema but that's only doing a ref for schemas so you'd still have lots of repeating lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    need better exampleneeds more information, explanation or a better example.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions