如何解决昂首阔步的发送和接收数组
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和array并获取dataInfo状态的数组。
我尝试了以下操作:
schema:
type:array
items:
$ref: "#/components/schemas/dataInfo"
但我知道
解析器错误映射条目缩进
项。我正在关注this。
如何在请求中以dataInfo数组形式发送dataInfo并以dataInfoStatus数组作为响应?
解决方法
您必须在type:
和array
之间再添加一个空格,然后错误消息消失了:
schema:
type: array
items:
$ref: "#/components/schemas/dataInfo"
您可以为version of the openapi file添加info.version
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。