swagger-api / swagger-api/swagger-ui

Do not render example value under schema section for request body data in object-model.jsx

Open
#8,470 1 comment 1 reaction 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.