question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:open
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
webroncommented, Oct 16, 2017

While this is a bug, you can easily overcome it by explicitly adding the type.

  accessTokenReq:
    type: object
    properties:
      grant_type:
        type: string
        enum:
          - client_credentials
      client_id:
        type: string
      client_secret:
        type: string
0reactions
daklcommented, Jan 27, 2022

Any updates in this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

DisplayTemplate for Enum not working for some values
I have a model as enum class named Priority. I have an editor template for Priority and a display template for Enum. In...
Read more >
Picker driven by enum | Apple Developer Forums
SwiftUI will use this to map from views to enum case values. ... enum Sample: String, Equatable, CaseIterable { case first = "First"...
Read more >
Enum dropdown with readable values in rails
If you have a model, which has an enum attribute and you want to have a select tag(dropdown) with titleized values(no ugly underscores)...
Read more >
Enterprise Architect Object Model | Sparx Systems
If this does not appear, go to the command line and ... The enum values defined here are used exclusively for the ......
Read more >
swagger vendor extensions example
Changes to this prop's value will not be propagated to the underlying Swagger UI instance. ... Example using Vendor Extensions in Swagger Template...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found