---
source: https://iinventedlight.com/library/notes/ao-structured-json-schema-composition.md
title: "JSON Schema enum, allOf, anyOf, oneOf and not"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "BSD-3-Clause (json-schema-org/website (GitHub)); BSD-3-Clause (json-schema-org/website (GitHub)); MIT (pydantic/pydantic (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: json-schema-org/website (GitHub), Understanding JSON Schema: enum, BSD-3-Clause (https://raw.githubusercontent.com/json-schema-org/website/main/LICENSE). Copyright (c) 2022 JSON Schema Specification Authors; json-schema-org/website (GitHub), Understanding JSON Schema: schema composition, BSD-3-Clause (https://raw.githubusercontent.com/json-schema-org/website/main/LICENSE). Copyright (c) 2022 JSON Schema Specification Authors; pydantic/pydantic (GitHub), JSON Schema (Pydantic docs), MIT (https://raw.githubusercontent.com/pydantic/pydantic/main/LICENSE). Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Docs read; no API call was made for this note."
category: agent-operations
topic_area: "agent operations: structured output"
tags: [json-schema, enum, anyof, oneof, pydantic]
client: Librarian
sources:
  - id: S1
    title: "Understanding JSON Schema: enum"
    publisher: json-schema-org/website (GitHub)
    url: https://github.com/json-schema-org/website/blob/main/pages/understanding-json-schema/reference/enum.md
    accessed: 2026-11-16
    license: "BSD-3-Clause"
  - id: S2
    title: "Understanding JSON Schema: schema composition"
    publisher: json-schema-org/website (GitHub)
    url: https://github.com/json-schema-org/website/blob/main/pages/understanding-json-schema/reference/combining.md
    accessed: 2026-11-16
    license: "BSD-3-Clause"
  - id: S3
    title: "JSON Schema (Pydantic docs)"
    publisher: pydantic/pydantic (GitHub)
    url: https://github.com/pydantic/pydantic/blob/main/docs/concepts/json_schema.md
    accessed: 2026-11-16
    license: "MIT"
---
# JSON Schema enum, allOf, anyOf, oneOf and not
**Answer:** `enum` restricts a value to a fixed set; it must be an array with at least one element, where each element is unique. The keywords used to combine schemas are the following:

| Keyword | Meaning |
|---|---|
| `allOf` | (AND) valid against all of the subschemas |
| `anyOf` | (OR) valid against any of the subschemas |
| `oneOf` | (XOR) valid against exactly one of the subschemas |
| `not` | (NOT) the value fails the given schema |

## Notes

- All of these keywords must be set to an array, and each item in it is a schema.
- Be careful with recursive schemas, as they can exponentially increase processing times.
- Pydantic generates JSON schemas compliant with JSON Schema Draft 2020-12.

## See also

- [ao-structured-json-schema-objects](https://iinventedlight.com/library/notes/ao-structured-json-schema-objects/)
- [ao-structured-gemini-json-schema](https://iinventedlight.com/library/notes/ao-structured-gemini-json-schema/)
- [ao-structured-openai-structured-outputs](https://iinventedlight.com/library/notes/ao-structured-openai-structured-outputs/)
- [ao-structured-across-providers](https://iinventedlight.com/library/notes/ao-structured-across-providers/)

## Claims

- id: C1
  claim: enum needs a non-empty array of unique items.
  source: S1
  evidence: "It must be an array with at least one element"

- id: C2
  claim: oneOf means exactly one subschema.
  source: S2
  evidence: "Must be valid against *exactly one* of the subschemas"

- id: C3
  claim: Recursive schemas can be slow.
  source: S2
  evidence: "Be careful with recursive schemas"

- id: C4
  claim: Pydantic emits Draft 2020-12 schemas.
  source: S3
  evidence: "JSON Schema Draft 2020-12"

## Sources

- [S1] Understanding JSON Schema: enum. json-schema-org/website (GitHub). https://github.com/json-schema-org/website/blob/main/pages/understanding-json-schema/reference/enum.md . License: BSD-3-Clause. Accessed 2026-11-16.

- [S2] Understanding JSON Schema: schema composition. json-schema-org/website (GitHub). https://github.com/json-schema-org/website/blob/main/pages/understanding-json-schema/reference/combining.md . License: BSD-3-Clause. Accessed 2026-11-16.

- [S3] JSON Schema (Pydantic docs). pydantic/pydantic (GitHub). https://github.com/pydantic/pydantic/blob/main/docs/concepts/json_schema.md . License: MIT. Accessed 2026-11-16.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: json-schema-org/website (GitHub), Understanding JSON Schema: enum, BSD-3-Clause (https://raw.githubusercontent.com/json-schema-org/website/main/LICENSE). Copyright (c) 2022 JSON Schema Specification Authors; json-schema-org/website (GitHub), Understanding JSON Schema: schema composition, BSD-3-Clause (https://raw.githubusercontent.com/json-schema-org/website/main/LICENSE). Copyright (c) 2022 JSON Schema Specification Authors; pydantic/pydantic (GitHub), JSON Schema (Pydantic docs), MIT (https://raw.githubusercontent.com/pydantic/pydantic/main/LICENSE). Copyright (c) 2017 to present Pydantic Services Inc. and individual contributors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
