参数为空时是否可以跳过参数生成,例如版本swagger:'2.0'

时间:2019-07-31 14:45:25

标签: swagger swagger-2.0 swagger-3.0

我遇到了麻烦,使用openapi时会生成一个空参数:3.0.1。

因此,这里有2个摘要(您可以直接复制粘贴到https://editor.swagger.io/中)

const eventSource = new EventSource(`host/my/url/`, {withCredentials: true});

eventSource.onmessage = (sse: any) => { ... };

eventSource.onerror = (err: any) => { ... };

当您点击登录时->试用->使用空的测试字段执行它会生成curl:

swagger: '2.0'
info:
  title: t
  version: '1'
paths:
  /login:
    post:
      consumes:
        - application/x-www-form-urlencoded
      parameters:
        - name: test
          type: string
          in: formData
      responses:
        '200':
          description: OK

,如果您通过了参数测试,例如:

curl -X POST "https://editor.swagger.io/login" -H "accept: application/json"

第二段代码:

curl -X POST "https://editor.swagger.io/login" -H "accept: application/json" -H "Content-Type: application/x-www-form-urlencoded" -d "test=test"

当您点击登录时->试用->使用空的测试字段执行它会生成curl:

openapi: 3.0.1
info:
  title: t
  version: "1"
servers:
- url: /
paths:
  /login:
    post:
      requestBody:
        content:
          application/x-www-form-urlencoded:
            schema:
              type: object
              properties:
                test:
                  type: string
      responses:
        200:
          description: OK
          content: {}
components: {}

,如果您通过了参数测试,例如:

curl -X POST "https://editor.swagger.io/login" -H "accept: */*" -H "Content-Type: application/x-www-form-urlencoded" -d "test="

我需要获得如下的通用卷曲请求:

curl -X POST "https://editor.swagger.io/login" -H "accept: */*" -H "Content-Type: application/x-www-form-urlencoded" -d "test=test"

使用openapi时:3.0.1

0 个答案:

没有答案