我有一个项目与春季启动,我想用swagger2来记录我的JSON Web服务。Swagger 2接受XML而不是JSON
我有这样的配置:
@Configuration
@EnableSwagger2
public class Swagger2Config {
@Bean
public Docket welcomeMessageApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("My API")
.description("Lorem Ipsum is simply dummy text of ...")
.termsOfServiceUrl("an url")
.contact("contact")
.license("")
.licenseUrl("")
.version("2.0")
.build();
}
阅读文档,我用这个链接:http://localhost:9081/v2/api-docs
在招摇的用户界面,它工作正常。但是当我在浏览器中直接尝试此链接时,出现此错误:
使用Firebug,我发现它接受XML内容而不是JSON内容。
如何修改swagger配置以接受JSON内容?