Kno*_*bik 5 rest swagger swagger-ui openapi
该参数未分解为单独的字段,我无法理解为什么。
这是我的Yaml,使用OpenApi 3.0
paths:
/match/started:
post:
tags:
- match
summary: 'Callback for when a game has started.'
operationId: 'App\Http\Controllers\Api\V1\MatchController::started'
requestBody:
description: 'Something something batman!'
required: true
content:
multipart/form-data:
schema:
required:
- match_uuid
properties:
game_uuid:
type: string
player_uuids:
type: array
items:
type: string
type: object
encoding:
player_uuids:
style: form
explode: true
responses:
200:
description: 'success response'
content:
application/json:
schema:
$ref: '#/components/schemas/Api_V1_Match_Started'
Run Code Online (Sandbox Code Playgroud)
这是sw着嘴给我的卷曲要求(不好)
curl -X POST "https://editor.swagger.io/api/v1/match/started" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "game_uuid=test" -F "player_uuids=aaa,bbb,ccc"
您可以在其中看到最后一个参数的地方-F "player_uuids=aaa,bbb,ccc"
,应该是-F "player_uuids=aaa" -F "player_uuids=bbb" -F "player_uuids=ccc"
因此完整的请求应如下所示:
curl -X POST "https://editor.swagger.io/api/v1/match/started" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "game_uuid=test" -F "player_uuids=aaa" -F "player_uuids=bbb" -F "player_uuids=ccc"
目前无法使用 OpenAPI 定义您的场景(带有分解数组的多部分请求),因为explode
andstyle
行为仅定义于application/x-www-form-urlencoded
但不定义于multipart/*
:
style
...如果请求正文媒体类型不是,则应忽略此属性application/x-www-form-urlencoded
。
explode
...如果请求正文媒体类型不是,则应忽略此属性application/x-www-form-urlencoded
。
相关讨论:Swagger UI:在formdata中提交整数元素数组
您可能想向 OpenAPI 规范提交增强请求。
归档时间: |
|
查看次数: |
272 次 |
最近记录: |