-
-
Notifications
You must be signed in to change notification settings - Fork 559
Closed
Description
Hi @springdoc,
I'm migrating an existing Spring boot 2 project with SpringFox and i doesn't found an equivalent of this code below:
@Bean
public OpenAPI customImplementation(final ServletContext servletContext, @Value("${openapi.app.base-path:/api/v1}") final String basePath) {
return new OpenAPI(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage(DOC_PACKAGE_NAME))
.build()
.pathProvider(new BasePathAwareRelativePathProvider(servletContext, basePath))
.directModelSubstitute(java.time.LocalDate.class, java.sql.Date.class)
.directModelSubstitute(java.time.OffsetDateTime.class, java.util.Date.class)
.apiInfo(this.apiInfo())
.enable(this.appProperties.getSwagger());
}
static class BasePathAwareRelativePathProvider extends RelativePathProvider {
private final String basePath;
BasePathAwareRelativePathProvider(final ServletContext servletContext, final String basePath) {
super(servletContext);
this.basePath = basePath;
}
@Override
protected String applicationPath() {
return Paths.removeAdjacentForwardSlashes(UriComponentsBuilder.fromPath(super.applicationPath()).path(this.basePath).build().toString());
}
@Override
public String getOperationPath(final String operationPath) {
final UriComponentsBuilder uriComponentsBuilder = UriComponentsBuilder.fromPath("/");
return Paths.removeAdjacentForwardSlashes(
uriComponentsBuilder.path(operationPath.replaceFirst("^" + this.basePath, "")).build().toString());
}
}I read the hole tests and doc of the project before opening this issue.
Thanks for this great project :)
filomat
Metadata
Metadata
Assignees
Labels
No labels