swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Swagger-UI: ugly numbered rendering of enum "allowed values"

Open elipp opened this issue 5 months ago • 4 comments

Q&A

  • OS: Linux
  • Browser: Chrome, Firefox, probably all of them
  • Version:
  • Method of installation: Docker
  • Swagger-UI version: 5.20.0
  • Swagger/OpenAPI version: whatever's in the swaggerapi/swagger-ui:5.20.0 Docker image, OpenAPI 3.1.0

Content & configuration

Example Swagger/OpenAPI definition:

{
	"MyEnum": {
		"type": "string",
		"enum": [
			"allowedValue1",
			"allowedValue2",
			"allowedValue3",
			"allowedValue4"
		]
	}
}

Swagger-UI configuration options:

const ui = SwaggerUIBundle({
	urls: [
		{url: "https://{$DOMAIN_NAME}/api/a", name: "a"},
		{url: "https://{$DOMAIN_NAME}/api/b", name: "b"}
	],
	dom_id: '#swagger-ui',
	presets: [
		SwaggerUIBundle.presets.apis,
		SwaggerUIStandalonePreset
	],
	layout: "StandaloneLayout",
	tryItOutEnabled: true,
	validatorUrl: null,
	plugins: [
	SwaggerUIBundle.plugins.DownloadUrl
	],
	deepLinking: true
});

Describe the bug you're encountering

In Swagger-UI 5.19.0, the allowed values are rendered in a pretty listing in dotted-border boxes, and 5.20.x onwards, they render as:

#0"allowedValue1"
#1"allowedValue2"
#2"allowedValue3"
#3"allowedValue4"

To reproduce...

Steps to reproduce the behavior:

  1. have a schema with an enum type
  2. click Schemas and Expand for the enum type

Expected behavior

Render a pretty listing of allowed values :D

Screenshots

Swagger-UI >=5.14.x <= 5.19.x

Image

Swagger-UI >= 5.20.x:

Image

Additional context or thoughts

On further investigation, this goes for other types of "example" elements too.

elipp avatar Sep 02 '25 13:09 elipp

Hey @elipp 👋 In the 5.20.1 release, we introduced displaying enum values using the JSONViewer component, which addressed issues where complex values hadn't been displayed correctly

before: Image

after: Image

The changes to the UI allowed us to be more flexible with the values; anyway, we are open to PRs with ideas for improving the current behavior

robert-hebel-sb avatar Sep 15 '25 10:09 robert-hebel-sb

hey @robert-hebel-sb , I’d love to work on this issue. could you please assign it to me?

sajdakabir avatar Oct 03 '25 07:10 sajdakabir

hello there @sajdakabir Sure! Looking forward to a PR ❤️

robert-hebel-sb avatar Oct 07 '25 09:10 robert-hebel-sb

@robert-hebel-sb can you check my pr #10597

sajdakabir avatar Oct 08 '25 15:10 sajdakabir