LoginSignup
1
1

More than 3 years have passed since last update.

array of objectsを表現するswagger記法

Posted at

OpenAPI v3におけるYAMLの記法です。

yaml

results:
  type: array
  items:
    type: object
    properties:
      AA:
        type: string
      BB:
        type: string
      CC:
        type: string
      DD:
        type: string
      EE:
        type: string
  example:
    - AA: aa
      BB: bb
      CC: cc
      DD: dd
      EE: ee
    - AA: aa
      DD: dd
      EE: ee
    - AA: aa
      BB: bb
      CC: cc

出力

{
  "results": [
    {
      "AA": "aa",
      "BB": "bb",
      "CC": "cc",
      "DD": "dd",
      "EE": "ee"
    },
    {
      "AA": "aa",
      "DD": "dd",
      "EE": "ee"
    },
    {
      "AA": "aa",
      "BB": "bb",
      "CC": "cc"
    }
  ]
}

exampleで指定されていない値はkeyごとskipされるようになります

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1