Skip to content

TypeScript Error: Missing url Property Required by DataShape in generated services #176

Closed
@imreb-ff

Description

@imreb-ff

Bug Report

Describe the bug
The TypeScript compiler throws an error indicating that the type GetWizardData does not satisfy the constraint DataShape. The DataShape type requires a url property, which is missing in GetWizardData.

Error details:

src/openapi/requests/services.gen.ts:106:83 - error TS2344: Type 'GetWizardData' does not satisfy the constraint 'DataShape'.
  Property 'url' is missing in type 'GetWizardData' but required in type 'DataShape'.

106 export const getWizard = <ThrowOnError extends boolean = false>(options?: Options<GetWizardData, ThrowOnError>) => {
																					  ~~~~~~~~~~~~~ 
 return (options?.client ?? client).get<GetWizardResponse, GetWizardError, ThrowOnError>({

  node_modules/@hey-api/client-axios/dist/index.d.ts:163:5
    163     url: string;
            ~~~
    'url' is declared here.

The generated function:

export const getWizard = <ThrowOnError extends boolean = false>(options?: Options<GetWizardData, ThrowOnError>) => { 
  return (options?.client ?? client).get<GetWizardResponse, GetWizardError, ThrowOnError>({
    ...options,
    url: '/api/v1/wizard'
  }); 
};

To Reproduce
Steps to reproduce the behavior:

Generate TypeScript types and services using @hey-api.
Use the getWizard function with the generated type GetWizardData.
Run tsc to compile the project.
Observe the TypeScript error in the compilation output.

OpenAPI spec file
If possible, please upload or share a link to the OpenAPI spec file used to generate these types.

Expected behavior
The GetWizardData type should satisfy the DataShape constraint by including all required properties, including url. The project should compile successfully without errors.

Screenshots
If applicable, include screenshots or logs showing the issue.

OS: Windows 11
Version: @hey-api/client-axios v0.3.4
@7nohe/openapi-react-query-codegen v2.0.0-beta.3

Additional context

This issue occurs in the file src/openapi/requests/services.gen.ts at line 106.
It seems that the generated GetWizardData type from @hey-api does not include the url property required by DataShape. This might indicate a mismatch between the OpenAPI spec and the code generator configuration.
Potential resolution could involve modifying the OpenAPI spec, generator configuration, or manually extending the generated type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions