7
參考下面的示例,我想在其定義中提供一個NamedElementArray
的示例。這將需要爲elements
屬性顯示一個NamedElement
數組的示例。如何提供一個包含數組作爲其屬性的數組中的對象定義的示例
我該怎麼做?我找不到在swagger規範中如何做到這一點的細節。
swagger: '2.0'
info:
version: "0.0.0"
title: Example
definitions:
Identifier:
type: string
format: uuid
NamedElement:
type: object
properties:
name:
type: string
identifier:
$ref: "#/definitions/Identifier"
required:
- name
- identifier
example:
name: Identifier1
identifier: ab804529-11d0-4781-a49a-3bbbc40243df
NamedElementArray:
type: object
properties:
name:
type: string
elements:
type: array
minLength: 0
items:
$ref: "#/definitions/NamedElement"
required:
- name
- elements
example:
name: Fred
elements:
paths:
/elements/{name}:
get:
description: |
Gets `NamedElement` objects, based on the **name** query param.
parameters:
-
name: name
in: path
description: Name of element array to return
required: true
type: string
responses:
200:
description: Returns a named element array
schema:
$ref: "#/definitions/NamedElementArray"
default:
description: Return nothing