fix: handle non-string query param types in resource registry#747
Open
Bortlesboat wants to merge 1 commit intoMerit-Systems:mainfrom
Open
fix: handle non-string query param types in resource registry#747Bortlesboat wants to merge 1 commit intoMerit-Systems:mainfrom
Bortlesboat wants to merge 1 commit intoMerit-Systems:mainfrom
Conversation
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
Contributor
|
@Bortlesboat is attempting to deploy a commit to the Merit Systems Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
Friendly ping, any blockers on this one? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Numeric and boolean example values in
queryParams(likepage=1orinclude_gt_community_data=true) get silently dropped from the Resource Registry display. Only string-typed values show up.This happens because
expandFieldsinschema.tsonly handlesstringandobjectraw values -- rawnumberandbooleanprimitives fall through to thetypeof 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), onlydurationandincludewere displayed.Changes
schema.tstypeof raw === 'number'inexpandFields-- infersintegervsnumbertype, pre-fills defaulttypeof raw === 'boolean'-- sets type tobooleanwith['true', 'false']enum and pre-fills defaultfieldDefaultextraction to preserve non-string defaults (wastypeof field.default === 'string', nowfield.default != null ? String(field.default))form/index.tsx<pre>inside<pre>in the response viewer -- JSON responses now use a<div>wrapper, plain text keeps<pre>schema.test.ts(new)Test plan
pnpm test:runtsc --noEmitclean for changed files)Closes #623