Skip to content

Commit 91ce946

Browse files
committed
fix additional empty line when generating javadoc on a property without description (#415)
1 parent dcaaab3 commit 91ce946

6 files changed

Lines changed: 25 additions & 2 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,11 @@ abstract class DataTypeWriterBase(
9595
var result = ""
9696

9797
if (apiOptions.javadoc && !apiOptions.isRecord()) {
98-
result += javadocFactory.create(propDataType).indent()
99-
result += LF
98+
val javadoc = javadocFactory.create(propDataType)
99+
if (javadoc.isNotEmpty()) {
100+
result += javadoc.indent()
101+
result += LF
102+
}
100103
}
101104

102105
result += ifDeprecated(propDataType)

openapi-processor-core/src/testInt/resources/tests/javadoc/inputs/openapi30.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ components:
5656
this is the *Foo* schema description
5757
type: object
5858
properties:
59+
no-description:
60+
type: string
5961
foo-bar:
6062
description: >
6163
*property* description

openapi-processor-core/src/testInt/resources/tests/javadoc/inputs/openapi31.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ components:
5656
this is the *Foo* schema description
5757
type: object
5858
properties:
59+
no-description:
60+
type: string
5961
foo-bar:
6062
description: >
6163
*property* description

openapi-processor-core/src/testInt/resources/tests/javadoc/inputs/openapi32.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ components:
5252
this is the *Foo* schema description
5353
type: object
5454
properties:
55+
no-description:
56+
type: string
5557
foo-bar:
5658
description: |
5759
*property* description

openapi-processor-core/src/testInt/resources/tests/javadoc/outputs/model/_default_/Foo.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
@Generated(value = "openapi-processor-core", version = "test")
1010
public class Foo {
1111

12+
@JsonProperty("no-description")
13+
private String noDescription;
14+
1215
/**
1316
* <em>property</em> description
1417
*/
@@ -21,6 +24,14 @@ public class Foo {
2124
@JsonProperty("enum")
2225
private FooEnum aEnum;
2326

27+
public String getNoDescription() {
28+
return noDescription;
29+
}
30+
31+
public void setNoDescription(String noDescription) {
32+
this.noDescription = noDescription;
33+
}
34+
2435
public String getFooBar() {
2536
return fooBar;
2637
}

openapi-processor-core/src/testInt/resources/tests/javadoc/outputs/model/_record_/Foo.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
*/
1212
@Generated(value = "openapi-processor-core", version = "test")
1313
public record Foo(
14+
@JsonProperty("no-description")
15+
String noDescription,
16+
1417
@JsonProperty("foo-bar")
1518
String fooBar,
1619

0 commit comments

Comments
 (0)