swagger-api / swagger-api/swagger-ui
Do not render example value under schema section for request body data in object-model.jsx
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Content & configuration
Swagger/OpenAPI definition:
# N/A
Swagger-UI configuration options:
SwaggerUI({
// nothing relevant
})
Is your feature request related to a problem?
In the object-model.jsx file there is a section that defines and renders "infoProperties":
let infoProperties = schema
.filter( ( v, key) => ["maxProperties", "minProperties", "nullable", "example"].indexOf(key) !== -1 )
...
{
infoProperties.size ? infoProperties.entrySeq().map( ( [ key, v ] ) => <Property key={`${key}-${v}`} propKey={ key } propVal={ v } propClass={ propClass } />) : null
}
As this is an object model, the example is likely to be something more complex, like json, the example tab shows and nicely formats this, whether an example is provided in the schema or auto-generated by swagger-ui.
However, only when a specific example is provided in the schema, swagger-ui then also chooses to render this against the schema tab at the end but in a completely unformulated, flat, hard to read way.
Describe the solution you'd like
Put simply, it would be good if example was not considered part of the infoProperties collection when dealing with object models. The example tab should be sufficient as the value rendered in the schema tab just ends up being a harder to read, unformatted copy of that same data.
Describe alternatives you've considered
Custom CSS rules could be put into place to try and hide just that section, but in our usages, using Swashbuckle across a large number of ASP.NET Core microservices where this is all centrally configured for consistency, it would mean ensuring each service manually had the CSS assets file included with it
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 with src/core/components/object-model.jsx and inspect how infoProperties is built and rendered for object models. Compare the schema tab with the example tab using a schema that provides an object example; done means the example is no longer duplicated as a flat value under the schema section while the example tab still displays it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100