Multiple parameters examples

Currently ReDoc supports only one example per parameter, add many examples support if it is possible, please.
where to add the query parameter and how to use it
Yes. I've checked it one more time, it can has many enum values, but examples are always limited to one value. I've edited spec in Restlet GUI and it allows to add many examples which are displayed on service, but in fact in generated spec file it has only one x-example per parameter.
parameters:
- name: "include[type]"
in: "query"
required: false
type: "string"
enum:
- "FirstType"
- "SecondType"
- "ThirdType"
x-example: "FirstType"
I just ran into this as well. There's a nice overview under "Parameter Examples" https://swagger.io/docs/specification/adding-examples/.
I'm trying to document examples for query parameters that match a specific pattern:
parameters:
- name: created
in: query
description: Date when foo was created.
required: false
schema:
type: string
pattern: '(gte|lte|equals):\d{4}-\d{2}-\d{2}'
examples:
gte:
value: 'gte:2019-05-10'
summary: 'Filter foo when created >= 2019-05-10'
lte:
value: 'lte:2019-05-10'
summary: '...'
@antograssiot seems to use OpenAPI 2 which didn't have examples on parameters. They were added in OpenAPI 3
I think we can render multiple examples. It may looks like:
Field description here
Examples:
gte:2019-05-10 - Filter foo when created >= 2019-05-10
lte:2019-05-10 - ....
PR would be appreciated. It shouldn't be complicated
I guess you wanted to ping @antonkomarev instead of me 😂
Oops 🙈. Sorry for bothering
Would be nice to see this feature :+1:
Would be nice to see this feature 👍
+1
This seems to be added in 2.0.0-rc.48, but I'm not sure if it works.
I tried to generate a bundle using redoc-cli but it fails. I've been able to reproduce the issue using the Petstore OpenAPI spec by adding a parameter example.
Defining one example for the parameter works as expected:
'/pet/{petId}':
get:
tags:
- pet
summary: Find pet by ID
description: Returns a single pet
operationId: getPetById
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
schema:
type: integer
format: int64
example: 123
Specifying multiple fails:
'/pet/{petId}':
get:
tags:
- pet
summary: Find pet by ID
description: Returns a single pet
operationId: getPetById
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
schema:
type: integer
format: int64
examples:
TestExample: 456
TestExample2: 789
Not completely sure if this is valid OpenAPI. Using something like this also does not work:
TestExample:
$ref: '#/components/schemas/Test'
Output:
# redoc-cli bundle openapi.yml
Prerendering docs
ReferenceError: name is not defined
at /Users/xxx/.config/yarn/global/node_modules/redoc/bundles/redoc.lib.js:9404:124
at mapValues (/Users/xxx/.config/yarn/global/node_modules/redoc/bundles/redoc.lib.js:7269:24)
at new FieldModel (/Users/xxx/.config/yarn/global/node_modules/redoc/bundles/redoc.lib.js:9404:29)
at /Users/xxx/.config/yarn/global/node_modules/redoc/bundles/redoc.lib.js:9741:50
at Array.map (<anonymous>)
at OperationModel.get (/Users/xxx/.config/yarn/global/node_modules/redoc/bundles/redoc.lib.js:9741:15)
at OperationModel.get (/Users/xxx/.config/yarn/global/node_modules/redoc/bundles/redoc.lib.js:8600:42)
at Object.children (/Users/xxx/.config/yarn/global/node_modules/redoc/bundles/redoc.lib.js:14129:97)
at ReactDOMServerRenderer.render (/Users/xxx/.config/yarn/global/node_modules/react-dom/cjs/react-dom-server.node.development.js:3635:55)
at ReactDOMServerRenderer.read (/Users/xxx/.config/yarn/global/node_modules/react-dom/cjs/react-dom-server.node.development.js:3373:29)
I'm using redoc-cli version 0.10.2 on MacOS 10.15.7 with NodeJS v14.15.1. Everthing works fine with redoc-cli 0.10.1 (just not showing multiple examples, as not supported yet).
Stange thing here is that 0.10.2 has not been released yet? https://github.com/Redocly/redoc/blob/master/cli/package.json#L3
This seems to be added in 2.0.0-rc.48, but I'm not sure if it works.
Seems to work. Could be closed maybe