Skip to content

fix: strip null defaults from OpenAPI spec for optional params#466

Merged
0237h merged 1 commit intomainfrom
fix/openapi-default-null
Apr 8, 2026
Merged

fix: strip null defaults from OpenAPI spec for optional params#466
0237h merged 1 commit intomainfrom
fix/openapi-default-null

Conversation

@0237h
Copy link
Copy Markdown
Collaborator

@0237h 0237h commented Apr 8, 2026

Summary

Optional scalar query params (e.g. start_block, end_block, protocol) use .default(null) at runtime so handlers receive null instead of undefined. This leaked "default": null into the OpenAPI spec, causing API explorer UIs to pre-fill query params with param=null which triggers validation errors for users.

  • Strip the null default from OpenAPI meta output while preserving runtime .default(null) behavior
  • Affects 31 parameters across EVM/SVM/TVM endpoints
  • Added tests verifying meta output for optional scalar and batched fields

Root cause: createQuerySchema in src/types/zod.ts line 785 — .default(null).meta({...}) propagated the null default into the schema metadata consumed by zod-openapi.


🤖 Generated with Claude Code

Optional scalar params use `.default(null)` at runtime so handlers
receive null instead of undefined. But this leaks `"default": null`
into the OpenAPI spec, causing API explorer UIs to pre-fill query
params with "param=null" which triggers validation errors.

Override the meta to strip the null default from the spec output
while preserving runtime behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@YaroShkvorets YaroShkvorets temporarily deployed to fix/openapi-default-null - token-api PR #466 April 8, 2026 21:44 — with Render Destroyed
@0237h 0237h merged commit 9432f9a into main Apr 8, 2026
2 of 3 checks passed
@0237h 0237h deleted the fix/openapi-default-null branch April 8, 2026 21:45
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.

2 participants