Swagger 发送和接收数组
Swagger send and receive array
openapi: "3.0.0"
info:
title: project
servers:
- url: http://example1.net/v3
- url: http://example/v3
paths:
/Pn/{PnId}/service1:
post:
summary: Pn data
description: |
can Pn the data
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/dataInfo"
application/x-www-form-urlencoded:
schema:
$ref: "#/components/schemas/dataInfo"
parameters:
- name: PnId
in: path
description: PnId
required: true
schema:
$ref: "#/components/schemas/Pn"
responses:
'200':
description: status
content:
application/json:
schema:
$ref: "#/components/schemas/dataInfoStatus"
example: infoable
default:
description: error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Error:
type: object
properties:
code:
type: integer
message:
type: string
required:
- message
Pn:
type: integer
format: int64
dataInfo:
type: string
dataInfoStatus:
type: string
enum: [infoable, non_infoable,ignorable]
我在请求中发送单个 dataInfo 并在响应中获取单个 dataInfoStatus,但我想发送 dataInfo 数组并获取 dataInfo 状态数组。
我试过以下方法:
schema:
type:array
items:
$ref: "#/components/schemas/dataInfo"
但我明白了
Parser error bad indentation of a mapping entry
对于项目。我正在关注 this.
如何实现在请求中将 dataInfo 作为 dataInfo 数组发送并在响应中获取 dataInfoStatus 数组?
你必须在type:
和array
之间再添加一个space,然后错误信息就没有了:
schema:
type: array
items:
$ref: "#/components/schemas/dataInfo"
您可以为 version of the openapi file 添加 info.version
。
openapi: "3.0.0"
info:
title: project
servers:
- url: http://example1.net/v3
- url: http://example/v3
paths:
/Pn/{PnId}/service1:
post:
summary: Pn data
description: |
can Pn the data
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/dataInfo"
application/x-www-form-urlencoded:
schema:
$ref: "#/components/schemas/dataInfo"
parameters:
- name: PnId
in: path
description: PnId
required: true
schema:
$ref: "#/components/schemas/Pn"
responses:
'200':
description: status
content:
application/json:
schema:
$ref: "#/components/schemas/dataInfoStatus"
example: infoable
default:
description: error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
components:
schemas:
Error:
type: object
properties:
code:
type: integer
message:
type: string
required:
- message
Pn:
type: integer
format: int64
dataInfo:
type: string
dataInfoStatus:
type: string
enum: [infoable, non_infoable,ignorable]
我在请求中发送单个 dataInfo 并在响应中获取单个 dataInfoStatus,但我想发送 dataInfo 数组并获取 dataInfo 状态数组。
我试过以下方法:
schema:
type:array
items:
$ref: "#/components/schemas/dataInfo"
但我明白了
Parser error bad indentation of a mapping entry
对于项目。我正在关注 this.
如何实现在请求中将 dataInfo 作为 dataInfo 数组发送并在响应中获取 dataInfoStatus 数组?
你必须在type:
和array
之间再添加一个space,然后错误信息就没有了:
schema:
type: array
items:
$ref: "#/components/schemas/dataInfo"
您可以为 version of the openapi file 添加 info.version
。