使用 OpenAPI 呈现字典字典的示例

问题描述 投票:0回答:0

我面临的情况是整个 openapi 规范被分割成多个相互引用的文件,如下所示。在此链的末尾,有一个 DataContainer.yaml 的示例。但是这不会被渲染。事实上,放置任何类似描述的内容都会导致奇怪的行为,例如该字段在外部和内部“字典”中重复出现。我应该把这个例子放在哪里才能渲染它?

#apis.yml

openapi: 3.0.1
...
paths:
  '/path/to/resource':
    $ref: './resources/myspec.yaml'
#myspec.yml

post:
  summary: Creates a new whatever
  parameters:
    - name: whatever
      in: path
      required: true
      schema:
        type: string
  requestBody:
    required: true
    content:
      application/json:
        schema:
          $ref: '../schemas/CreateParams.yaml'
#CreateParams.yml

type: object
properties:
  name:
    type: string
    description: The default name
  data:
    $ref: './DataContainer.yaml'
#DataContainer.yml

type: object
additionalProperties:
  type: object
  additionalProperties:
    type: number
example:
  -1:
    0: 100000
    1: 200000
    2: 300000
    3: 400000
  0:
    0: 100000
    1: 200000
    2: 300000
    3: 400000
swagger swagger-ui openapi
© www.soinside.com 2019 - 2024. All rights reserved.