REST V2コネクタ > REST V2コネクタについて > オブジェクトの配列
  

オブジェクトの配列

application/jsonメディアタイプのオブジェクトの配列は、要求定義と応答定義のOpenAPI仕様ファイルで定義できます。

要求本文と応答本文のインライン配列

要求本文のすべてのフィールドがrequestBodyセクションで定義されているrequestBodyまたは応答。
例:
"/users_inline": {
"post": {
"description": "Add Multiple Users",
"operationId": "users_inline",
"requestBody": {
"description": "Add Multiple Users",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
}
}
}
}
}
}
}
"responses": {
"200": {
"description": "add User Response",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"id": {
"type": "string"
}
}
}
}
}
}
}
}

要求と応答の本文のインラインref配列

スキーマの型が配列で、参照オブジェクト$refを含むrequestBodyまたは応答。
例:
"post": {
"description": "Add Multiple Users",
"operationId": "users_inline_ref",
"requestBody": {
"description": "Add new Users",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
}
}
"responses": {
"200": {
"description": "add User Response",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
}
}
}

要求本文と応答本文のコンポーネント内の配列

schemaにコンポーネントを指す参照オブジェクト$refのみが含まれるrequestBodyまたは応答。
例:
"post": {
"description": "Add Multiple Users",
"operationId": "users",
"requestBody": {
"description": "Add new Users",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/user_list_inline"
}
}
}
}
"components": {
"schemas": {
"user_list": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
}
"responses": {
"200": {
"description": "add User Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/user_list"
}
}
}
}
}
"components": {
"schemas": {
"user_list": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
}

要求本文と応答本文の複合オブジェクト

配列フィールドと単純フィールドを含むrequestBodyまたは応答。
例:
"description": "Add Complex Object",
"operationId": "aad_complex_object",
"requestBody": {
"description": "Add new Users",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/complex_object"
}
}
}
}
"components": {
"schemas": {
"complex_object": {
"type": "object",
"properties": {
"sample_string": {
"type": "string"
},
"user_array": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
}
}
}
"responses": {
"200": {
"description": "add User Response",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/complex_object"
}
}
}
}
}

"components": {
"schemas": {
"complex_object": {
"type": "object",
"properties": {
"sample_string": {
"type": "string"
},
"user_array": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"
}
}
}
}
}
}