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

Reusable enums are not working

Open alejandrod-f opened this issue 2 years ago • 1 comments

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 avatar Feb 15 '23 12:02 alejandrod-f

@alejandrod-f We are currently reviewing it. It may take some time, but we plan to address it.

Javakky-pxv avatar Jul 20 '23 12:07 Javakky-pxv