Swagger身体参数名称的目的是什么?

时间:2016-09-23 12:15:45

标签: rest http swagger

如下所示,我将body参数命名为main_name_of_parameter

swagger: "2.0"

info:
  title: Learing Swagger Title
  description: Learing Swagger Description
schemes:
  - http
host: testing.example.com
basePath: /api
consumes:
  - application/json
produces:
  - application/json

paths:
 /test:
    post:
      summary: testing a post
      description: testing a post
      parameters:
        - name: main_name_of_parameter
          in: body
          description: main_name_of_parameter
          schema:
            properties:
              property_one:
                type: string
              property_two:
                type: string

然后我使用swagger UI测试它,它会生成以下curl:

curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \ 
   "property_one": "string", \ 
   "property_two": "string" \ 
 }' 'http://testing.example.com/api/test'

如图所示,main_name_of_parameter从未发送到服务器。 Swagger身体参数名称的目的是什么?

1 个答案:

答案 0 :(得分:3)

嗯,该名称用于代码生成器,作为生成的方法的参数名称。但正如你所说的那样,名字并没有真正用处,事实上它正在removed in the 3.0 specification

相关问题