Skip to content

Commit 4171473

Browse files
authored
Merge branch 'main' into chore/0.18.1-snapshot-exampleobject-fix
2 parents 2fdbe37 + fb065ce commit 4171473

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,14 @@ It currently consists of
1616
# Release Notes
1717
BOAT is still under development and subject to change.
1818

19-
## 0.18.1
19+
## 0.18.2
2020
* Spring generator: fixed `@ExampleObject` rendering in `api.mustache` by unwrapping escaped quotes in example payloads.
2121
* Added `unwrapEscapedQuotes` lambda to `boat-spring` generator templates to prevent malformed annotation values (for example `value = "\"{...}"`).
2222
* Added a regression test to verify generated Spring API interfaces include valid `@ExampleObject` annotation values and remain parseable Java code.
2323

24+
## 0.18.1
25+
* Use Jackson3 imports in `BigDecimalCustomSerializer.class` when using `useJackson3` set to `true`
26+
2427
## 0.18.0
2528
* openapi-generator `7.20.0` baseline (Spring Boot 4, Jackson 3)
2629
* moved Java and JavaSpring templates to `7.20.0` adding remaing custom features

boat-scaffold/src/main/java/com/backbase/oss/codegen/java/BoatSpringCodeGen.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public class BoatSpringCodeGen extends SpringCodegen {
5151
public static final String UNWRAP_ESCAPED_QUOTES = "unwrapEscapedQuotes";
5252

5353
private static final String VENDOR_EXTENSION_NOT_NULL = "x-not-null";
54+
private static final String JSON_SERIALIZE = "JsonSerialize";
5455

5556
static class NewLineIndent implements Mustache.Lambda {
5657

@@ -224,8 +225,8 @@ public CodegenProperty fromProperty(String name, Schema p, boolean required, boo
224225
}
225226

226227
/**
227-
* "overridden" to fix invalid code when the data type is a collection of a fully qualified classname.
228-
* eg. <code>Set<@Valid com.backbase.dbs.arrangement.commons.model.TranslationItemDto></code>
228+
* "overridden" to fix invalid code when the data type is a collection of a fully qualified classname. eg. <code>Set<@Valid
229+
* com.backbase.dbs.arrangement.commons.model.TranslationItemDto></code>
229230
*
230231
* @param itemsProperty
231232
* @param dataType
@@ -332,7 +333,12 @@ public void processOpts() {
332333
serializerTemplate + ".java"
333334
));
334335
this.importMapping.put(serializerTemplate, modelPackage + "." + serializerTemplate);
335-
this.importMapping.put("JsonSerialize", "com.fasterxml.jackson.databind.annotation.JsonSerialize");
336+
337+
if (this.additionalProperties.containsKey(USE_JACKSON_3)) {
338+
this.importMapping.put(JSON_SERIALIZE, "tools.jackson.databind.annotation.JsonSerialize");
339+
} else {
340+
this.importMapping.put(JSON_SERIALIZE, "com.fasterxml.jackson.databind.annotation.JsonSerialize");
341+
}
336342

337343
if (this.additionalProperties.containsKey(ADD_SERVLET_REQUEST)) {
338344
this.addServletRequest = convertPropertyToBoolean(ADD_SERVLET_REQUEST);
@@ -405,7 +411,7 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
405411
if (shouldSerializeBigDecimalAsString(property)) {
406412
property.vendorExtensions.put("x-extra-annotation", "@JsonSerialize(using = BigDecimalCustomSerializer.class)");
407413
model.imports.add("BigDecimalCustomSerializer");
408-
model.imports.add("JsonSerialize");
414+
model.imports.add(JSON_SERIALIZE);
409415
}
410416
}
411417

boat-scaffold/src/main/templates/boat-spring/BigDecimalCustomSerializer.mustache

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
package {{modelPackage}};
22

3-
import com.fasterxml.jackson.databind.ser.std.ToStringSerializerBase;
3+
{{#useJackson3}}
4+
import tools.jackson.databind.ser.std.ToStringSerializerBase;
5+
{{/useJackson3}}
6+
{{^useJackson3}}
7+
import com.fasterxml.jackson.databind.ser.std.ToStringSerializerBase;
8+
{{/useJackson3}}
49
import java.math.BigDecimal;
510

611
public class BigDecimalCustomSerializer extends ToStringSerializerBase {

0 commit comments

Comments
 (0)