[Scala] Add enums to scala-http4s-server#21320
Conversation
47c1ab8 to
1cb9c2f
Compare
1cb9c2f to
3e46ec6
Compare
|
thanks for the PR cc |
|
please follow step 3 to update the samples so that the CI can verify the change |
393f94d to
de1c5c3
Compare
de1c5c3 to
3225064
Compare
| cModel.getVendorExtensions().put("x-isEnum", true); | ||
|
|
||
| } else { | ||
| cModel.getVendorExtensions().put("x-another", true); |
There was a problem hiding this comment.
thanks for the PR. what exactly is another?
There was a problem hiding this comment.
I added this type to describe types that are not traits or enums. This is necessary to get into this branch in the mustache templates and generate case classes
There was a problem hiding this comment.
will x-unsupported works better in this case?
There was a problem hiding this comment.
I doubt that "unsupported" is the right name for simple types, which generated to scala case classes. I think "another" better describes all types except traits and enums
There was a problem hiding this comment.
let's go with what you've right now. we can always fine tune the extension naming later.
|
tested locally and the result is good here is what the change looks like before and after applying this fix diff --git a/src/main/scala/org/openapitools/models/types.scala b/src/main/scala/org/openapitools/models/types.scala
index 8247885..2075ca8 100644
--- a/src/main/scala/org/openapitools/models/types.scala
+++ b/src/main/scala/org/openapitools/models/types.scala
@@ -8,15 +8,17 @@ import io.circe.{ Decoder, Encoder }
import io.circe.generic.semiauto.{ deriveDecoder, deriveEncoder }
+import org.openapitools.models.EnumType.EnumType
/**
*
*/
-case class EnumType(
-)
-object EnumType {
- implicit val encoderEnumType: Encoder[EnumType] = deriveEncoder[EnumType].mapJson(_.dropNullValues)
- implicit val decoderEnumType: Decoder[EnumType] = deriveDecoder[EnumType]
+object EnumType extends Enumeration {
+ type EnumType = Value
+ val Fix = Value
+ val Max = Value
+ implicit val decoder: Decoder[EnumType.Value] = Decoder.decodeEnumeration(EnumType)
+ implicit val encoder: Encoder[EnumType.Value] = Encoder.encodeEnumeration(EnumType)
}
/**
|
There is an example of correct openAPI specification:
For given OpenAPI specification generated not valid type for enum EnumType - empty case class:
case class EnumType()I added enum handling for scala-http4s-server.
Trying to fix #9987 for scala-http4s-server.