play-swagger
play-swagger copied to clipboard
Reusable enums are not working
Hi!
I can not find a way to get enums to be generated in a way that are reused.
Based on some research, looks like we should be using @Schema(enumAsRef = true)
. But, it does not work.
I'd actually suggest that maybe this should be a global option. Wondering why is not the default... in the code you usually do not repeat the enums.
Spec ref: https://swagger.io/docs/specification/data-models/enums/
- Example
object SomeType extends Enumeration {
type SomeType = Value```
I tried these both:
case class SomeClass(someType: SomeType.SomeType)
case class SomeClass(someType: SomeType.Value)
They both generate something like:
"someType" : {
"type" : "string",
"enum" : [ "Value1", "Value2" ]
},
expected:
"someType" : {
"$ref: '#/components/schemas/SomeType"
},
@alejandrod-f We are currently reviewing it. It may take some time, but we plan to address it.