swagger-api / swagger-api/swagger-ui
Show "undefined" explicitly in addition to not showing a red asterisk
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Is your feature request related to a problem?
If you define a component where every field is optional, the UI shows all fields without a red asterisk. This is expected and fine. However, when sharing this schema with other teams who are unfamiliar with this specific format, they may interpret the lack of a red asterisk to mean all fields are required. For example, look at the two screenshots below:
In the first, you would think every property is required since we see string for all of them.
In the second, you realize they are actually all optional except for id since it has a red asterisk.
Describe the solution you'd like
The solution is to show string | undefined for properties that are not required. This would clear up the issue and make it more clear that something is not required. We could also show a ? next to the field name instead of undefined.
Thanks so much!
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
The issue names no files or tests, so first locate the Swagger UI component that renders schema properties and their required-field indicators. Verify how optional properties are displayed, then make the rendered type explicitly indicate undefined or use a question mark, and confirm the result in the schema view.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100