Skip to content

Commit

Permalink
fix(java): Update to use JsonMapper (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
booniepepper committed Sep 6, 2023
1 parent bea9236 commit 577a7f8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions config/clients/java/template/libraries/native/JSON.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package {{invokerPackage}};

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.json.JsonMapper;
{{#openApiNullable}}
import org.openapitools.jackson.nullable.JsonNullableModule;
{{/openApiNullable}}
Expand All @@ -24,11 +25,12 @@ public class JSON {
private ObjectMapper mapper;
public JSON() {
mapper = new ObjectMapper();
mapper = JsonMapper.builder()
.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false)
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true)
.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true)
.build();
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, false);
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, true);
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
Expand Down

0 comments on commit 577a7f8

Please sign in to comment.