@Schema annotation with type String and allowableValues set doesn't generate enum drop-down in swagger-ui after upgrading from 1.6.6 (when Spring custom converter is used)

See original GitHub issue

Describe the bug

After upgrading from springdoc-openapi 1.6.6 to 1.6.7/1.6.8 enum drop-down is not visible in swagger-ui.

EDIT: problem is most likely a custom converter with enum (plain or decorated with schema-annotation). More details from comments.

This works with 1.6.6. as expected, but in 1.6.7/1.6.8 there is only normal empty text-field and not the enum drop-down with allowable values:


@Schema(type = "String", allowableValues = {
    "foo", "bar"
})
public enum FooBar {
[..]

And enum is used as pathvariable in controller:


@GetMapping(value = "/some/path/{fooBar}")
public void getFooBar(@PathVariable FooBar fooBar) {
[..]

  • What version of spring-boot you are using? 2.6.7
  • What modules and versions of springdoc-openapi are you using? 1.6.6 works, 1.6.7/1.6.8 doesn’t

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
bnasslahsencommented, May 24, 2022

@solita-alperttiti,

Should be fixed with the next release.

This is the workaround, until then

    @GetMapping(value = "/example/{fooBar}")
    public String getFooBar(@PathVariable @Parameter(schema = @Schema(allowableValues = { "foo", "bar" })) FooBar fooBar) {
        return fooBar.name();
    }
0reactions
solita-alperttiticommented, May 24, 2022

@bnasslahsen I have made a sample project to help reproducing the described behavior easily.

Please see: https://github.com/solita-alperttiti/springdoc-enum-example

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Using @Schema(allowableValues=) for enum param ...
When I generate swagger UI, its showing enum with allowed value as enum names. Instead of enum names, I need to set it...
Read more >
F.A.Q - Springdoc-openapi
How can I define multiple OpenAPI definitions in one Spring Boot project? ... For layout options, you can use swagger-ui configuration options. For...
Read more >
springdoc-openapi changelog - Awesome Java - LibHunt
#1663 - @Schema annotation with type String and allowableValues set doesn't generate enum drop-down in swagger-ui after upgrading from 1.6.6 (when Spring ......
Read more >
springdoc/springdoc-openapi v1.6.9 on GitHub
#1663 - @Schema annotation with type String and allowableValues set doesn't generate enum drop-down in swagger-ui after upgrading from 1.6.6 (when Spring ......
Read more >
Springdoc Openapi Versions - Open Source Agenda
#1663 - @Schema annotation with type String and allowableValues set doesn't generate enum drop-down in swagger-ui after upgrading from 1.6.6 (when Spring ......
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