メインコンテンツまでスキップ

Componentsオブジェクト

OAS のさまざまな側面のための再利用可能なオブジェクトのセットを保持します。コンポーネント オブジェクト内で定義されたすべてのオブジェクトは、コンポーネント オブジェクトの外部のプロパティから明示的に参照されない限り、API に影響を与えません。

固定フィールド
フィールド名タイプ説明
スキーマMap[ string,Schemaオブジェクト]再利用可能なSchemaオブジェクトを保持するオブジェクト。
反応Map[ string,Responseオブジェクト| Referenceオブジェクト]再利用可能なResponse Objectを保持するオブジェクト。
パラメーターMap[ string,Parameterオブジェクト| Referenceオブジェクト]再利用可能なParameterオブジェクトを保持するオブジェクト。
Map[ string,Exampleオブジェクト| Referenceオブジェクト]再利用可能なExampleオブジェクトを保持するオブジェクト。
リクエストボディMap[ string,リクエスト本文オブジェクト| Referenceオブジェクト]再利用可能なリクエストボディオブジェクトを保持するオブジェクト。
ヘッダーMap[ string,Headerオブジェクト| Referenceオブジェクト]再利用可能なHeader Objectを保持するオブジェクト。
セキュリティスキームMap[ string,Security Schemaオブジェクト| Referenceオブジェクト]再利用可能なSecurity Schemaオブジェクトを保持するオブジェクト。
リンクMap[ string,Linkオブジェクト| Referenceオブジェクト]再利用可能なLinkオブジェクトを保持するオブジェクト。
コールバックMap[ string,Callbackオブジェクト| Referenceオブジェクト]再利用可能なCallback Objectを保持するオブジェクト。
パスアイテムMap[ string,Path Itemオブジェクト| Referenceオブジェクト]再利用可能なPath Items Objectを保持するオブジェクト。

このオブジェクトは、仕様拡張機能を使用して拡張できます。

上記で宣言されたすべての固定フィールドは、正規表現^[a-zA-Z0-9\.\-_]+$に一致するキーを使用しなければならないオブジェクトです。

フィールド名の例:

UserUser_1User_Nameuser-namemy.org.User

Componentsオブジェクトの例

{
"components": {
"schemas": {
"Category": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
},
"Tag": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
}
}
}
},
"parameters": {
"skipParam": {
"name": "skip",
"in": "query",
"description": "number of items to skip",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
},
"limitParam": {
"name": "limit",
"in": "query",
"description": "max records to return",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
}
}
},
"responses": {
"NotFound": {
"description": "Entity not found."
},
"IllegalInput": {
"description": "Illegal input for operation."
},
"GeneralError": {
"description": "General Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GeneralError"
}
}
}
}
},
"securitySchemes": {
"api_key": {
"type": "apiKey",
"name": "api_key",
"in": "header"
},
"petstore_auth": {
"type": "oauth2",
"flows": {
"implicit": {
"authorizationUrl": "http://example.org/api/oauth/dialog",
"scopes": {
"write:pets": "modify pets in your account",
"read:pets": "read your pets"
}
}
}
}
}
}
}
components:
schemas:
Category:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
Tag:
type: object
properties:
id:
type: integer
format: int64
name:
type: string
parameters:
skipParam:
name: skip
in: query
description: number of items to skip
required: true
schema:
type: integer
format: int32
limitParam:
name: limit
in: query
description: max records to return
required: true
schema:
type: integer
format: int32
responses:
NotFound:
description: Entity not found.
IllegalInput:
description: Illegal input for operation.
GeneralError:
description: General Error
content:
application/json:
schema:
$ref: '#/components/schemas/GeneralError'
securitySchemes:
api_key:
type: apiKey
name: api_key
in: header
petstore_auth:
type: oauth2
flows:
implicit:
authorizationUrl: http://example.org/api/oauth/dialog
scopes:
write:pets: modify pets in your account
read:pets: read your pets