Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OP-21771: springboot3 upgrade aftereffects swagger failed so migrating from SpringFox to SpringDoc. #120

Merged
merged 1 commit into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions kork-swagger/kork-swagger.gradle
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
apply plugin: "java-library"

dependencies {
api(platform(project(":spinnaker-dependencies")))

api 'io.swagger.core.v3:swagger-annotations:2.2.8'

implementation "com.google.guava:guava"
implementation "org.springframework.boot:spring-boot-autoconfigure"
// implementation 'io.springfox:springfox-swagger2:3.0.0'
// implementation 'io.springfox:springfox-swagger-ui:3.0.0'
implementation "io.springfox:springfox-boot-starter:3.0.0"

api('org.springdoc:springdoc-openapi-starter-webmvc-ui')
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright 2024 OpsMx.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.netflix.spinnaker.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration;

import java.util.List;

/**
* OP-21771:
* This configuration helps to decode the base64 response of /v3/api-docs and makes Swagger UI load the API docs properly. *
*
* At the service(child services to Kork) level, while registering converters, somehow the ordering of HttpMessageConverters is getting disturbed.
* This configuration aligns it properly and there by fix decoding issue of swagger responses.
*
* ref docs: https://github.com/springdoc/springdoc.github.io/issues/52
*/
@Configuration
public class ApiWebMvcConfiguration extends DelegatingWebMvcConfiguration {

@Autowired
Jackson2ObjectMapperBuilder jacksonBuilder;

@Override
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
var applicationContext = this.getApplicationContext();
if (applicationContext != null) {
jacksonBuilder.applicationContext(applicationContext);
}
converters.add(new ByteArrayHttpMessageConverter());
converters.add(new MappingJackson2HttpMessageConverter(jacksonBuilder.build()));
}
}

This file was deleted.

5 changes: 2 additions & 3 deletions spinnaker-dependencies/spinnaker-dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ext {
spek2 : "2.0.9",
springBoot : "3.0.9",
springCloud : "2022.0.2",
springfoxSwagger : "3.0.0",
springdocVersion : "2.0.3",

// Spring boot 2.4.13 brings in 9.0.55. Spring boot 2.5.14 brings in
// 9.0.63. Use 9.0.69 to resolve CVE-2022-42252 and CVE-2022-45143. Spring
Expand Down Expand Up @@ -111,8 +111,6 @@ dependencies {
api("com.netflix.spectator:spectator-reg-micrometer:${versions.spectator}")
api("mysql:mysql-connector-java:8.0.28")

api ("io.springfox:springfox-boot-starter:3.0.0")

constraints{
api("org.yaml:snakeyaml:2.0")
api("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.15.0")
Expand Down Expand Up @@ -145,5 +143,6 @@ dependencies {
api("io.projectreactor.netty:reactor-netty-http:1.1.13")
api("com.jayway.jsonpath:json-path:2.9.0")
api("org.springframework:spring-webmvc:6.0.14")
api("org.springdoc:springdoc-openapi-starter-webmvc-ui:${versions.springdocVersion}")
}
}
Loading