swagger-api / swagger-api/swagger-ui

Hide example from Inline Models in Respones

Open
#4,494 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

cat: rendering type: feature
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q A
Bug or feature request? feature request
Which Swagger/OpenAPI version? 3.0.0
Which Swagger-UI version? 3.13.6 gcbff0251
How did you install Swagger-UI? npm run build
Which browser & version? na
Which operating system? na
Problem

When example is provided in the schema of the Media object, it is being read correctly, and the "Example Value" box is filled in. HOWEVER, if you click "Model", you can also see your example field listed there, in gray-ed out color, and it's very confusing.

I'm providing 2 samples, one simple (where it's not that much of an issue), one more complex (where it's becoming a pain).

Am I missing something?

Demonstration API definition

Simple case:

openapi: "3.0.0"
info:
  title: Schema Example Test
  version: v2
  description: Schema Example
paths:
  /:
    get:
      operationId: main
      responses:
        '200':
          content:
            application/json:
              schema:
                type: integer
                example: 12

swag1

More complex version:

openapi: "3.0.0"
info:
  title: Schema Example Test
  version: v2
  description: Schema Example
paths:
  /:
    get:
      operationId: main
      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                    name:
                      type: string
                example:
                  id: 1
                  name: Dog

swag2

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 the two OpenAPI 3.0.0 definitions and compare how the Example Value and Model views render their schema examples. The work is done when a schema example remains visible in Example Value but is no longer listed in the Model view, including the array and object case.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.