You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttp4JsoniterClientCodegen.java
+2-3Lines changed: 2 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ public class ScalaSttp4JsoniterClientCodegen extends AbstractScalaCodegen implem
case primitive: Primitive => serializePrimitive(name, primitive, format, explode)
25
+
case array: Seq[Primitive] => serializeArray(name, array, format, explode)
26
+
case optPrimitive: Option[Primitive] => optPrimitive.map(value => serializePrimitive(name, value, format, explode)).getOrElse(Map.empty[String, String])
27
+
case optArray: Option[Seq[Primitive]] => optArray.map(serializeArray(name, _, format, explode)).getOrElse(Map.empty[String, String])
28
+
case freeObj: Map[String, Primitive] => freeObj.map((key, value) => (key, value.toString))
29
+
case optObj: Option[t] =>
30
+
inline summonInline[Mirror.Of[t]] match
31
+
case mirror: Mirror.ProductOf[t] =>
32
+
checkFields[mirror.MirroredElemTypes]
33
+
val labels = allLabels[mirror.MirroredElemLabels]
34
+
optObj.map{ obj =>
35
+
val keyVals = labels.zip(obj.asInstanceOf[Product].productIterator.toSeq.asInstanceOf[Seq[Primitive]]).toSeq
36
+
serializeModel(name, keyVals, format, explode)
37
+
}.getOrElse(Map.empty[String, String])
38
+
case _ => error("ERROR") // TODO - support for enums
39
+
case obj =>
40
+
inline summonInline[Mirror.Of[T]] match
41
+
case _: Mirror.SumOf[T] =>
42
+
error("ERROR") // TODO - support for enums
43
+
case mirror: Mirror.ProductOf[T] =>
44
+
checkFields[mirror.MirroredElemTypes] // Stripe ma IDGAF bo używają deepObject np. tak lines[0][tax_amounts][0][amount] - mimo tego że spec na to nie pozwala
45
+
val labels = allLabels[mirror.MirroredElemLabels]
46
+
val keyVals = labels.zip(obj.asInstanceOf[Product].productIterator.toSeq.asInstanceOf[Seq[Primitive]]).toSeq
"Cannot derive structure, structure must consist only of primitive fields"
63
+
)
64
+
}
65
+
66
+
privateinlinedefserializePrimitive(
67
+
paramName:String,
68
+
value:Primitive,
69
+
inlineformat:FormStyleFormat,
70
+
inlineexplode:Boolean
71
+
):Map[String,String] = {
72
+
inline format match
73
+
case FormStyleFormat.FORM =>
74
+
Map(paramName -> value.toString) // for primitve values explode does not change anything
75
+
case FormStyleFormat.SPACEDELIMITED =>
76
+
error(
77
+
"FormStyleFormat.SpaceDelimited does not support primitive values"
78
+
)
79
+
case FormStyleFormat.PIPEDELIMITED =>
80
+
error("FormStyleFormat.PipeDelimited does not support primitive values")
81
+
case FormStyleFormat.DEEPOBJECT =>
82
+
error("FormStyleFormat.DeepObject does not support primitive values")
83
+
84
+
}
85
+
privateinlinedefserializeArray(
86
+
paramName:String,
87
+
values:Seq[Primitive],
88
+
inlineformat:FormStyleFormat,
89
+
inlineexplode:Boolean
90
+
):Map[String,String] = {
91
+
inline format match
92
+
case FormStyleFormat.FORM =>
93
+
inline if explode then values.map(s => (paramName, s.toString)).toMap
94
+
else Map(paramName -> values.mkString(","))
95
+
case FormStyleFormat.SPACEDELIMITED =>
96
+
inline if explode then values.map(s => (paramName, s.toString)).toMap
97
+
else Map(paramName -> values.mkString("")) // Sttp will encode space as +, from https://swagger.io/docs/specification/v3_0/serialization/#query-parameters it is not clear if it should be + or%20
98
+
case FormStyleFormat.PIPEDELIMITED =>
99
+
inline if explode then values.map(s => (paramName, s.toString)).toMap
100
+
else Map(paramName -> values.mkString("|"))
101
+
case FormStyleFormat.DEEPOBJECT =>
102
+
error("FormStyleFormat.DeepObject does not support arrays")
103
+
}
104
+
inlinedefserializeModel(
105
+
paramName:String,
106
+
keyValPairs:Seq[(String,Primitive)],
107
+
inlineformat:FormStyleFormat,
108
+
inlineexplode:Boolean
109
+
):Map[String,String] = {
110
+
inline format match
111
+
case FormStyleFormat.FORM =>
112
+
inline if explode then keyValPairs.map((key, value) => (key, value.toString)).toMap
0 commit comments