You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow pageParam to be a string within generated infiniteQueries #146
Describe the bug
Our API uses string as page parameters, such as base64 encoded global ids, however when generating infinite queries where the type of pageParam is not a number within the schema
To Reproduce
Generate schemas where the page types are strings using openapi-rq --pageParam nextPageKey --nextPageParam nextPageKey -i specification.json -c axios
See the generated queries/infiniteQueries.ts file for type error
OpenAPI spec file
Would like to keep private
Expected behavior
If the schema defines the page token as a string then the generated types should also require a string.
The generator now resolves the page parameter's type from the schema — including through type aliases — and emits a matching type in all three positions instead of hardcoding number. For a spec where the cursor is Cursor: { type: string }:
No as number on the string path, and initialPageParam is quoted so it stays a string.
Two things worth knowing for a cursor-based API, since a default of "1" is rarely meaningful as a cursor:
--initialPageParam "" emits initialPageParam: ""
--omitInitialPageParam (added in v3) omits the page parameter from the first request entirely, which is usually what a cursor API wants — the server returns the first page when no cursor is supplied
Available on latest (npm i @7nohe/openapi-react-query-codegen@3). Thanks for the report, and sorry it took a while.
Activity
feat: make initialPageParam and getNextPageParam overridable in infin…
7nohe commentedon Aug 11, 2026
Fixed in v3.0.0.
The generator now resolves the page parameter's type from the schema — including through type aliases — and emits a matching type in all three positions instead of hardcoding
number. For a spec where the cursor isCursor: { type: string }:No
as numberon the string path, andinitialPageParamis quoted so it stays a string.Two things worth knowing for a cursor-based API, since a default of
"1"is rarely meaningful as a cursor:--initialPageParam ""emitsinitialPageParam: ""--omitInitialPageParam(added in v3) omits the page parameter from the first request entirely, which is usually what a cursor API wants — the server returns the first page when no cursor is suppliedAvailable on
latest(npm i @7nohe/openapi-react-query-codegen@3). Thanks for the report, and sorry it took a while.