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 javax.ws.rs.Consumes;
13 import javax.ws.rs.Produces;
14 import javax.ws.rs.core.MediaType;
15 import javax.ws.rs.ext.ContextResolver;
16 import javax.ws.rs.ext.Provider;
17 import org.opendaylight.netconf.sal.rest.doc.swagger.ApiDeclaration;
20 @Consumes(MediaType.APPLICATION_JSON)
21 @Produces(MediaType.APPLICATION_JSON)
22 public class JaxbContextResolver implements ContextResolver<ObjectMapper> {
24 private final ObjectMapper ctx;
26 public JaxbContextResolver() {
27 ctx = new ObjectMapper();
28 ctx.getSerializationConfig().withSerializationInclusion(JsonInclude.Include.ALWAYS);
32 public ObjectMapper getContext(final Class<?> klass) {
33 if (ApiDeclaration.class.isAssignableFrom(klass)) {
37 return null; // must return null so that JAX-RS can continue context search