2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.netconf.sal.rest.doc.jaxrs;
10 import com.fasterxml.jackson.annotation.JsonInclude;
11 import com.fasterxml.jackson.databind.ObjectMapper;
12 import com.fasterxml.jackson.datatype.jsonorg.JsonOrgModule;
13 import javax.ws.rs.Consumes;
14 import javax.ws.rs.Produces;
15 import javax.ws.rs.core.MediaType;
16 import javax.ws.rs.ext.ContextResolver;
17 import javax.ws.rs.ext.Provider;
18 import org.opendaylight.netconf.sal.rest.doc.swagger.ApiDeclaration;
21 @Consumes(MediaType.APPLICATION_JSON)
22 @Produces(MediaType.APPLICATION_JSON)
23 public class JaxbContextResolver implements ContextResolver<ObjectMapper> {
25 private final ObjectMapper ctx;
27 public JaxbContextResolver() {
28 ctx = new ObjectMapper();
29 ctx.registerModule(new JsonOrgModule());
30 ctx.getSerializationConfig().withSerializationInclusion(JsonInclude.Include.ALWAYS);
34 public ObjectMapper getContext(final Class<?> klass) {
35 if (ApiDeclaration.class.isAssignableFrom(klass)) {
39 return null; // must return null so that JAX-RS can continue context search