Skip to content

Enum as field in class doesn't show description #9

@mkczyk

Description

@mkczyk

What works

Enum directly in the controller.

public enum SomeEnum {
	@ApiEnum("First Option")
	A, //
	@ApiEnum("Second Option")
	B, //
	C
}
    @PostMapping("/some")
    public void someMethod(@ApiParam("Some description.") SomeEnum param) {}

It shows properly:

Some description.

A: First Option
B: Second Option
C: @ApiEnum annotation not available
Available values : A, B, C

image

What doesn't work

Enum nested in class.

SomeEnum the same as above.

public class ParamParent {
    @ApiModelProperty("Some description.")
    SomeEnum attribute;
}
@PostMapping("/some2")
    public void someMethod2(@RequestParam ParamParent param) {}

It didn't show details of enum:

image

What I tried (but it still doesn't work)

  • Add @ApiModel to class ParamParent,
  • Add @ApiParam to parameter in controller's method: someMethod2(@ApiParam ParamParent param),
  • Add or remove @RequestParam to parameter in controller's method: someMethod2(@RequestParam ParamParent param).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions