1

I have multiple paths that require an id number. There are some paths where multiple ids are required.

I know that I can reference a parameter when building a path.

paths:
  /path1/{path1ID}
    parameters:
      - $ref: '#/components/parameters/path1ID_param'

components:
  parameters:
    path1ID_param:
      name: path1ID
      in: path
        schema:
          type: integer

If I do it this way, I'm going to have a lot of repeated definitions where the only change is the name. This grates.

Is there a way I can override the name in the path definition? I have tried variations of allOf but haven't hit on anything yet. I've searched the swagger documentation without much luck. I've searched here and found a lot of interesting pointers that helped me refine my API ... but I found nothing related to what I'm trying to do.

Is it possible to do something like this?

paths:
  /path1/{path1ID}
    parameters:
      - $ref: '#/components/parameters/parmID_param/'
      - name: path1ID
  /path1/{path1ID}/subpath2/{subpath2ID}
    - $ref: '#/components/parameters/parmID_param/'
    - name: path1ID
    - $ref: '#/components/parameters/parmID_param/'
    - name: subpath2ID

components:
  parameters:
    path1ID_param:
      name: path1ID
      in: path
        schema:
          type: integer
1

1 Answer 1

1

This is not supported.

As of OpenAPI 3.1, you can only override the description of a referenced parameter, but not its name or other attributes (required, style, etc.).

Here are existing feature requests in the OpenAPI Specification repository:

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Annoying, but based on the discussion on that issue, I'm not alone. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.