@@ -146,15 +146,15 @@ private fun Model.Union.toTypeSpec(): TypeSpec {
146
146
" %M(%S, %T.SEALED) {\n " ,
147
147
MemberName (" kotlinx.serialization.descriptors" , " buildSerialDescriptor" ),
148
148
toClassName(context).simpleNames.joinToString(" ." ),
149
- PolymorphicKind ::class
149
+ PolymorphicKind ::class ,
150
150
)
151
151
.withIndent {
152
152
cases.forEach { case ->
153
153
val (placeholder, values) = case.model.serializer()
154
154
add(
155
155
" element(%S, $placeholder .descriptor)\n " ,
156
156
toCaseClassName(case.model).simpleNames.joinToString(" ." ),
157
- * values
157
+ * values,
158
158
)
159
159
}
160
160
}
@@ -177,7 +177,7 @@ private fun Model.Union.toTypeSpec(): TypeSpec {
177
177
addStatement(
178
178
" is %T -> encoder.encodeSerializableValue($placeholder , value.value)" ,
179
179
toCaseClassName(case.model),
180
- * values
180
+ * values,
181
181
)
182
182
}
183
183
}
@@ -195,12 +195,12 @@ private fun Model.Union.toTypeSpec(): TypeSpec {
195
195
CodeBlock .builder()
196
196
.addStatement(
197
197
" val value = decoder.decodeSerializableValue(%T.serializer())" ,
198
- JsonElement ::class .asTypeName()
198
+ JsonElement ::class .asTypeName(),
199
199
)
200
200
.addStatement(
201
201
" val json = requireNotNull(decoder as? %T) { %S }.json" ,
202
202
JsonDecoder ::class .asTypeName(),
203
- " Currently only supporting Json"
203
+ " Currently only supporting Json" ,
204
204
)
205
205
.addStatement(" return attemptDeserialize(value," )
206
206
.withIndent {
@@ -211,7 +211,7 @@ private fun Model.Union.toTypeSpec(): TypeSpec {
211
211
" Pair(%T::class) { %T(json.decodeFromJsonElement($placeholder , value)) },\n " ,
212
212
caseClassName,
213
213
caseClassName,
214
- * values
214
+ * values,
215
215
)
216
216
}
217
217
}
@@ -239,7 +239,7 @@ private fun Model.Object.toTypeSpec(): TypeSpec =
239
239
if (prop.isRequired && hasDefault) addAnnotation(annotationSpec<Required >())
240
240
else if (! prop.isRequired && ! hasDefault && prop.isNullable) defaultValue(" null" )
241
241
}
242
- }
242
+ },
243
243
) {
244
244
// Cannot serialize binary, these are used for multipart requests.
245
245
// This occurs when request bodies are defined using top-level schemas.
@@ -273,7 +273,7 @@ private fun Iterable<Model.Object.Property>.requirements(): List<Requirement> =
273
273
Requirement (
274
274
property,
275
275
" $paramName .size <= ${constraint.maxItems} " ,
276
- " $paramName should have at most ${constraint.maxItems} elements"
276
+ " $paramName should have at most ${constraint.maxItems} elements" ,
277
277
)
278
278
)
279
279
}
@@ -284,15 +284,15 @@ private fun Iterable<Model.Object.Property>.requirements(): List<Requirement> =
284
284
Requirement (
285
285
property,
286
286
" $paramName .size >= ${constraint.minItems} " ,
287
- " $paramName should have at least ${constraint.minItems} elements"
287
+ " $paramName should have at least ${constraint.minItems} elements" ,
288
288
)
289
289
)
290
290
else ->
291
291
listOf (
292
292
Requirement (
293
293
property,
294
294
" $paramName .size in ${constraint.minItems} ..${constraint.maxItems} " ,
295
- " $paramName should have between ${constraint.minItems} and ${constraint.maxItems} elements"
295
+ " $paramName should have between ${constraint.minItems} and ${constraint.maxItems} elements" ,
296
296
)
297
297
)
298
298
}
@@ -325,7 +325,7 @@ private fun Iterable<Model.Object.Property>.requirements(): List<Requirement> =
325
325
Requirement (
326
326
property,
327
327
" $paramName .${" length" } <= ${constraint.maxLength} " ,
328
- " $paramName should have a ${" length" } of at most ${constraint.maxLength} "
328
+ " $paramName should have a ${" length" } of at most ${constraint.maxLength} " ,
329
329
)
330
330
}
331
331
else ->
@@ -334,13 +334,13 @@ private fun Iterable<Model.Object.Property>.requirements(): List<Requirement> =
334
334
Requirement (
335
335
property,
336
336
" $paramName .${" length" } >= ${constraint.minLength} " ,
337
- " $paramName should have a ${" length" } of at least ${constraint.minLength} "
337
+ " $paramName should have a ${" length" } of at least ${constraint.minLength} " ,
338
338
)
339
339
else ->
340
340
Requirement (
341
341
property,
342
342
" $paramName .${" length" } in ${constraint.minLength} ..${constraint.maxLength} " ,
343
- " $paramName should have a ${" length" } between ${constraint.minLength} and ${constraint.maxLength} "
343
+ " $paramName should have a ${" length" } between ${constraint.minLength} and ${constraint.maxLength} " ,
344
344
)
345
345
}
346
346
}
@@ -412,7 +412,7 @@ private fun Model.Object.Property.intRequirement(constraint: Constraints.Number)
412
412
context(OpenAPIContext )
413
413
private fun Model.Object.Property.numberRequirement (
414
414
constraint : Constraints .Number ,
415
- transform : (Double ) -> Number
415
+ transform : (Double ) -> Number ,
416
416
): Requirement ? {
417
417
val paramName = toParamName(Named (baseName))
418
418
val minimum = transform(constraint.minimum)
@@ -435,7 +435,7 @@ private fun Model.Object.Property.numberRequirement(
435
435
Requirement (
436
436
this ,
437
437
" $minimum $min $paramName && $paramName $max $maximum " ,
438
- " $paramName should be $minM $minimum and should be $maxM ${maximum} "
438
+ " $paramName should be $minM $minimum and should be $maxM ${maximum} " ,
439
439
)
440
440
}
441
441
}
@@ -470,7 +470,7 @@ private fun Model.Enum.Closed.toTypeSpec(): TypeSpec {
470
470
)
471
471
}
472
472
.addSuperclassConstructorParameter(" \" $rawName \" " )
473
- .build()
473
+ .build(),
474
474
)
475
475
}
476
476
}
@@ -554,7 +554,7 @@ private fun Model.Enum.Open.toTypeSpec(): TypeSpec {
554
554
" %M(%S, %T.STRING)" ,
555
555
PrimitiveSerialDescriptor ,
556
556
enumName,
557
- PrimitiveKind ::class .asTypeName()
557
+ PrimitiveKind ::class .asTypeName(),
558
558
)
559
559
.build()
560
560
)
@@ -582,7 +582,7 @@ private fun Model.Enum.Open.toTypeSpec(): TypeSpec {
582
582
val nested = NamingContext .Nested (Named (name), context)
583
583
addStatement(
584
584
" Pair(%T::class) { defined.find { it.value == value } }," ,
585
- toClassName(nested)
585
+ toClassName(nested),
586
586
)
587
587
}
588
588
}
0 commit comments