Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
imreb-ff opened this issue Jan 3, 2025 · 1 comment

Comments

@imreb-ff
Copy link

imreb-ff commented Jan 3, 2025

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.

@mghizzo
Copy link

mghizzo commented Jan 11, 2025

It works for me using @hey-api/client-axios version 0.2.9.
This is most likely due to this repo still using @hey-api/openapi-ts version 0.53.8.

Potential related issue: hey-api/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants