Java 17 / Spring 6 / Spring Boot 3 Upgrade
[policy/api.git] / main / src / main / java / org / onap / policy / api / main / config / WebConfig.java
index 88871f5..42e07d6 100644 (file)
@@ -1,6 +1,7 @@
 /*-
  * ============LICENSE_START=======================================================
- *  Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Copyright (C) 2022 Bell Canada. All rights reserved.
+ * Modifications Copyright (C) 2023 Nordix Foundation.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.policy.api.main.config;
 
-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;
@@ -31,9 +28,7 @@ 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.http.converter.json.GsonHttpMessageConverter;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-import springfox.documentation.spring.web.json.Json;
 
 /**
  * Register custom converters to Spring configuration.
@@ -48,24 +43,7 @@ public class WebConfig implements WebMvcConfigurer {
     @Override
     public void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
         var yamlConverter = new YamlHttpMessageConverter();
-        yamlConverter.setSupportedMediaTypes(Arrays.asList(MediaType.parseMediaType("application/yaml")));
+        yamlConverter.setSupportedMediaTypes(List.of(MediaType.parseMediaType("application/yaml")));
         converters.add(yamlConverter);
-
-        GsonHttpMessageConverter converter = buildGsonConverter();
-        converters.removeIf(GsonHttpMessageConverter.class::isInstance);
-        converters.add(0, converter);
-    }
-
-    /**
-     * Swagger uses {{@link springfox.documentation.spring.web.json.Json}} which leads to Gson serialization errors.
-     * Hence, we customize a typeAdapter on the Gson bean in the Gson http message converter.
-     *
-     * @return customised GSON HttpMessageConverter instance.
-     */
-    private GsonHttpMessageConverter buildGsonConverter() {
-        JsonSerializer<Json> serializer = (json, type, jsonSerializationContext) ->
-            JsonParser.parseString(json.value());
-        var gson = new GsonBuilder().registerTypeAdapter(Json.class, serializer).create();
-        return new GsonHttpMessageConverter(gson);
     }
-}
\ No newline at end of file
+}