7nohe / openapi-react-query-codegen

OpenAPI React Query Codegen is a code generator for creating React Query (also known as TanStack Query) hooks based on your OpenAPI schema.
https://openapi-react-query-codegen.vercel.app
MIT License
308 stars 31 forks source link

feat: Support string type for `pageParam` and `nextPageParam` options #149

Open 7nohe opened 2 months ago

7nohe commented 2 months ago

resolve #146

github-actions[bot] commented 2 months ago

Coverage Report

Status Category Percentage Covered / Total
🟢 Lines 99.05% (🎯 95%) 2103 / 2123
🟢 Statements 99.05% (🎯 95%) 2103 / 2123
🟢 Functions 100% (🎯 95%) 42 / 42
🟢 Branches 93.57% (🎯 85%) 204 / 218
File Coverage
File Stmts % Branch % Funcs % Lines Uncovered Lines
Changed Files
src/createUseQuery.mts 99.47% 94.5% 100% 99.47% 299-302
Generated in workflow #331
JonasPf commented 2 months ago

I'm running into a problem with initialPageParam here. My api expects no or an empty initial page parameter. initialPageParam="" generates code that sends page=0. I believe the reason is that formatOptions => safeParseNumber converts the empty string to 0.

I can work around it by setting initialPageParam="''" which generates code that sends page=%27%27 which works with my api but it's a bit ugly.

Ideally there would be a omitInitialPageParam parameter that would change it so that no page parameter is send at all.