swagger-api / swagger-api/swagger-ui
Multiple examples inside schema
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Context
OpenAPI spec 3.1 announced support for multiple examples inside a schema (not to be confused with multiple examples for request/response which has been supported for a while now).
I was trying to check out how this feature looks like, but it seems is not yet supported by SwaggerUI latest version (5.2.4 as of now).
Specs
The following, single example syntax is supported at 3.0.2:
components:
schemas:
Cat:
type: object
required: [name, livesLeft]
properties:
name:
type: string
livesLeft:
type: integer
example:
name: Grumpy
livesLeft: 2
It renders
However, if I try to switch to 3.1.0 and use multiple examples
components:
schemas:
Cat:
type: object
required: [name, livesLeft]
properties:
name:
type: string
livesLeft:
type: integer
examples:
- name: Grumpy
livesLeft: 2
- name: Felix
livesLeft: 3
the following is rendered
Which is incorrect, as it looks as if Examples was a property of a Cat object.
Are there any plans to add support for this feature? Thanks
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied OpenAPI 3.1 YAML in Swagger UI 5.2.4 and trace how schema examples are rendered. The work is done when multiple schema examples render as examples rather than as a Cat property, while the existing single-example syntax continues to render correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100