I have a Spring application where I exposed two rest interfaces for usage. One is internally for in-house developers the other one is for customers.
Swagger does generate a nice documentation reachable under /swagger-ui.html.
Under this URL it shows the documentation for both internal and external users.
Here is my Code setup:
import org.springframework.boot.info.BuildProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
public class Swagger2UiConfiguration extends WebMvcConfigurerAdapter {
@Bean(name="restInternalSwaggerApi")
public Docket internalApi(BuildProperties build) {
final Docket docket = new Docket(DocumentationType.SWAGGER_2)
.groupName( "internal" )
.select()
.apis( RequestHandlerSelectors.basePackage("com.xyz.web.internal") )
.build();
return docket;
}
@Bean(name="restPublicSwaggerApi")
public Docket publicApi(BuildProperties build) {
final Docket docket = new Docket(DocumentationType.SWAGGER_2)
.groupName( "public" )
.select()
.apis( RequestHandlerSelectors.basePackage("com.xyz.web.public") )
.build();
return docket;
}
}
Now, I want to separate these swagger-ui documentations. So that our internal developers access it like
/documentation/private/swagger-ui.html and
/documentation/public/api-v1.html
Both not seeing each other. How to do that?
I found some hints here, but they really were not constructive for me:
http://sp ingfox.github.io/springfox/docs/current/#q13 and linked resources
Customize endpoints of dockets with springfox Swagger
swagger multiple versions in path
https://github.com/springfox/springfox/issues/963
https://github.com/springfox/springfox/issues/1263#issuecomment-210839308
If someone would yield me to the proper documentation I would also be happy.
Let me know If the question is hard to understand and how to improve it.
for version infos on java's maven:
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
In other words:
I want the different APIs reached by the DropDown-Box to have called by different URLs:
I want this, so I can give a customer a different URL with a different API than to giving another URL to my developer colleagues.