Skip to content

Error with @Schema annotation on enum on 2.5.6 but not on 2.5.5 #5611

@noeliajimenezg

Description

@noeliajimenezg

The annotation io.swagger.v3.oas.annotations.media.Schema used on an enum class is throwing the error "Enum types cannot be defined as beans" since Micronaut 2.5.6.

Steps to Reproduce

  1. Having an enum class
@Schema(description = "My description")
public enum MyEnumClass {
  VALUE1,
  VALUE2;
}
  1. Having a class using the enum
public class MyClass {
  MyEnumClass logisticType;
}

Expected Behaviour

Build successful.

Actual Behaviour

The error "Enum types cannot be defined as beans" is thrown.
That error handling was added longtime ago on this commit: 88e5f1f#diff-eb053b86bf8cb1bf2922f4e33f58ffdd98065386b02f884b32b70afa5b4ace42

Environment Information

  • Operating System: Mac OS Big Sur
  • Micronaut Version: 2.5.6
  • JDK Version: JDK 16

Workaround solution

@ApiModel(description = "My description")
public enum MyEnumClass {
  VALUE1,
  VALUE2;
}
public class MyClass {
  @ApiModelProperty MyEnumClass logisticType;
}

Metadata

Metadata

Assignees

Labels

priority: highHigh prioritystatus: pr submittedA pull request has been submitted for the issuetype: regressionA breaking change was introduced in a minor or patch release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions