如何避免一般的 Swagger 警告?

How to avoid general Swagger Warnings?

我将在 http://editor.swagger.io/#/ 中验证我的 swagger (v2) 文档,但我收到了以下警告消息。

{ "generalSwaggerWarnings": [ { "swaggerObject": "#/definitions/Future«object»", "message": "Definition is defined but is not used: #/definitions/Future«object»" } ] }

您的场景与我在评论中发布的示例链接略有不同,因为您没有使用嵌套的 ResponseEntity。所以你的实现会更像这样:

import static springfox.documentation.schema.AlternateTypeRules.newRule;

...

    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .alternateTypeRules(
                        newRule(typeResolver.resolve(Future.class),
                                typeResolver.resolve(WildcardType.class)))
                ;
    }