swagger-api / swagger-api/swagger-ui

enum values not displayed in example/model view (resubmitted using template)

Open
#3,761 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P2 type: bug version: 3.x
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

ENUM values in the schema definition are not displayed in the example/model view sections of the swagger-ui page.

Q A
Bug or feature request? Bug
Which Swagger/OpenAPI version? 2.0
Which Swagger-UI version? 3.3.1
How did you install Swagger-UI? embedded in swagger-tools module
Which browser & version? Safari Version 11.0 (12604.1.38.1.7)
Which operating system? macOS Sierra Version 10.12.6 (16G29)
Demonstration API definition
accessTokenReq:
    type: object
    properties:
      grant_type:
        enum:
          - client_credentials
      client_id:
        type: string
      client_secret:
        type: string

Expected Behavior

Rendered by UI:

Example section:

{
  "grant_type": "client_credentials",
  "client_id": "string",
  "client_secret": "string"
}

Model section

accessTokenReq { 
  grant_type  = ['client_credentials'],
  client_id | string
  client_secret | string
}
Current Behavior

Rendered by UI:

Example section:

{
  "client_id": "string",
  "client_secret": "string"
}

Model section

accessTokenReq {
  grant_type {
  }
  client_id | string
  client_secret | string
}
Possible Solution
Context

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 by loading the demonstrated Swagger 2.0 schema in Swagger UI 3.3.1 and reproducing the missing enum in the example and model sections. Trace the example/model rendering paths for the grant_type property, then verify that both sections display client_credentials as shown in the expected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
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.