是否可以在 OAS3 中为请求正文的内部对象设置内容类型,并在调用调用时将其显示在 swagger UI 生成的 curl 命令中?这是 OAS3 中支持的功能吗?下面给出一个例子。记者是内部对象。
paths:
"/incidents/{incidentId}/type/file":
post:
summary: Add an image
description: "Image"
parameters:
- name: incidentId
in: path
description: Incident ID
required: true
schema:
type: string
requestBody:
content:
multipart/form-data:
schema:
type: object
required:
- file
properties:
file:
type: string
description: File to upload
format: binary
type:
type: string
description: Type
teamId:
type: string
description: Team ID
incidentCreation:
type: string
description: "Test"
professionalId:
type: string
description: Professional ID
reporter:
type: object
properties:
name:
type: string
actingAs:
type: string
contact:
type: object
properties:
emailAddress:
type: string
phoneNumber:
type: string
language:
type: object
properties:
user:
type: string
address:
type: string
encoding:
file:
contentType: application/octet-stream
reporter:
contentType: application/json
required: true
responses:
"200":
description: ""
content: {}
x-auth-type: "Application & Application User"
x-throttling-tier: Unlimited
x-codegen-request-body-name: Payload
以下是在 wso2am-2.2.0 商店门户中生成的 curl 命令。
curl -k -X POST "https://192.168.8.101:8243/api/1.1.0/incidents/1232387912/type/file" -H "accept: */*" -H "Content-Type: multipart/form-data" -H "Authorization: Bearer 5eb36aea-1ed3-3a90-b578-356e89c79c99" -d {"type":"","teamId":"","incidentCreation":"","professionalId":"","reporter":"{ \"name\": \"string\", \"actingAs\": \"string\", \"contact\": { \"emailAddress\": \"string\", \"phoneNumber\": \"string\", \"language\": { \"user\": \"string\", \"address\": \"string\" } }}","file":{}}