spring boot swagger springfox为oauth / token端点生成无效的规范

时间:2019-07-19 11:04:31

标签: spring-boot swagger springfox

我想将令牌端点oauth / token添加到我的API文档中,因此我按如下方式配置了Docket:

public Docket api(UserProperties userProperties) {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(Predicates.not(PathSelectors.regex("/error")))
                .paths(Predicates.not(PathSelectors.regex("/oauth/authorize")))
                .paths(Predicates.not(PathSelectors.regex("/oauth/check_token")))
                .paths(Predicates.not(PathSelectors.regex("/oauth/token_key")))
                .paths(Predicates.not(PathSelectors.regex("/oauth/confirm_access")))
                .paths(Predicates.not(PathSelectors.regex("/oauth/error")))
                .build().apiInfo(apiInfo());
    }

swagger-ui可以正确显示页面,但是第三方验证器声称:

Swagger schema validation failed.
 Data does not match any schemas from 'oneOf' at #/paths//oauth/token/post/parameters/1
   Data does not match any schemas from 'oneOf' at #/paths//oauth/token/post/parameters/1
     Missing required property: schema at #/
     Missing required property: type at #/
   Missing required property: $ref at #/paths//oauth/token/post/parameters/1

JSON_OBJECT_VALIDATION_FAILED

从/ api / v2 / api-docs中获取的swagger.json:

"/oauth/token": {
          "get": {
            ...
          },
          "post": {
            "tags": [
              "token-endpoint"
            ],
            "summary": "postAccessToken",
            "operationId": "postAccessTokenUsingPOST",
            "consumes": [
              "application/json"
            ],
            "produces": [
              "*/*"
            ],
            "parameters": [
              {
                "name": "name",
                "in": "query",
                "required": false,
                "type": "string"
              },
              {
                "name": "parameters",
                "in": "query",
                "description": "parameters",
                "required": true,
                "items": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "string"
                  }
                }
              }
            ],
            "responses": {
              ...
            },
            "deprecated": false
          }
        },

springfox为什么会生成无效的架构?

0 个答案:

没有答案