Skip to content

Commit 5ddc052

Browse files
committed
create object schema & properties javadoc
1 parent 2f07ca4 commit 5ddc052

File tree

18 files changed

+154
-68
lines changed

18 files changed

+154
-68
lines changed

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/converter/DataTypeConverter.kt

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,7 @@ class DataTypeConverter(
204204
properties = properties,
205205
constraints = constraints,
206206
deprecated = schemaInfo.getDeprecated(),
207-
documentation = Documentation(
208-
description = schemaInfo.description
209-
)
207+
documentation = Documentation(description = schemaInfo.description)
210208
)
211209

212210
dataTypes.add (objectType)
@@ -246,22 +244,29 @@ class DataTypeConverter(
246244
return when(typeFormat) {
247245
"integer",
248246
"integer:int32" ->
249-
IntegerDataType(constraints, schemaInfo.getDeprecated())
247+
IntegerDataType(constraints, schemaInfo.getDeprecated(),
248+
Documentation(description = schemaInfo.description))
250249
"integer:int64" ->
251-
LongDataType(constraints, schemaInfo.getDeprecated())
250+
LongDataType(constraints, schemaInfo.getDeprecated(),
251+
Documentation(description = schemaInfo.description))
252252
"number",
253253
"number:float" ->
254-
FloatDataType(constraints, schemaInfo.getDeprecated())
254+
FloatDataType(constraints, schemaInfo.getDeprecated(),
255+
Documentation(description = schemaInfo.description))
255256
"number:double" ->
256-
DoubleDataType(constraints, schemaInfo.getDeprecated())
257+
DoubleDataType(constraints, schemaInfo.getDeprecated(),
258+
Documentation(description = schemaInfo.description))
257259
"boolean" ->
258-
BooleanDataType(constraints, schemaInfo.getDeprecated())
260+
BooleanDataType(constraints, schemaInfo.getDeprecated(),
261+
Documentation(description = schemaInfo.description))
259262
"string" ->
260263
createStringDataType(schemaInfo, constraints, dataTypes)
261264
"string:date" ->
262-
LocalDateDataType(constraints, schemaInfo.getDeprecated())
265+
LocalDateDataType(constraints, schemaInfo.getDeprecated(),
266+
Documentation(description = schemaInfo.description))
263267
"string:date-time" ->
264-
OffsetDateTimeDataType (constraints, schemaInfo.getDeprecated())
268+
OffsetDateTimeDataType (constraints, schemaInfo.getDeprecated(),
269+
Documentation(description = schemaInfo.description))
265270
else ->
266271
throw UnknownDataTypeException(schemaInfo.getName(), schemaInfo.getType(),
267272
schemaInfo.getFormat())
@@ -294,9 +299,12 @@ class DataTypeConverter(
294299
"date-time")
295300
}
296301

297-
private fun createStringDataType(schemaInfo: SchemaInfo, constraints: DataTypeConstraints, dataTypes: DataTypes): DataType {
302+
private fun createStringDataType(schemaInfo: SchemaInfo, constraints: DataTypeConstraints,
303+
dataTypes: DataTypes): DataType {
304+
298305
if (!schemaInfo.isEnum()) {
299-
return StringDataType(constraints, schemaInfo.getDeprecated())
306+
return StringDataType(constraints, schemaInfo.getDeprecated(),
307+
Documentation(description = schemaInfo.description))
300308
}
301309

302310
// in case of an inline definition the name may be lowercase, make sure the enum

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/model/datatypes/BooleanDataType.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.openapiprocessor.core.model.datatypes
1818

19+
import io.openapiprocessor.core.model.Documentation
20+
1921
/**
2022
* OpenAPI type 'boolean' maps to java Boolean.
2123
*
@@ -24,9 +26,10 @@ package io.openapiprocessor.core.model.datatypes
2426
class BooleanDataType(
2527

2628
constraints: DataTypeConstraints? = null,
27-
deprecated: Boolean = false
29+
deprecated: Boolean = false,
30+
documentation: Documentation? = null
2831

29-
): DataTypeBase(constraints, deprecated) {
32+
): DataTypeBase(constraints, deprecated, documentation) {
3033

3134
override fun getName(): String {
3235
return "Boolean"

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/model/datatypes/DoubleDataType.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.openapiprocessor.core.model.datatypes
1818

19+
import io.openapiprocessor.core.model.Documentation
20+
1921
/**
2022
* OpenAPI type 'number' with format 'double' maps to java Double.
2123
*
@@ -24,9 +26,10 @@ package io.openapiprocessor.core.model.datatypes
2426
class DoubleDataType(
2527

2628
constraints: DataTypeConstraints? = null,
27-
deprecated: Boolean = false
29+
deprecated: Boolean = false,
30+
documentation: Documentation? = null
2831

29-
): DataTypeBase(constraints, deprecated) {
32+
): DataTypeBase(constraints, deprecated, documentation) {
3033

3134
override fun getName(): String {
3235
return "Double"

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/model/datatypes/FloatDataType.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.openapiprocessor.core.model.datatypes
1818

19+
import io.openapiprocessor.core.model.Documentation
20+
1921
/**
2022
* OpenAPI type 'number' with format 'float' maps to java Float.
2123
*
@@ -24,9 +26,10 @@ package io.openapiprocessor.core.model.datatypes
2426
class FloatDataType(
2527

2628
constraints: DataTypeConstraints? = null,
27-
deprecated: Boolean = false
29+
deprecated: Boolean = false,
30+
documentation: Documentation? = null
2831

29-
): DataTypeBase(constraints, deprecated) {
32+
): DataTypeBase(constraints, deprecated, documentation) {
3033

3134
override fun getName(): String {
3235
return "Float"

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/model/datatypes/IntegerDataType.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.openapiprocessor.core.model.datatypes
1818

19+
import io.openapiprocessor.core.model.Documentation
20+
1921
/**
2022
* OpenAPI type 'integer' with format 'int32' maps to java Integer.
2123
*
@@ -24,9 +26,10 @@ package io.openapiprocessor.core.model.datatypes
2426
class IntegerDataType(
2527

2628
constraints: DataTypeConstraints? = null,
27-
deprecated: Boolean = false
29+
deprecated: Boolean = false,
30+
documentation: Documentation? = null
2831

29-
): DataTypeBase(constraints, deprecated) {
32+
): DataTypeBase(constraints, deprecated, documentation) {
3033

3134
override fun getName(): String {
3235
return "Integer"

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/model/datatypes/LocalDateDataType.kt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.openapiprocessor.core.model.datatypes
1818

19+
import io.openapiprocessor.core.model.Documentation
20+
1921
/**
2022
* OpenAPI type 'string' with format 'date' maps to java LocalDate.
2123
*
@@ -24,9 +26,10 @@ package io.openapiprocessor.core.model.datatypes
2426
class LocalDateDataType(
2527

2628
constraints: DataTypeConstraints? = null,
27-
deprecated: Boolean = false
29+
deprecated: Boolean = false,
30+
documentation: Documentation? = null
2831

29-
): DataTypeBase(constraints, deprecated) {
32+
): DataTypeBase(constraints, deprecated, documentation) {
3033

3134
override fun getName(): String {
3235
return "LocalDate"
@@ -35,5 +38,5 @@ class LocalDateDataType(
3538
override fun getPackageName(): String {
3639
return "java.time"
3740
}
38-
41+
3942
}

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/model/datatypes/LongDataType.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.openapiprocessor.core.model.datatypes
1818

19+
import io.openapiprocessor.core.model.Documentation
20+
1921
/**
2022
* OpenAPI type 'integer' with format 'int64' maps to java Long.
2123
*
@@ -24,9 +26,10 @@ package io.openapiprocessor.core.model.datatypes
2426
class LongDataType(
2527

2628
constraints: DataTypeConstraints? = null,
27-
deprecated: Boolean = false
29+
deprecated: Boolean = false,
30+
documentation: Documentation? = null
2831

29-
): DataTypeBase(constraints, deprecated) {
32+
): DataTypeBase(constraints, deprecated, documentation) {
3033

3134
override fun getName(): String {
3235
return "Long"

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/model/datatypes/OffsetDateTimeDataType.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.openapiprocessor.core.model.datatypes
1818

19+
import io.openapiprocessor.core.model.Documentation
20+
1921
/**
2022
* OpenAPI type 'string' with format 'date-time' maps to java OffsetDateTime.
2123
*
@@ -24,7 +26,8 @@ package io.openapiprocessor.core.model.datatypes
2426
class OffsetDateTimeDataType(
2527

2628
constraints: DataTypeConstraints? = null,
27-
deprecated: Boolean = false
29+
deprecated: Boolean = false,
30+
documentation: Documentation? = null
2831

2932
): DataTypeBase(constraints, deprecated) {
3033

openapi-processor-core/src/main/kotlin/io/openapiprocessor/core/model/datatypes/StringDataType.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package io.openapiprocessor.core.model.datatypes
1818

19+
import io.openapiprocessor.core.model.Documentation
20+
1921
/**
2022
* OpenAPI type 'string' maps to java String.
2123
*
@@ -24,9 +26,10 @@ package io.openapiprocessor.core.model.datatypes
2426
class StringDataType(
2527

2628
constraints: DataTypeConstraints? = null,
27-
deprecated: Boolean = false
29+
deprecated: Boolean = false,
30+
documentation: Documentation? = null
2831

29-
): DataTypeBase(constraints, deprecated) {
32+
): DataTypeBase(constraints, deprecated, documentation) {
3033

3134
override fun getName(): String {
3235
return "String"

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class DataTypeWriter(
6565
propDataType: DataType, required: Boolean): String {
6666

6767
var result = ""
68+
69+
if (apiOptions.javadoc) {
70+
result += javadocWriter.convert(propDataType)
71+
}
72+
6873
if (propDataType.isDeprecated()) {
6974
result += " @Deprecated\n"
7075
}

0 commit comments

Comments
 (0)