I have an URL like this:
/id/{idnumber}/status
In this URL, /id/{idnumber}
is the API base path, and /status
is the resource.
I know that OpenAPI (Swagger) allows parameters in paths, like so:
paths:
/id/{number}/status:
but this is not what I need, because /id/{idnumber}
is the base path and not part of the resoruce path.
Is there any way to have a parameter in the base path?
host: my.api.com
basePath: /id/{idnumber} # <---
paths:
/status:
Parameterized base paths are now supported in OpenAPI 3.0, using server variables:
openapi: 3.0.0
...
servers:
- url: https://my.api.com/id/{number}
variables:
number:
default: '-1'
Note that server variables MUST have a default
value - it will be used if the client does not supply a value.
For details, see:
I don't think basePath
allows variables.
For your case, you don't need to use basePath
. You can simply put /id/{idnumber} in the URL path. For example:
"/pet/{petId}": {
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