I have multiple parameters that I want to reference, but I do not want to specify them one by one.
This snippet does not make the parameters show up:
{
...
"paths": {
"/stuff": {
"get": {
"description": "Gets stuff",
"operationId": "getStuff",
"parameters": {
"$ref": "#/definitions/set1"
}
}
}
},
"parameters": {
"a": {
"name": "a",
"in": "query",
"description": "Param A",
"required": false,
"type": "string"
},
"b": {
"name": "b",
"in": "query",
"description": "Param B",
"required": false,
"type": "string"
}
},
"definitions": {
"set1": [
{
"$ref": "#/parameters/a"
},
{
"$ref": "#/parameters/b"
}
],
"set2": ...
}
}
Is this possible or do I have to specify each parameter like set1
, for each request?
Indeed that's not a valid definition and as you suggested, you'd have to specify each parameter separately by referencing the global one. If your parameters are shared for all operations under a specific path, you can define those at the path level and they would be applied to all operations.
For an individual operation, you'd define it as:
"paths": {
"/stuff": {
"get": {
"description": "Gets stuff",
"operationId": "getStuff",
"parameters": [
{
"$ref": "#/parameters/a"
},
{
"$ref": "#/parameters/b"
}
]
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With