我遇到过同样的问题 . 我通过改变Docket创建参数来解决它 . 我在用
@Bean
public Docket oAuthService() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.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(newArrayList(apiKey()))
.securityContexts(newArrayList(securityContext()))
.enableUrlTemplating(true)
.tags(new Tag("Oauth Service", "Oauth Service"));
}
这导致所有spring-oauth endpoints 成为我的swagger规范的一部分 . 我更改了注册的api以使用我的basePackage而不是any() . 像这样的东西:
.apis(RequestHandlerSelectors.basePackage("my.base.package.name"))