Skip to content

DeepObject query parameters generate incorrect infiniteQueryOptions with dot notation #2639

@WooWan

Description

@WooWan

Description

Bug Description
openapi-ts with tanstack/query plugin generates incorrect query parameter names for deepObject style parameters in infiniteQueryOptions and causes TypeScript errors. This is the only blocker preventing us from adopting openapi-ts. We use query param object style for existing APIs, so we need to support it. As far as I know, query param object official spec since OpenAPI 3.0
Thanks for your lovely library!

Current Output

const page = typeof pageParam === 'object' ? pageParam : {
    query: {
        'pageable.page': pageParam  // Wrong: uses dot notation
    }
};

error:

Type 'Pick<Pick<Options<GetDeepObjectData>, "body" | "path" | "query" | "headers" | "baseUrl"> & { _id: string; _infinite?: boolean | undefined; tags?: readonly string[] | undefined; }, "body" | ... 2 more ... | "headers"> | { ...; }' is not assignable to type 'Pick<Pick<Options<GetDeepObjectData>, "body" | "path" | "query" | "headers" | "baseUrl"> & { _id: string; _infinite?: boolean | undefined; tags?: readonly string[] | undefined; }, "body" | ... 2 more ... | "headers">'.
  Type '{ query: { 'pageable.page': number; }; }' is not assignable to type 'Pick<Pick<Options<GetDeepObjectData>, "body" | "path" | "query" | "headers" | "baseUrl"> & { _id: string; _infinite?: boolean | undefined; tags?: readonly string[] | undefined; }, "body" | ... 2 more ... | "headers">'.
    Types of property 'query' are incompatible.
      Object literal may only specify known properties, and ''pageable.page'' does not exist in type '{ pageable: { page?: number | undefined; size?: number | undefined; sort?: string[] | undefined; }; }'

Reproducible example or configuration

https://stackblitz.com/~/github.com/WooWan/openapi-ts-reproduction

OpenAPI specification (optional)

No response

System information (optional)

Environment

openapi-ts: 0.83.1
TypeScript: 5.9.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug 🔥Something isn't workingclientClient package relatedjavascriptPull requests that update Javascript code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions