Skip to content

fix(schema): support boolean "false" subschemas#3004

Merged
schani merged 8 commits into
masterfrom
agent/fix-issue-1896
Jul 21, 2026
Merged

fix(schema): support boolean "false" subschemas#3004
schani merged 8 commits into
masterfrom
agent/fix-issue-1896

Conversation

@schani

@schani schani commented Jul 20, 2026

Copy link
Copy Markdown
Member

Bug

Fixes #1896.

quicktype crashed with Error: Schema "false" is not supported at <ref> on
valid draft-07+ JSON Schema documents that use a boolean subschema
(false) as a property/items value — e.g. "patches": false to mean "this
property is disallowed here." This is a normal part of the JSON Schema spec
(commonly emitted by tools that compile oneOf/allOf branches), and it
appears in the real-world Amazon Selling Partner Listings Feed schema
attached to the issue.

Repro before the fix:

node dist/index.js --src-lang schema --lang csharp amazon.schema
# Error: Schema "false" is not supported at .../properties/messages/items/oneOf/0/properties/patches.

Exit code 1, no code generated at all, for any target language.

Root cause

In packages/quicktype-core/src/input/JSONSchemaInput.ts, toType()
handled schema === true (mapping it to the any primitive) but asserted
against schema === false, throwing SchemaFalseNotSupported and aborting
the whole run. items: false hit a similar rejection in the array-items
handling.

Fix

  • false subschemas now map to quicktype's existing none primitive type —
    the same type already used to represent an empty union. A later pass
    (noneToAny, already run in the pipeline) converts none to any before
    rendering, so false now behaves like an always-empty/unknown value
    instead of crashing. true keeps mapping to any as before.
  • items: false is now accepted the same way object properties are (was
    previously rejected as "must be string or array").
  • resolveIntersections (used for allOf) now treats none as an
    absorbing member, so allOf: [false, ...] correctly resolves to none
    (nothing valid) rather than mis-simplifying.

Test coverage

Added test/inputs/schema/boolean-subschema.schema (+
boolean-subschema.1.json sample), covering:

  • false as a plain property value
  • items: false inside an array schema
  • false inside an allOf (intersection)

This is a new JSON Schema fixture input under test/inputs/schema/, so it
runs automatically against every language's schema-<language> fixture in
CI (per the repo's fixture-based testing convention).

Verification performed locally

  • npm run build passes.
  • Re-ran the original issue repro (amazon.schema from Can not create C# code or any other from Amazon json schemas #1896) with
    --lang csharp: now generates valid C# (458 lines, exit 0) instead of
    erroring.
  • QUICKTEST=true FIXTURE=schema-typescript script/test test/inputs/schema/boolean-subschema.schema: passes.
  • QUICKTEST=true FIXTURE=schema-typescript script/test (full TS schema
    suite): passes, aside from one pre-existing, unrelated failure
    (vega-lite.schema hits a TypeScript TS2411 index-signature error) that
    I confirmed also reproduces identically on master without this change.
  • npm run test:unit: all 163 unit tests pass.
  • The C#-specific fixture (schema-csharp) could not be run locally
    (dotnet is not installed in this environment); CI will validate it and
    the other language fixtures.

🤖 Generated with Claude Code

schani and others added 2 commits July 20, 2026 17:18
Draft-07+ JSON Schema allows a subschema to be the literal boolean
`false`, meaning "nothing is valid here" (e.g. to disallow a property
in a particular oneOf branch). quicktype's schema input unconditionally
rejected this with "Schema \"false\" is not supported", aborting
codegen entirely for real-world schemas that use the pattern (such as
the Amazon Selling Partner Listings Feed schema from the issue).

`false` subschemas now map to quicktype's existing "none" primitive
type, the same mechanism already used for empty unions; a later pass
(noneToAny) converts it to "any" before rendering. `items: false` is
now also accepted the same way properties are. Intersections
(allOf) treat "none" as absorbing, matching normal empty-type
semantics.

Added test/inputs/schema/boolean-subschema.schema (+ .1.json sample)
covering false as a property value, as items, and inside allOf.

Co-Authored-By: gpt-5.6-sol via pi <noreply@openai.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Mark Probst and others added 6 commits July 20, 2026 20:29
The bare boolean-subschema.1.fail.json ran for every language but relied
on a type violation (object supplied for the string 'foo') that Jackson
leniently coerces to "", so kotlin/schema-kotlin did not reject it and
the round-trip produced {"empty":[],"foo":""} instead of failing.

Replace it with a scalar supplied for the required 'empty' array, which
every target's deserializer rejects (no language coerces a scalar into a
list): verified via the real fixture harness for schema-golang and
schema-python, and manually for go/rust/python generated code.

Co-Authored-By: Claude <noreply@anthropic.com>
…alidation gap (#3004)

Co-Authored-By: gpt-5.6-sol via pi <noreply@openai.com>
Bring the branch up to date with master so CI (which tests the
PR-head/master merge) reflects current mainline state.
test/unit/cjson-enum-default.test.ts, pulled in by merging master, expected
alphabetical enum-case order, but quicktype preserves JSON Schema
declaration order for enum cases in cJSON (and every other language). Update
the expectation to match actual generator output.

Co-Authored-By: gpt-5.6-sol via pi <noreply@openai.com>
…cking (#3004)

Elixir's generated from_map/1 assigns JSON fields directly with no type
validation (same pre-existing, already-documented limitation that already
excludes strict-optional.schema and required.schema for this language), so
the new boolean-subschema.1.fail.json type-mismatch case can't be enforced.

Co-Authored-By: gpt-5.6-sol via pi <noreply@openai.com>
…ation (#3004)

test/fixtures/haskell/Main.hs unconditionally encodes the decoded Maybe
result, so a failed decode prints "null" and exits 0 (same pre-existing,
already-documented limitation that already excludes
nested-intersection-union.schema and prefix-items.schema for this
language), so the new boolean-subschema.1.fail.json case can't be detected.

Co-Authored-By: gpt-5.6-sol via pi <noreply@openai.com>
@schani
schani merged commit 15ace60 into master Jul 21, 2026
28 checks passed
@schani
schani deleted the agent/fix-issue-1896 branch July 21, 2026 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can not create C# code or any other from Amazon json schemas

1 participant