File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed
01-domain/src/main/scala/camundala/domain Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,22 @@ given InOutCodec[IntOrString] = CirceCodec.from(
113
113
type IntOrString = Int | String
114
114
given ApiSchema [IntOrString ] = Schema .derivedUnion
115
115
116
+ type IntOrBoolean = Int | Boolean
117
+
118
+ given ApiSchema [IntOrBoolean ] = Schema .derivedUnion
119
+ given InOutCodec [IntOrBoolean ] = CirceCodec .from(
120
+ new Decoder [IntOrBoolean ]:
121
+ final def apply (c : HCursor ): Decoder .Result [IntOrBoolean ] =
122
+ if c.value.isBoolean
123
+ then c.as[Boolean ]
124
+ else c.as[Int ]
125
+ ,
126
+ new Encoder [IntOrBoolean ]:
127
+ final def apply (a : IntOrBoolean ): Json = a match
128
+ case s : Boolean => Json .fromBoolean(s)
129
+ case i : Int => Json .fromInt(i)
130
+ )
131
+
116
132
case class NoInput ()
117
133
object NoInput :
118
134
given ApiSchema [NoInput ] = deriveApiSchema
You can’t perform that action at this time.
0 commit comments