機械翻訳について

oneOfキーワード・パターンのサポート

oneOfキーワードを使用して、指定されたデータがいずれかのサブスキーマに対して有効であることを確認します。

ノート:

oneOfを使用する場合、次のガイドラインは必須です:
  • discriminator要素が存在する必要があります。
  • discriminator要素名は、すべてのサブスキーマで一意である必要があります。

ノート:

次のoneOfキーワード・パターンは現在サポートされていません。
  • サブスキーマが単純型であるoneOf
  • ネストされたoneOfサブスキーマを持つoneOf (インラインまたは$refとして定義)

次の項に記載されていないその他のパターンは、サポート対象外とみなす必要があります。

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"
                }
            }
        }
    }
}