2 * Copyright © 2021 Orange, 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.transportpce.pce.gnpy.consumer;
10 import com.fasterxml.jackson.annotation.JsonInclude;
11 import com.fasterxml.jackson.databind.DeserializationFeature;
12 import com.fasterxml.jackson.databind.ObjectMapper;
13 import com.fasterxml.jackson.databind.SerializationFeature;
14 import javax.ws.rs.ext.ContextResolver;
15 import org.opendaylight.transportpce.common.converter.JsonStringConverter;
16 import org.opendaylight.yang.gen.v1.gnpy.gnpy.api.rev220221.Request;
17 import org.opendaylight.yang.gen.v1.gnpy.path.rev220221.Result;
19 public class JsonConfigurator implements ContextResolver<ObjectMapper> {
21 private final ObjectMapper mapper;
23 public JsonConfigurator(JsonStringConverter<Request> requestConverter,
24 JsonStringConverter<Result> resultConverter) {
25 mapper = new ObjectMapper();
26 mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
27 mapper.enable(SerializationFeature.INDENT_OUTPUT);
28 mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
29 mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
30 mapper.registerModule(new GnpyApiModule(requestConverter, resultConverter));
34 public ObjectMapper getContext(Class<?> type) {