Hi, I am trying out swagger2 with springboot 1.1.5. I got json end point working but I can't get swagger-ui.html endpoint working. Not sure what is underlaying issue here. Here is my swagger config file.
@EnableSwagger2 //Enable swagger 2.0 spec
//There is no @configuration here, even though it works, well at least json
public class SwaggerConfig {
@Autowired
private TypeResolver typeResolver;
@bean
public Docket dataResourceAPI() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("xAPI")
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(commonAPIPaths())
.build()
.pathMapping("/")
.directModelSubstitute(LocalDate.class, String.class)
.genericModelSubstitutes(ResponseEntity.class)
.alternateTypeRules(
newRule(typeResolver.resolve(DeferredResult.class,
typeResolver.resolve(ResponseEntity.class, WildcardType.class)),
typeResolver.resolve(WildcardType.class)))
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET,
newArrayList(new ResponseMessageBuilder()
.code(500)
.message("500 message")
.responseModel(new ModelRef("Error"))
.build()));
//.securitySchemes()
//.securityContexts();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("REST API")
.description("swagger")
.termsOfServiceUrl("asdafsd")
.contact("abcd.com")
.license("License Version 2.0")
.licenseUrl("https://comming/soon/LICENSE")
.version("2.0")
.build();
}
private Predicate commonAPIPaths() {
return or(
regex("/v1/api/."),
regex("/v2/api/.")
);
}
}
My main Application class is:
@componentscan(basePackages = "com.x.y")
@EnableAutoConfiguration(exclude = { EmbeddedServletContainerFactory.class })
@configuration
@EnableWebMvc
@EnableAsync
@EnableSwagger2
@ImportResource(value = { "classpath:springmvc-resteasy.xml" })
public class Application implements AsyncConfigurer, DisposableBean {
...
}
There is one more additional config class:
@configuration
public class AdditionalConfig extends WebMvcConfigurerAdapter {
@OverRide
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
//converters.add(ScalaObjectMapper);
super.configureMessageConverters(converters);
converters.add(customJackson2HttpMessageConverter());
}
}