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

Commit b44da23

Browse files
committed
#45, write "null" init value
1 parent 0622348 commit b44da23

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/kotlin/io/openapiprocessor/core/writer/java/DataTypeWriter.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package io.openapiprocessor.core.writer.java
1919
import io.openapiprocessor.core.converter.ApiOptions
2020
import io.openapiprocessor.core.model.datatypes.DataType
2121
import io.openapiprocessor.core.model.datatypes.ModelDataType
22+
import io.openapiprocessor.core.model.datatypes.NullDataType
2223
import java.io.Writer
2324

2425
/**
@@ -85,7 +86,14 @@ class DataTypeWriter(
8586
}
8687

8788
result += " @JsonProperty(\"${propertyName}\")\n"
88-
result += " private ${propDataType.getName()} ${javaPropertyName};\n\n"
89+
result += " private ${propDataType.getName()} ${javaPropertyName}"
90+
91+
// null may have an init value
92+
if (propDataType is NullDataType && propDataType.init != null) {
93+
result += " = ${propDataType.init}"
94+
}
95+
96+
result += ";\n\n"
8997
return result
9098
}
9199

0 commit comments

Comments
 (0)