rest - Swagger 的 body 参数名称的用途是什么?

标签 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 的 body 参数名称的用途是什么?

最佳答案

好吧,名称用于代码生成器,作为生成方法的参数名称。但正如你所说,这个名字并没有真正的用途,实际上它是 removed in the 3.0 specification .

关于rest - Swagger 的 body 参数名称的用途是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39660554/

相关文章:

java - 根据 Swagger 定义验证 REST 消息

rest - 为什么 HBase Java 客户端比 REST/Thrift 慢

java - 为什么我的 REST API 在嵌套对象上返回空白 JSON?

java - 在 Spring Boot 中使用 token 保护 api

javascript - 使用 Javascript 加载非 HTML 内容。是否可以?

typescript - Swagger/OpenAPI 客户端代码生成器更改属性名称

.net - Azure App Insights 中的 Rest API(后期)可用性测试

python - 我需要 Apache 吗?

java - 移动设备上连接的适当超时是多少?

java - 由 : java. lang.ClassNotFoundException : springfox. documentation.common.ClassPresentInClassPathCondition 引起