I am having a Springboot application where I integrated Swagger for creating REST documentations.
When using swagger my startup time increases dramatically by factor 5. I'm having 30secs without swagger. 2min plus with swagger.
Also having the docket listed in the snipped underneath startup time becomes endlessly! - And this is a no-go.
My Problem is endless startup times + Exceptions regarding memory usage from google guava.
Why is it that way? What am I doing wrong? Where is the missing point? Why is the API not protecting me from very wrong setups?
It feels like that swagger is on the one hand a number one tool for documenting rest APIs but using it feels very ancient for me.
Some setup info (located at maven pom.xml):
- org.springframework.boot; spring-boot-starter-parent; 1.5.5.RELEASE
- io.springfox; springfox-swagger2; 2.9.2
- io.springfox; springfox-swagger-ui; 2.9.2
I somewhere picked up that googles guava library needs to be exchanged; which I did: https://github.com/springfox/springfox/issues/2616#issuecomment-412811912
Is swagger/springfox really so good to use for documenting an API coming from Spring? - What would be some alternatives to render documentation?
@Configuration
@EnableSwagger2
public class Swagger2UiConfiguration extends WebMvcConfigurerAdapter {
...
@Bean(name="restPublicSwaggerV1Api")
public Docket publicV1Api(BuildProperties build) {
final ApiInfoBuilder apiInfo = new ApiInfoBuilder()
.title(build.getName())
.description("Description for public API")
.version( build.getVersion() );
final long TIME = System.currentTimeMillis();
final Docket docket = new Docket(DocumentationType.SWAGGER_2)
.groupName( "public-v1" )
.apiInfo( apiInfo.build() )
.select()
.apis( (wmrh)->{ // springfox.documentation.spring.web.WebMvcRequestHandler
final StringBuffer sb = new StringBuffer();
sb.append( wmrh.getClass().getTypeName() +"\n\t"+ wmrh );
final RequestHandlerKey rhk = wmrh.key();
boolean result = false;
for( String pathMapping : rhk.getPathMappings() ) {
sb.append( "\n\t-> "+ pathMapping );
result |= pathMapping.startsWith( "/api/public/" );
}
sb.append( "\n\t=>> "+ result +", time: "+ Util.formatTime( System.currentTimeMillis() - TIME ) +" after start." );
LOG.debug( sb.toString() );
return result;
} )
.paths( (p)->{ return true; } )
.build();
LOG.debug( "instantiated: {}", docket );
return docket;
}