Skip to content

Represent null example values as null, drop null defaults and examples - #294

Merged
adamw merged 3 commits into
masterfrom
fix-null-values
Oct 26, 2026
Merged

adamw merged 3 commits into
masterfrom
fix-null-values

Conversation

@adamw

@adamw adamw commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #293.

  • null: Schema.nullable and the decoder now use ExampleSingleValue(null) for null, instead of the "null" string. JSON null and the string "null" no longer mix.
  • tapir Option defaults: e.g. jsonBody[Option[String]].default(None) passes "null". Keep string defaults and examples as strings, and keep null const and default #293 wrote it as the string 'null'. In string schemas, JSON-encoded nulls are now unwrapped too, so it's dropped as before.
  • Dropped nulls: null const, default and examples are dropped again when encoding (YAML printing dropped them anyway), so JSON and YAML output are the same. A null const or default decodes as None, as before Keep string defaults and examples as strings, and keep null const and default #293.
  • Docs: ExampleSingleValue and ExampleMultipleValue now document what the value they hold means, including when a String is a string and when it is encoded JSON.

adamw added 3 commits October 25, 2026 19:28
- Schema.nullable and the decoder use ExampleSingleValue(null) for null,
  instead of the "null" string, so JSON null and the string "null" no
  longer mix
- in string schemas, unwrap JSON-encoded nulls too (tapir passes "null"
  for an Option default)
- drop null const, default and examples, as before #293, so that JSON
  and YAML output are the same
@adamw
adamw merged commit 3a7b0f7 into master Oct 26, 2026
10 checks passed
@adamw
adamw deleted the fix-null-values branch October 26, 2026 13:13
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.

1 participant