-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[Java][client] make it possible to send explicit nulls for nullable fields #3474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| {{! | ||
| If this is map and items are nullable, make sure that nulls are included. | ||
| To determine what JsonInclude.Include method to use, consider the following: | ||
| * If the field is required, always include it, even if it is null. | ||
| * Else use custom behaviour, IOW use whatever is defined on the object mapper | ||
| }} | ||
| @JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}}) | ||
| @JsonInclude({{#isMapContainer}}{{#items.isNullable}}content = JsonInclude.Include.ALWAYS, {{/items.isNullable}}{{/isMapContainer}}value = JsonInclude.Include.{{#required}}ALWAYS{{/required}}{{^required}}USE_DEFAULTS{{/required}}) | ||
| {{#withXml}} | ||
| {{^isContainer}} | ||
| @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#xmlName}}{{xmlName}}{{/xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") | ||
| {{/isContainer}} | ||
| {{#isContainer}} | ||
| {{#isXmlWrapped}} | ||
| // items.xmlName={{items.xmlName}} | ||
| @JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{xmlNamespace}}", {{/xmlNamespace}}localName = "{{#items.xmlName}}{{items.xmlName}}{{/items.xmlName}}{{^items.xmlName}}{{items.baseName}}{{/items.xmlName}}") | ||
| {{/isXmlWrapped}} | ||
| {{/isContainer}} | ||
| {{/withXml}} |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import {{apiPackage}}.*; | |
| import com.fasterxml.jackson.databind.DeserializationFeature; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.fasterxml.jackson.databind.SerializationFeature; | ||
| import org.openapitools.jackson.nullable.JsonNullableModule; | ||
| {{#joda}} | ||
| import com.fasterxml.jackson.datatype.joda.JodaModule; | ||
| {{/joda}} | ||
|
|
@@ -53,6 +54,8 @@ public class ApiClient { | |
| module.addDeserializer(ZonedDateTime.class, CustomInstantDeserializer.ZONED_DATE_TIME); | ||
| objectMapper.registerModule(module); | ||
| {{/threetenbp}} | ||
| JsonNullableModule jnm = new JsonNullableModule(); | ||
|
||
| objectMapper.registerModule(jnm); | ||
| return objectMapper; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.