-
Notifications
You must be signed in to change notification settings - Fork 173
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
chore(swagger): Upgrade SpringFox and Swagger #827
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,13 +16,10 @@ | |
|
||
package com.netflix.spinnaker.config; | ||
|
||
import static com.google.common.base.Predicates.or; | ||
|
||
import com.google.common.base.Predicate; | ||
import com.google.common.collect.ImmutableList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
import java.util.stream.Collectors; | ||
import java.util.function.Predicate; | ||
import javax.annotation.Nullable; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
@@ -32,11 +29,9 @@ | |
import springfox.documentation.builders.RequestHandlerSelectors; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.paths.AbstractPathProvider; | ||
import springfox.documentation.spring.web.paths.DefaultPathProvider; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
@EnableSwagger2 | ||
@Configuration | ||
@ConditionalOnProperty("swagger.enabled") | ||
@ConfigurationProperties(prefix = "swagger") | ||
|
@@ -80,7 +75,7 @@ private static Class<?> getClassIfPresent(String name) { | |
} | ||
|
||
private Predicate<String> paths() { | ||
return or(patterns.stream().map(PathSelectors::regex).collect(Collectors.toList())); | ||
return patterns.stream().map(PathSelectors::regex).reduce(x -> false, Predicate::or); | ||
} | ||
|
||
private ApiInfo apiInfo() { | ||
|
@@ -123,7 +118,8 @@ public String getDocumentationPath() { | |
return documentationPath; | ||
} | ||
|
||
public class BasePathProvider extends AbstractPathProvider { | ||
// TODO: make sure this works given https://github.com/springfox/springfox/issues/3493 | ||
public class BasePathProvider extends DefaultPathProvider { | ||
private String basePath; | ||
private String documentationPath; | ||
|
||
|
@@ -133,13 +129,13 @@ private BasePathProvider(String basePath, String documentationPath) { | |
} | ||
|
||
@Override | ||
protected String applicationPath() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They deprecated |
||
return basePath; | ||
public String getOperationPath(String operationPath) { | ||
return documentationPath + "/" + super.getOperationPath(operationPath); | ||
} | ||
|
||
@Override | ||
protected String getDocumentationPath() { | ||
return documentationPath; | ||
public String getResourceListingPath(String groupName, String apiDeclaration) { | ||
return documentationPath + "/" + super.getResourceListingPath(groupName, apiDeclaration); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,8 +25,8 @@ ext { | |
spring : "5.2.9.RELEASE", // this should be kept in sync with spring-boot / removed once the need for a version override is gone | ||
springBoot : "2.2.5.RELEASE", | ||
springCloud : "Hoxton.SR4", | ||
springfoxSwagger : "2.9.2", | ||
swagger : "1.5.20" //this should stay in sync with what springfoxSwagger expects | ||
springfoxSwagger : "3.0.0", | ||
swagger : "2.1.2" //this should stay in sync with what springfoxSwagger expects | ||
] | ||
} | ||
|
||
|
@@ -127,7 +127,7 @@ dependencies { | |
api("io.mockk:mockk:1.10.0") | ||
api("io.springfox:springfox-swagger-ui:${versions.springfoxSwagger}") | ||
api("io.springfox:springfox-swagger2:${versions.springfoxSwagger}") | ||
api("io.swagger:swagger-annotations:${versions.swagger}") | ||
api("io.swagger.core.v3:swagger-annotations:${versions.swagger}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This may break services using annotations, I'm not sure yet. Second thing to verify. SpringFox uses different deps for v2 and v3: https://github.com/springfox/springfox/blob/9722b7e3a41208bc3e7c0409aa3e63fc27a66f52/gradle/dependencies.gradle#L61-L68 |
||
api("javax.annotation:javax.annotation-api:1.3.2") | ||
api("javax.xml.bind:jaxb-api:2.3.1") | ||
api("mysql:mysql-connector-java:8.0.20") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Following the (very light on detail) migration instructions here: https://github.com/springfox/springfox#migrating-from-existing-2x-version