1

我使用 swagger 获得 404 的有效资源请求。Swagger 失败并返回 404,而 Postman 正在返回结果。swagger 失败的参数是 authDtls,我必须在这个参数中传递一个 json,如果我传递 json,那么它会以 404 失败,但在非 json 输入下工作正常。我正在使用 springfox swagger ui 版本 2.5.0

这是swagger或springfox中的错误吗?请建议。

Springfox Json:

"/swaggerIssueReproduce": {
        "post": {
            "tags": ["preview-integration-controller"],
            "summary": "swaggerIssueReproduce",
            "operationId": "swaggerIssueReproduceUsingPOST",
            "consumes": ["multipart/form-data"],
            "produces": ["application/json"],
            "parameters": [{
                "name": "sourceArchive",
                "in": "formData",
                "description": "sourceArchive",
                "required": true,
                "type": "file"
            }, {
                "name": "authDtls",
                "in": "query",
                "description": "authDtls",
                "required": true,
                "type": "string"
            }, {
                "name": "mode",
                "in": "query",
                "description": "mode",
                "required": false,
                "type": "string"
            }],
            "responses": {
                "200": {
                    "description": "OK",
                    "schema": {
                        "type": "string"
                    }
                }
            }
        }
    }

弹簧控制器:

@RequestMapping(value= "/swaggerIssueReproduce", method =  RequestMethod.POST,
consumes = { MediaType.MULTIPART_FORM_DATA_VALUE },
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity swaggerIssueReproduce(
       @ApiParam(required = true)
            MultipartFile sourceArchive,
       @RequestParam
            String authDtls,
       @RequestParam(required = false)
            String mode
) {
   LOG.info(" sourceArchive ###################" + sourceArchive);
   LOG.info(" authDtls ###################" + authDtls);
   LOG.info(" mode ###################" + mode);
   return new ResponseEntity("{\"_id\":\"Hello World\"}", HttpStatus.OK);
 }
4

0 回答 0