mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 14:40:53 +00:00
Fixing missing openApiNullable config for java apache-httpclient generator (#14828)
* 14827 - fixing missing openApiNullable config for java apache-httpclient generator * 14827 - run PR steps updating examples & docs * 14827 - fixing test data
This commit is contained in:
parent
9705617f93
commit
d56a55a06b
@ -12,6 +12,9 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
|||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
{{#openApiNullable}}
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
|
{{/openApiNullable}}
|
||||||
|
|
||||||
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
||||||
import org.apache.hc.client5.http.cookie.Cookie;
|
import org.apache.hc.client5.http.cookie.Cookie;
|
||||||
@ -141,6 +144,9 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
|
|||||||
objectMapper.registerModule(new JodaModule());
|
objectMapper.registerModule(new JodaModule());
|
||||||
{{/joda}}
|
{{/joda}}
|
||||||
objectMapper.registerModule(new JavaTimeModule());
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
|
{{#openApiNullable}}
|
||||||
|
objectMapper.registerModule(new JsonNullableModule());
|
||||||
|
{{/openApiNullable}}
|
||||||
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
|
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
|
||||||
|
|
||||||
dateFormat = ApiClient.buildDefaultDateFormat();
|
dateFormat = ApiClient.buildDefaultDateFormat();
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
|||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
|
|
||||||
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
||||||
import org.apache.hc.client5.http.cookie.Cookie;
|
import org.apache.hc.client5.http.cookie.Cookie;
|
||||||
@ -116,6 +117,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
objectMapper.registerModule(new JavaTimeModule());
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
|
objectMapper.registerModule(new JsonNullableModule());
|
||||||
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
|
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
|
||||||
|
|
||||||
dateFormat = ApiClient.buildDefaultDateFormat();
|
dateFormat = ApiClient.buildDefaultDateFormat();
|
||||||
|
@ -220,7 +220,7 @@ public class CustomTest {
|
|||||||
Assert.assertNull(d.getArrayStringNullable());
|
Assert.assertNull(d.getArrayStringNullable());
|
||||||
Assert.assertEquals(d.getArrayString().size(), 0);
|
Assert.assertEquals(d.getArrayString().size(), 0);
|
||||||
|
|
||||||
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_ref_default\":[\"success\",\"failure\"],\"array_string_enum_default\":[\"success\",\"failure\"],\"array_string_default\":[\"failure\",\"skipped\"],\"array_integer_default\":[1,3],\"array_string\":[],\"array_string_nullable\":{\"present\":false},\"array_string_extension_nullable\":{\"present\":false},\"string_nullable\":{\"present\":false}}");
|
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_ref_default\":[\"success\",\"failure\"],\"array_string_enum_default\":[\"success\",\"failure\"],\"array_string_default\":[\"failure\",\"skipped\"],\"array_integer_default\":[1,3],\"array_string\":[]}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -248,7 +248,7 @@ public class CustomTest {
|
|||||||
Assert.assertNull(d.getArrayStringNullable());
|
Assert.assertNull(d.getArrayStringNullable());
|
||||||
Assert.assertEquals(d.getArrayString().size(), 0);
|
Assert.assertEquals(d.getArrayString().size(), 0);
|
||||||
|
|
||||||
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_ref_default\":[\"unclassified\"],\"array_string_enum_default\":[\"unclassified\"],\"array_string_default\":[\"failure\"],\"array_integer_default\":[1,3],\"array_string\":[],\"array_string_nullable\":{\"present\":false},\"array_string_extension_nullable\":{\"present\":false},\"string_nullable\":{\"present\":false}}");
|
Assert.assertEquals(apiClient.getObjectMapper().writeValueAsString(d), "{\"array_string_enum_ref_default\":[\"unclassified\"],\"array_string_enum_default\":[\"unclassified\"],\"array_string_default\":[\"failure\"],\"array_integer_default\":[1,3],\"array_string\":[]}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -20,6 +20,7 @@ import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
|||||||
import com.fasterxml.jackson.core.type.TypeReference;
|
import com.fasterxml.jackson.core.type.TypeReference;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.JavaType;
|
import com.fasterxml.jackson.databind.JavaType;
|
||||||
|
import org.openapitools.jackson.nullable.JsonNullableModule;
|
||||||
|
|
||||||
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
import org.apache.hc.client5.http.cookie.BasicCookieStore;
|
||||||
import org.apache.hc.client5.http.cookie.Cookie;
|
import org.apache.hc.client5.http.cookie.Cookie;
|
||||||
@ -163,6 +164,7 @@ public class ApiClient extends JavaTimeFormatter {
|
|||||||
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
objectMapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||||
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
objectMapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||||
objectMapper.registerModule(new JavaTimeModule());
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
|
objectMapper.registerModule(new JsonNullableModule());
|
||||||
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
|
objectMapper.setDateFormat(ApiClient.buildDefaultDateFormat());
|
||||||
|
|
||||||
dateFormat = ApiClient.buildDefaultDateFormat();
|
dateFormat = ApiClient.buildDefaultDateFormat();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user