springfox swagger ui返回404有效资源

时间:2016-06-22 20:00:50

标签: spring swagger-ui springfox

我使用swagger获得404有效资源请求。 Swagger失败并让我回归404,而Postman正在返回结果。 swagger失败的参数是authDtls,我必须在这个参数中传递json,如果我传递json然后它失败了404,但是使用非json输入正常工作。 我使用的是springfox swagger ui version 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"
                    }
                }
            }
        }
    }

Spring Controller:

@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);
 }

0 个答案:

没有答案