Swagger UI未填充响应标头,响应正文和响应代码

时间:2015-08-31 14:59:00

标签: swagger-ui

以下是我用swagger core生成的swagger.json。

{
    "basePath": "/rest",
    "host": "localhost:8080",
    "info": {
        "title": "",
        "version": "1.5.0"
    },
    "paths": {
        /device/{iccid}/{deviceId}": {
            "get": {
                "consumes": [
                    "application/xml"
                ],
                "description": "Return \"Success\" if the deviceID is successfully Set \"Failure\" otherwise",
                "operationId": "setDeviceId",
                "parameters": [
                    {
                        "description": "iccid of the device",
                        "in": "path",
                        "name": "iccid",
                        "required": true,
                        "type": "string"
                    },
                    {
                        "description": "deviceId of to be on the device",
                        "in": "path",
                        "name": "deviceId",
                        "required": true,
                        "type": "string"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "successful operation",
                        "schema": {
                            "type": "string"
                        }
                    },
                    "400": {
                        "description": "Invalid status value"
                    }
                },
                "summary": "Set the deviceID of a SIM's iccid ",
                "tags": [
                    "change device name"
                ]
            }
        }
    },
    "schemes": [
        "http"
    ],
    "swagger": "2.0",
    "tags": [
        {
            "name": "change device name"
        }
    ]
}

当我卷曲样本请求时,我得到以下回复:

$ curl -i "http://localhost:8080/rest/device/1234555/test"
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Content-Type: text/plain
Content-Length: 7
Date: Mon, 31 Aug 2015 14:46:21 GMT

success%

我在tomcat web.xml中添加了CORS过滤器

<filter>
  <filter-name>CorsFilter</filter-name>
  <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>CorsFilter</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

我不确定我是否需要更多?

提前致谢。

0 个答案:

没有答案