mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-05 03:26:12 +00:00
Disable Jackson FAIL_ON_INVALID_SUBTYPE in feign (#5597)
* Disable Jackson FAIL_ON_INVALID_SUBTYPE in feign With this change, Jackson does not fail even if it doesn't recognize a discriminator type name. This is helpful when upgrading a microservice with a new subtype while keeping compatibility with its old clients. The instance is returned as null instead of throwing an exception deep in the feign framework, allowing clients to gracefully degrade. * Disable FAIL_ON_INVALID_SUBTYPE for all Jackson-based projects
This commit is contained in:
committed by
wing328
parent
de427297ec
commit
be3cfda3ce
@@ -16,6 +16,7 @@ public class JSON implements ContextResolver<ObjectMapper> {
|
||||
mapper = new ObjectMapper();
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false);
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
|
||||
mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
|
||||
|
||||
@@ -9,7 +9,7 @@ public class ConfigurationTest {
|
||||
public void testDefaultApiClient() {
|
||||
ApiClient apiClient = Configuration.getDefaultApiClient();
|
||||
assertNotNull(apiClient);
|
||||
assertEquals("http://petstore.swagger.io/v2", apiClient.getBasePath());
|
||||
assertEquals("http://petstore.swagger.io:80/v2", apiClient.getBasePath());
|
||||
assertFalse(apiClient.isDebugging());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PetApiTest {
|
||||
// the default api client is used
|
||||
assertEquals(Configuration.getDefaultApiClient(), api.getApiClient());
|
||||
assertNotNull(api.getApiClient());
|
||||
assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath());
|
||||
assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath());
|
||||
assertFalse(api.getApiClient().isDebugging());
|
||||
|
||||
ApiClient oldClient = api.getApiClient();
|
||||
@@ -54,7 +54,7 @@ public class PetApiTest {
|
||||
// set api client via setter method
|
||||
api.setApiClient(oldClient);
|
||||
assertNotNull(api.getApiClient());
|
||||
assertEquals("http://petstore.swagger.io/v2", api.getApiClient().getBasePath());
|
||||
assertEquals("http://petstore.swagger.io:80/v2", api.getApiClient().getBasePath());
|
||||
assertFalse(api.getApiClient().isDebugging());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user