Search in sources :

Example 1 with JaxbAnnotationModule

use of com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule in project ORCID-Source by ORCID.

the class PublicSwaggerResource method scan.

/**
 * Scan the classes and add in the OAuth information
 */
@Override
protected synchronized Swagger scan(Application app) {
    // tell swagger to pick up our jaxb annotations
    Json.mapper().registerModule(new JaxbAnnotationModule());
    Swagger s = super.scan(app);
    OAuth2Definition oauthTwoLegs = new OAuth2Definition();
    oauthTwoLegs.application(this.tokenEndPoint);
    oauthTwoLegs.scope(ScopePathType.READ_PUBLIC.value(), "Read Public record");
    s.securityDefinition("orcid_two_legs", oauthTwoLegs);
    return s;
}
Also used : JaxbAnnotationModule(com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule) Swagger(io.swagger.models.Swagger) OAuth2Definition(io.swagger.models.auth.OAuth2Definition)

Example 2 with JaxbAnnotationModule

use of com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule in project fabric8 by fabric8io.

the class JsonSchemaLookup method init.

public void init() {
    LOG.log(Level.INFO, "Creating JsonSchemaLookup instance");
    try {
        if (mapper == null) {
            mapper = new ObjectMapper();
            mapper.setVisibility(new IgnorePropertiesBackedByTransientFields(mapper.getVisibilityChecker()));
            JaxbAnnotationModule module1 = new JaxbAnnotationModule();
            mapper.registerModule(module1);
            BeanValidationAnnotationModule module2 = new BeanValidationAnnotationModule();
            mapper.registerModule(module2);
        }
        // now lets expose the mbean...
        singleton = this;
    } catch (Exception e) {
        LOG.log(Level.WARNING, "Exception during initialization: ", e);
        throw new RuntimeException(e);
    }
}
Also used : JaxbAnnotationModule(com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with JaxbAnnotationModule

use of com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule in project swagger-core by swagger-api.

the class JaxbObjectMapperFactory method getMapper.

public static ObjectMapper getMapper() {
    ObjectMapper mapper = ObjectMapperFactory.createJson();
    mapper.registerModule(new JaxbAnnotationModule());
    return mapper;
}
Also used : JaxbAnnotationModule(com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with JaxbAnnotationModule

use of com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule in project mycore by MyCoRe-Org.

the class MCRJobQueueResource method toJSON.

private <T> String toJSON(T entity) throws IOException {
    StringWriter sw = new StringWriter();
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JaxbAnnotationModule());
    mapper.writeValue(sw, entity);
    return sw.toString();
}
Also used : JaxbAnnotationModule(com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule) StringWriter(java.io.StringWriter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with JaxbAnnotationModule

use of com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule in project CFLint by cflint.

the class ConfigUtils method unmarshalJson.

public static <E> E unmarshalJson(final InputStream inputStream, final Class<E> expectedClass) throws IOException {
    final ObjectMapper objectMapper = new ObjectMapper();
    final JaxbAnnotationModule module = new JaxbAnnotationModule();
    objectMapper.registerModule(module);
    // mapper.setAnnotationIntrospector(introspector);
    return objectMapper.readValue(inputStream, expectedClass);
}
Also used : JaxbAnnotationModule(com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JaxbAnnotationModule (com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule)16 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)11 StringWriter (java.io.StringWriter)3 JsonInclude (com.fasterxml.jackson.annotation.JsonInclude)2 DeserializationFeature (com.fasterxml.jackson.databind.DeserializationFeature)2 MapperFeature (com.fasterxml.jackson.databind.MapperFeature)2 Module (com.fasterxml.jackson.databind.Module)2 SerializationFeature (com.fasterxml.jackson.databind.SerializationFeature)2 Swagger (io.swagger.models.Swagger)2 OAuth2Definition (io.swagger.models.auth.OAuth2Definition)2 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 XmlMapper (com.fasterxml.jackson.dataformat.xml.XmlMapper)1 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)1 AfterburnerModule (com.fasterxml.jackson.module.afterburner.AfterburnerModule)1 IOException (java.io.IOException)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 HelloRequestType (org.openecard.ws.chipgateway.HelloRequestType)1 Test (org.testng.annotations.Test)1