API要求将POST主体作为表单对象传递。例如Postman如何提出请求:
curl -X POST \
http://api.mysite.local/v1/site/login \
-H 'cache-control: no-cache' \
-H 'content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW' \
-F 'LoginForm[login]=username' \
-F 'LoginForm[password]=password'
如何使用OpenAPI 3.0对此进行描述?由于大量可重复使用的表单和数据对象,我决定将它们放在/components/schemas
中并在$ ref中重用请求描述:
paths:
/site/login:
description: "Authorization"
post:
requestBody:
content:
application/x-www-form-urlencoded:
type: object
properties:
LoginForm:
$ref: "components/schemas/LoginForm"
encoding:
LoginForm:
style: deepObject
explode: true
components:
schemas:
LoginForm:
type: object
properties:
login:
type: string
password:
type: string
required:
- login
- password
不幸的是,当我执行widdershins --expandBody 'api.yml' -o 'api.md'
时,身体参数部分为空,但没有效果。我做错了什么?