Skip to content
This repository was archived by the owner on Mar 16, 2025. It is now read-only.

Commit 0622348

Browse files
committed
#45, handle explicit null type
1 parent 9ecf208 commit 0622348

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/main/kotlin/io/openapiprocessor/core/converter/wrapper/NullDataTypeWrapper.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,25 @@ open class NullDataTypeWrapper(
2929
* @return the resulting java data type
3030
*/
3131
fun wrap(dataType: DataType, schemaInfo: SchemaInfo): DataType {
32-
val targetType = getNullDataType(schemaInfo)
32+
val (targetType, init) = getNullDataType(schemaInfo)
3333
if (targetType == null) {
3434
return dataType
3535
}
3636

3737
return NullDataType (
3838
targetType.getName(),
3939
targetType.getPkg(),
40+
init,
4041
dataType
4142
)
4243
}
4344

44-
private fun getNullDataType(info: SchemaInfo): TargetType? {
45+
private data class Target(val targetType: TargetType?, val init: String? = null)
46+
47+
private fun getNullDataType(info: SchemaInfo): Target {
4548
// check endpoint result mapping
46-
return finder.findEndpointNullTypeMapping(info)?.getTargetType()
49+
val nullType = finder.findEndpointNullTypeMapping(info)
50+
return Target(nullType?.getTargetType(), nullType?.undefined)
4751

4852
// not yet supported
4953
// check global result mapping

0 commit comments

Comments
 (0)