Skip to content

fix: handle non-string query param types in resource registry#747

Open
Bortlesboat wants to merge 1 commit intoMerit-Systems:mainfrom
Bortlesboat:fix/non-string-query-params-and-response-markup
Open

fix: handle non-string query param types in resource registry#747
Bortlesboat wants to merge 1 commit intoMerit-Systems:mainfrom
Bortlesboat:fix/non-string-query-params-and-response-markup

Conversation

@Bortlesboat
Copy link
Copy Markdown

Problem

Numeric and boolean example values in queryParams (like page=1 or include_gt_community_data=true) get silently dropped from the Resource Registry display. Only string-typed values show up.

This happens because expandFields in schema.ts only handles string and object raw values -- raw number and boolean primitives fall through to the typeof raw !== 'object' guard and get skipped.

Reported in #623 with CoinGecko trending pools as an example: out of 4 query params (page, duration, include_gt_community_data, include), only duration and include were displayed.

Changes

schema.ts

  • Handle typeof raw === 'number' in expandFields -- infers integer vs number type, pre-fills default
  • Handle typeof raw === 'boolean' -- sets type to boolean with ['true', 'false'] enum and pre-fills default
  • Fix fieldDefault extraction to preserve non-string defaults (was typeof field.default === 'string', now field.default != null ? String(field.default))

form/index.tsx

  • Fix nested <pre> inside <pre> in the response viewer -- JSON responses now use a <div> wrapper, plain text keeps <pre>

schema.test.ts (new)

  • 6 tests covering numeric, boolean, float, mixed-type params, and non-string defaults

Test plan

  • All 6 new tests pass via pnpm test:run
  • No new TypeScript errors (tsc --noEmit clean for changed files)
  • View a resource with mixed query param types (e.g. CoinGecko trending pools) -- all params should appear

Closes #623

Numeric and boolean example values in queryParams (e.g. page=1,
include_gt_community_data=true) were silently dropped by expandFields
because it only handled string and object types. Also fixes non-string
schema defaults being lost, and a nested <pre> in the response viewer.

Closes Merit-Systems#623
@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 28, 2026

@Bortlesboat is attempting to deploy a commit to the Merit Systems Team on Vercel.

A member of the Team first needs to authorize it.

@Bortlesboat
Copy link
Copy Markdown
Author

Friendly ping, any blockers on this one?

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.

Resource Registry not displaying non-string query parameters

1 participant