Change artifactId in sal-rest-docgen
[netconf.git] / restconf / restconf-openapi / src / main / java / org / opendaylight / netconf / sal / rest / doc / jaxrs / JaxbContextResolver.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.netconf.sal.rest.doc.jaxrs;
9
10 import com.fasterxml.jackson.databind.ObjectMapper;
11 import javax.ws.rs.Consumes;
12 import javax.ws.rs.Produces;
13 import javax.ws.rs.core.MediaType;
14 import javax.ws.rs.ext.ContextResolver;
15 import javax.ws.rs.ext.Provider;
16 import org.opendaylight.netconf.sal.rest.doc.openapi.OpenApiObject;
17
18 @Provider
19 @Consumes(MediaType.APPLICATION_JSON)
20 @Produces(MediaType.APPLICATION_JSON)
21 public class JaxbContextResolver implements ContextResolver<ObjectMapper> {
22
23     private static final ObjectMapper CTX = new ObjectMapper();
24
25     @Override
26     public ObjectMapper getContext(final Class<?> klass) {
27         if (OpenApiObject.class.isAssignableFrom(klass)) {
28             return CTX;
29         }
30
31         return null; // must return null so that JAX-RS can continue context search
32     }
33 }