0
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"

但我明白了

解析器错误映射条目的缩进错误

对于项目。我正在关注这个

如何实现将请求中的 dataInfo 作为 dataInfo 数组发送并获得 dataInfoStatus 数组作为响应?

4

1 回答 1

2

type:您必须在and之间再添加一个空格array,然后错误消息就消失了:

schema:
    type: array
    items:
        $ref: "#/components/schemas/dataInfo"

并且您可以为openapi 文件info.version的版本添加。

于 2020-08-31T18:46:51.447 回答