Reputation: 1294
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
Upvotes: 1
Views: 2709
Reputation: 98082
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:
Upvotes: 1