use of com.google.api.server.spi.config.annotationreader.ApiAnnotationIntrospector in project endpoints-java by cloudendpoints.
the class ObjectMapperUtil method createStandardObjectMapper.
/**
* Creates an Endpoints standard object mapper that allows unquoted field names and unknown
* properties.
*
* Note on unknown properties: When Apiary FE supports a strict mode where properties
* are checked against the schema, BE can just ignore unknown properties. This way, FE does
* not need to filter out everything that the BE doesn't understand. Before that's done,
* a property name with a typo in it, for example, will just be ignored by the BE.
*/
public static ObjectMapper createStandardObjectMapper(ApiSerializationConfig config) {
ObjectMapper objectMapper = new ObjectMapper().configure(JsonParser.Feature.ALLOW_COMMENTS, true).configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true).configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).setBase64Variant(Base64Variants.MODIFIED_FOR_URL).setSerializerFactory(BeanSerializerFactory.instance.withSerializerModifier(new DeepEmptyCheckingModifier()));
AnnotationIntrospector pair = EndpointsFlag.JSON_USE_JACKSON_ANNOTATIONS.isEnabled() ? AnnotationIntrospector.pair(new ApiAnnotationIntrospector(config), new JacksonAnnotationIntrospector()) : new ApiAnnotationIntrospector(config);
objectMapper.setAnnotationIntrospector(pair);
return objectMapper;
}
Aggregations