Skip to content

Commit ad2359a

Browse files
author
jpfinne
committed
Fix spacing for Spring generator
1 parent f8e0065 commit ad2359a

10 files changed

Lines changed: 14 additions & 27 deletions

File tree

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,10 @@ public void execute(Template.Fragment fragment, Writer writer) throws IOExceptio
27322732
if (value.startsWith(nullableAnnotation)) {
27332733
keptNullable = true;
27342734
int idx = nullableAnnotation.length();
2735+
// trim left
2736+
while (idx < value.length() && value.charAt(idx) == ' ') {
2737+
idx ++;
2738+
}
27352739
value = value.substring(idx);
27362740
}
27372741
}

modules/openapi-generator/src/main/java/org/openapitools/codegen/templating/mustache/TrimLambda.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class TrimLambda implements Mustache.Lambda {
3939

4040
@Override
4141
public void execute(Fragment fragment, Writer writer) throws IOException {
42-
writer.write(fragment.execute().trim());
42+
String text = fragment.execute();
43+
writer.write(text.trim());
4344
}
4445
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#openApiNullable}}{{#isNullable}}JsonNullable<{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional<{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}}{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}{{#openApiNullable}}{{#isNullable}}>{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}>{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}}
1+
{{#lambda.trim}}{{#openApiNullable}}{{#isNullable}}JsonNullable<{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional<{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}}{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}{{#openApiNullable}}{{#isNullable}}>{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}>{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}}{{/lambda.trim}}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{{#openApiNullable}}{{#isNullable}}{{^isContainer}}JsonNullable<{{#useBeanValidation}}{{>beanValidationCore}}{{/useBeanValidation}}{{/isContainer}}{{#isContainer}}JsonNullable<{{/isContainer}}{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional<{{#useBeanValidation}}{{>beanValidationCore}}{{/useBeanValidation}}{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}}{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}{{#openApiNullable}}{{#isNullable}}>{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}>{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}}
1+
{{#lambda.trim}}{{#openApiNullable}}{{#isNullable}}{{^isContainer}}JsonNullable<{{#useBeanValidation}}{{>beanValidationCore}}{{/useBeanValidation}}{{/isContainer}}{{#isContainer}}JsonNullable<{{/isContainer}}{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}Optional<{{#useBeanValidation}}{{>beanValidationCore}}{{/useBeanValidation}}{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}}{{#lambda.jSpecifyDatatype}}{{{datatypeWithEnum}}}{{/lambda.jSpecifyDatatype}}{{#openApiNullable}}{{#isNullable}}>{{/isNullable}}{{#useOptional}}{{^required}}{{^isNullable}}{{^isContainer}}>{{/isContainer}}{{/isNullable}}{{/required}}{{/useOptional}}{{/openApiNullable}}{{/lambda.trim}}

samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/model/AbstractOpenApiSchema.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,7 @@ public String toString() {
105105
* (except the first line).
106106
*/
107107
private String toIndentedString(Object o) {
108-
if (o == null) {
109-
return "null";
110-
}
111-
return o.toString().replace("\n", "\n ");
108+
return o == null ? "null" : o.toString().replace("\n", "\n ");
112109
}
113110

114111
public boolean equals(Object o) {

samples/client/petstore/java/native-jackson3-jspecify/src/main/java/org/openapitools/client/model/Foo.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,10 +268,7 @@ public String toString() {
268268
* (except the first line).
269269
*/
270270
private String toIndentedString(Object o) {
271-
if (o == null) {
272-
return "null";
273-
}
274-
return o.toString().replace("\n", "\n ");
271+
return o == null ? "null" : o.toString().replace("\n", "\n ");
275272
}
276273

277274
/**

samples/client/petstore/java/restclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/Foo.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,7 @@ public String toString() {
278278
* (except the first line).
279279
*/
280280
private String toIndentedString(Object o) {
281-
if (o == null) {
282-
return "null";
283-
}
284-
return o.toString().replace("\n", "\n ");
281+
return o == null ? "null" : o.toString().replace("\n", "\n ");
285282
}
286283

287284
}

samples/client/petstore/java/resttemplate-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/Foo.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,7 @@ public String toString() {
278278
* (except the first line).
279279
*/
280280
private String toIndentedString(Object o) {
281-
if (o == null) {
282-
return "null";
283-
}
284-
return o.toString().replace("\n", "\n ");
281+
return o == null ? "null" : o.toString().replace("\n", "\n ");
285282
}
286283

287284
}

samples/client/petstore/java/webclient-springBoot4-jackson3-jspecify/src/main/java/org/openapitools/client/model/Foo.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,7 @@ public String toString() {
277277
* (except the first line).
278278
*/
279279
private String toIndentedString(Object o) {
280-
if (o == null) {
281-
return "null";
282-
}
283-
return o.toString().replace("\n", "\n ");
280+
return o == null ? "null" : o.toString().replace("\n", "\n ");
284281
}
285282

286283
}

samples/openapi3/server/petstore/springboot-4-jspecify/src/main/java/org/openapitools/model/Foo.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,7 @@ public String toString() {
278278
* (except the first line).
279279
*/
280280
private String toIndentedString(Object o) {
281-
if (o == null) {
282-
return "null";
283-
}
284-
return o.toString().replace("\n", "\n ");
281+
return o == null ? "null" : o.toString().replace("\n", "\n ");
285282
}
286283

287284
public static class Builder {

0 commit comments

Comments
 (0)