package org.onap.policy.api.main.config;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonSerializer;
import java.util.Arrays;
import java.util.List;
import org.onap.policy.api.main.config.converter.StringToEnumConverter;
import org.onap.policy.common.spring.utils.YamlHttpMessageConverter;
-import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-import springfox.documentation.spring.web.json.Json;
/**
* Register custom converters to Spring configuration.
yamlConverter.setSupportedMediaTypes(Arrays.asList(MediaType.parseMediaType("application/yaml")));
converters.add(yamlConverter);
}
-
- /**
- * Swagger uses {{@link springfox.documentation.spring.web.json.Json}} which leads to Gson serialization errors.
- * Hence, we customize a typeAdapter on the Gson bean.
- *
- * @return customised GSON instance.
- */
- @Bean
- public Gson gson() {
- GsonBuilder gsonBuilder = new GsonBuilder();
- JsonSerializer<Json> serializer =
- (json, type, jsonSerializationContext) -> JsonParser.parseString(json.value());
- gsonBuilder.registerTypeAdapter(Json.class, serializer);
- return gsonBuilder.create();
- }
-}
\ No newline at end of file
+}