mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-15 15:54:17 +00:00
Ignore null fields in model serialization
in Java clients. Closes #1413
This commit is contained in:
@@ -12,12 +12,13 @@ public class JSON {
|
||||
|
||||
public JSON() {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
mapper.registerModule(new JodaModule());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize the given Java object into JSON string.
|
||||
|
||||
@@ -23,10 +23,9 @@ public class JSON {
|
||||
public JSON(ApiClient apiClient) {
|
||||
this.apiClient = apiClient;
|
||||
gson = new GsonBuilder()
|
||||
.serializeNulls()
|
||||
.registerTypeAdapter(Date.class, new DateAdapter(apiClient))
|
||||
.create();
|
||||
}
|
||||
}
|
||||
|
||||
public Gson getGson() {
|
||||
return gson;
|
||||
|
||||
Reference in New Issue
Block a user