swr-openapi version
5.3.1
Description
The current implementation of createQueryHook and createInfiniteHook doesn't enforce exact object literal validation for query and path parameters, allowing invalid properties to pass TypeScript compilation without errors.
This leads to runtime issues and reduces the type safety benefits that developers expect from a TypeScript-first OpenAPI integration.
Reproduction
import createClient from 'openapi-fetch';
import { createQueryHook } from 'swr-openapi';
import type { paths } from './generated'; // From openapi-typescript
const client = createClient<paths>();
const useQuery = createQueryHook(client, 'api');
// ❌ This should cause a TypeScript error but doesn't
const { data } = useQuery('/pets', {
params: {
query: {
limit: 10,
invalid_property: 'should error', // No TypeScript error!
},
},
});
// ❌ Same issue with infinite queries
const useInfiniteQuery = createInfiniteHook(client, 'api');
const { data: infiniteData } = useInfiniteQuery('/pets', pageIndex => ({
params: {
query: {
limit: 10,
another_invalid_prop: 'also no error', // No TypeScript error!
},
},
}));
Expected result
Expected behavior: TypeScript should show compilation errors for invalid_property and another_invalid_prop.
Actual behavior: Code compiles without errors, potentially causing runtime issues.
Extra
swr-openapi version
5.3.1
Description
The current implementation of
createQueryHookandcreateInfiniteHookdoesn't enforce exact object literal validation for query and path parameters, allowing invalid properties to pass TypeScript compilation without errors.This leads to runtime issues and reduces the type safety benefits that developers expect from a TypeScript-first OpenAPI integration.
Reproduction
Expected result
Expected behavior: TypeScript should show compilation errors for
invalid_propertyandanother_invalid_prop.Actual behavior: Code compiles without errors, potentially causing runtime issues.
Extra