allOf with multiple oneOf constraints
POST/allof-multiple-oneof
Schema demonstrating allOf containing multiple independent oneOf constraints. The object must satisfy one option from each oneOf group AND include shared properties.
This pattern is used when multiple independent constraints must all be satisfied, similar to the security-rules schema where a rule must be one policy type AND exist in one scope.
Schema:
type: object
allOf:
# Constraint 1: Must be one of these types
- oneOf:
- title: standard
type: object
properties:
type:
type: string
enum: [standard]
priority:
type: integer
minimum: 1
maximum: 10
required: [type, priority]
- title: express
type: object
properties:
type:
type: string
enum: [express]
expedited:
type: boolean
required: [type, expedited]
# Constraint 2: Must exist in one of these scopes
- oneOf:
- title: global
type: object
properties:
scope:
type: string
enum: [global]
required: [scope]
- title: regional
type: object
properties:
scope:
type: string
enum: [regional]
region:
type: string
required: [scope, region]
- title: local
type: object
properties:
scope:
type: string
enum: [local]
location:
type: string
required: [scope, location]
# Shared properties that apply regardless of which options are chosen
properties:
id:
type: string
format: uuid
name:
type: string
description:
type: string
enabled:
type: boolean
default: true
required: [id, name]
Request
Responses
- 201
Created