oneOfキーワード・パターンのサポート
oneOf
キーワードを使用して、指定されたデータがいずれかのサブスキーマに対して有効であることを確認します。
ノート:
oneOf
を使用する場合、次のガイドラインは必須です:
discriminator
要素が存在する必要があります。discriminator
要素名は、すべてのサブスキーマで一意である必要があります。
ノート:
次のoneOf
キーワード・パターンは現在サポートされていません。
- サブスキーマが単純型である
oneOf
- ネストされた
oneOf
サブスキーマを持つoneOf
(インラインまたは$ref
として定義)
次の項に記載されていないその他のパターンは、サポート対象外とみなす必要があります。
oneOf
キーワード・パターンがサポートされます。
- oneOf(すべてのサブスキーマが$refとして定義されている場合)
- oneOf(すべてのサブスキーマがインラインとして定義されている場合)
- oneOf(インラインおよび$refサブスキーマの混在)
- 複数のマッピングを含むサブスキーマを含むoneOf
- oneOf配列型の項目として定義
- oneOfトップ・レベル配列の項目として定義
- $refとして定義されるネストされたallOfサブスキーマを持つoneOf
- ネストされたallOfサブスキーマがインラインで定義されているoneOf
- $refとして定義されたネストされたanyOfサブスキーマを持つoneOf
- ネストされたanyOfサブスキーマをインラインで定義したoneOf
oneOf(すべてのサブスキーマが$refとして定義されている場合)
oneOf
パターンを使用すると、すべてのサブスキーマが参照($ref
)として定義されます。 この例では、pet
スキーマは2つのサブスキーマのいずれかに対して検証できます。
{
"schemas": {
"Pet": {
"discriminator": {
"propertyName": "pet_type",
"mapping": {
"CAT": "#/components/schemas/Cat_Type",
"DOG": "#/components/schemas/Dog_Type"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/Cat_Type"
},
{
"$ref": "#/components/schemas/Dog_Type"
}
]
},
"Cat_Type": {
"type": "object",
"required": [
"pet_type"
],
"properties": {
"hunts": {
"type": "boolean"
},
"pet_type": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"Dog_Type": {
"type": "object",
"required": [
"pet_type"
],
"properties": {
"bark": {
"type": "boolean"
},
"pet_type": {
"type": "string"
},
"breed": {
"type": "string",
"enum": [
"Dingo",
"Husky",
"Retriever",
"Shepherd"
]
}
}
}
}
}
oneOf(すべてのサブスキーマがインラインとして定義されている場合)
oneOf
パターンを使用すると、すべてのサブスキーマがインラインで定義されます。 この例では、Pet
スキーマは2つのサブスキーマのいずれかに対して検証できます。
ノート:
このパターンは、Oracle Integrationからの送信メッセージ(つまり、呼出し接続リクエストまたはクライアントへのトリガー接続レスポンス)でのみサポートされます。{
"schemas": {
"Pet": {
"discriminator": {
"propertyName": "pet_type"
},
"oneOf": [
{
"properties": {
"age": {
"type": "integer"
},
"hunts": {
"type": "boolean"
},
"pet_type": {
"type": "string"
}
},
"required": [
"pet_type"
],
"type": "object"
},
{
"properties": {
"bark": {
"type": "boolean"
},
"breed": {
"enum": [
"Dingo",
"Husky",
"Retriever",
"Shepherd"
],
"type": "string"
},
"pet_type": {
"type": "string"
}
},
"required": [
"pet_type"
],
"type": "object"
}
]
}
}
}
oneOf(インラインおよび$refサブスキーマの混在)
ノート:
discriminator
マッピングは、$ref
として定義されているすべてのサブスキーマに対して、このパターンで必須です。- 複数のサブスキーマがインラインとして定義されている場合、このパターンは、Oracle Integrationからの送信メッセージ(つまり、呼出し接続リクエストまたはクライアントへのトリガー・レスポンス)でのみサポートされます。
サブスキーマが参照($ref
)とインラインの両方として定義されるoneOf
パターンを使用できます。 この例では、1つのサブスキーマが参照として定義され、1つのサブスキーマがインラインで定義されています。
{
"schemas": {
"Pet": {
"discriminator": {
"propertyName": "pet_type",
"mapping": {
"CAT": "#/components/schemas/Cat_Type"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/Cat_Type"
},
{
"type": "object",
"required": [
"pet_type"
],
"properties": {
"bark": {
"type": "boolean"
},
"pet_type": {
"type": "string"
},
"breed": {
"type": "string",
"enum": [
"Dingo",
"Husky",
"Retriever",
"Shepherd"
]
}
}
}
]
},
"Cat_Type": {
"type": "object",
"required": [
"pet_type"
],
"properties": {
"hunts": {
"type": "boolean"
},
"pet_type": {
"type": "string"
},
"age": {
"type": "integer"
}
}
}
}
}
複数のマッピングを含むサブスキーマを含むoneOf
oneOf
パターンを使用できます。{
"schemas": {
"Pet": {
"discriminator": {
"propertyName": "pet_type",
"mapping": {
"CAT": "#/components/schemas/Cat_Type",
"DOG": "#/components/schemas/Dog_Type",
"PUP": "#/components/schemas/Dog_Type"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/Cat_Type"
},
{
"$ref": "#/components/schemas/Dog_Type"
}
]
},
"Cat_Type": {
"type": "object",
"required": [
"pet_type"
],
"properties": {
"hunts": {
"type": "boolean"
},
"pet_type": {
"type": "string"
},
"age": {
"type": "integer"
}
}
},
"Dog_Type": {
"type": "object",
"required": [
"pet_type"
],
"properties": {
"bark": {
"type": "boolean"
},
"pet_type": {
"type": "string"
},
"breed": {
"type": "string",
"enum": [
"Dingo",
"Husky",
"Retriever",
"Shepherd"
]
}
}
}
}
}
oneOf配列型の項目として定義
oneOf
パターンを使用できます。{
"components": {
"schemas": {
"ItemRootIccPrivateVO-item-patch-request": {
"properties": {
"Pets": {
"description": "The items in the collection.",
"items": {
"discriminator": {
"propertyName": "pet_type",
"mapping": {
"CAT": "#/components/schemas/Cat_Type",
"DOG": "#/components/schemas/Dog_Type"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/Cat_Type"
},
{
"$ref": "#/components/schemas/Dog_Type"
}
]
}
},
"title": "Pets",
"type": "array",
"x-cardinality": "1"
}
},
"type": "object"
}
}
}
oneOfトップ・レベル配列の項目として定義
最上位の配列の項目として定義されたoneOf
パターンを使用できます。
{
"components": {
"schemas": {
"Pets": {
"description": "The items in the collection.",
"items": {
"discriminator": {
"propertyName": "pet_type",
"mapping": {
"CAT": "#/components/schemas/Cat_Type",
"DOG": "#/components/schemas/Dog_Type"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/Cat_Type"
},
{
"$ref": "#/components/schemas/Dog_Type"
}
]
},
"title": "Pets",
"type": "array",
"x-cardinality": "1"
}
}
}
}
$refとして定義されるネストされたallOfサブスキーマを持つoneOf
allOf
がネストされ、参照($ref
)として定義されるoneOf
パターンを使用できます。
{
"schemas": {
"Animal": {
"discriminator": {
"propertyName": "pet_type",
"mapping": {
"CAT": "#/components/schemas/CatPet",
"DOG": "#/components/schemas/DogPet"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/CatPet"
},
{
"$ref": "#/components/schemas/DogPet"
}
]
},
"CatPet": {
"allOf": [
{
"$ref": "#/components/schemas/Pet"
},
{
"$ref": "#/components/schemas/Cat"
}
]
},
"DogPet": {
"allOf": [
{
"$ref": "#/components/schemas/Pet"
},
{
"$ref": "#/components/schemas/Dog"
}
]
},
"Pet": {
"type": "object",
"required": [
"pet_type"
],
"properties": {
"pet_type": {
"type": "string"
}
}
},
"Dog": {
"type": "object",
"properties": {
"bark": {
"type": "boolean"
},
"breed": {
"type": "string",
"enum": [
"Dingo",
"Husky",
"Retriever",
"Shepherd"
]
}
}
},
"Cat": {
"type": "object",
"properties": {
"hunts": {
"type": "boolean"
},
"age": {
"type": "integer"
}
}
}
}
}
ネストされたallOfサブスキーマがインラインで定義されているoneOf
allOf
がネストされ、インラインで定義されているoneOf
パターンを使用できます。
{
"schemas": {
"Animal": {
"discriminator": {
"propertyName": "pet_type",
"mapping": {
"DOG": "#/components/schemas/DogPet"
}
},
"oneOf": [
{
"allOf": [
{
"$ref": "#/components/schemas/Pet"
},
{
"$ref": "#/components/schemas/Cat"
}
]
},
{
"$ref": "#/components/schemas/DogPet"
}
]
},
"DogPet": {
"allOf": [
{
"$ref": "#/components/schemas/Pet"
},
{
"$ref": "#/components/schemas/Dog"
}
]
},
"Pet": {
"type": "object",
"required": [
"pet_type"
],
"properties": {
"pet_type": {
"type": "string"
}
}
},
"Dog": {
"type": "object",
"properties": {
"bark": {
"type": "boolean"
},
"breed": {
"type": "string",
"enum": [
"Dingo",
"Husky",
"Retriever",
"Shepherd"
]
}
}
},
"Cat": {
"type": "object",
"properties": {
"hunts": {
"type": "boolean"
},
"age": {
"type": "integer"
}
}
}
}
}
$refとして定義されたネストされたanyOfサブスキーマを持つoneOf
anyOf
サブスキーマが参照($ref
)として定義されるoneOf
パターンを使用できます。{
"schemas": {
"Animal": {
"discriminator": {
"propertyName": "pet_type",
"mapping": {
"CAT": "#/components/schemas/CatPet",
"DOG": "#/components/schemas/DogPet"
}
},
"oneOf": [
{
"$ref": "#/components/schemas/CatPet"
},
{
"$ref": "#/components/schemas/DogPet"
}
]
},
"CatPet": {
"anyOf": [
{
"$ref": "#/components/schemas/Pet"
},
{
"$ref": "#/components/schemas/Cat"
}
]
},
"DogPet": {
"anyOf": [
{
"$ref": "#/components/schemas/Pet"
},
{
"$ref": "#/components/schemas/Dog"
}
]
},
"Pet": {
"type": "object",
"required": [
"pet_type"
],
"properties": {
"pet_type": {
"type": "string"
}
}
},
"Dog": {
"type": "object",
"properties": {
"bark": {
"type": "boolean"
},
"breed": {
"type": "string",
"enum": [
"Dingo",
"Husky",
"Retriever",
"Shepherd"
]
}
}
},
"Cat": {
"type": "object",
"properties": {
"hunts": {
"type": "boolean"
},
"age": {
"type": "integer"
}
}
}
}
}
ネストされたanyOfサブスキーマをインラインで定義したoneOf
anyof
サブスキーマがインラインで定義されるoneOf
パターンを使用できます。
Collapse source
{
"schemas": {
"Animal": {
"discriminator": {
"propertyName": "pet_type",
"mapping": {
"DOG": "#/components/schemas/DogPet"
}
},
"oneOf": [
{
"anyOf": [
{
"$ref": "#/components/schemas/Pet"
},
{
"$ref": "#/components/schemas/Cat"
}
]
},
{
"$ref": "#/components/schemas/DogPet"
}
]
},
"DogPet": {
"allOf": [
{
"$ref": "#/components/schemas/Pet"
},
{
"$ref": "#/components/schemas/Dog"
}
]
},
"Pet": {
"type": "object",
"required": [
"pet_type"
],
"properties": {
"pet_type": {
"type": "string"
}
}
},
"Dog": {
"type": "object",
"properties": {
"bark": {
"type": "boolean"
},
"breed": {
"type": "string",
"enum": [
"Dingo",
"Husky",
"Retriever",
"Shepherd"
]
}
}
},
"Cat": {
"type": "object",
"properties": {
"hunts": {
"type": "boolean"
},
"age": {
"type": "integer"
}
}
}
}
}