Skip to content

Commit 637ba3b

Browse files
committed
Ensure @JsonSerialize and @JsonDeserialize is only generated when Jackson enabled
Fixes #6496
1 parent b725960 commit 637ba3b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,7 +1779,7 @@ private void addAdditionalImports(CodegenModel model, CodegenComposedSchemas com
17791779

17801780
@Override
17811781
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
1782-
if (serializeBigDecimalAsString) {
1782+
if (serializeBigDecimalAsString && additionalProperties.containsKey(JACKSON)) {
17831783
if ("decimal".equals(property.baseType) || "bigdecimal".equalsIgnoreCase(property.baseType)) {
17841784
// we serialize BigDecimal as `string` to avoid precision loss
17851785
property.vendorExtensions.put("x-extra-annotation", "@JsonSerialize(using = ToStringSerializer.class)");
@@ -1804,7 +1804,7 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
18041804
model.imports.add("Arrays");
18051805
} else if ("set".equals(property.containerType)) {
18061806
model.imports.add("LinkedHashSet");
1807-
if (!openApiNullable || !property.isNullable) { // cannot be wrapped to nullable
1807+
if ((!openApiNullable || !property.isNullable) && additionalProperties.containsKey(JACKSON)) { // cannot be wrapped to nullable
18081808
model.imports.add("JsonDeserialize");
18091809
property.vendorExtensions.put("x-setter-extra-annotation", "@JsonDeserialize(as = LinkedHashSet.class)");
18101810
}

0 commit comments

Comments
 (0)