hey-api / openapi-ts

✨ Turn your OpenAPI specification into a beautiful TypeScript client

Home Page:https://heyapi.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Generated angular client produces compile error due to tree shaking in services

szacskesz opened this issue · comments

Description

The angular client generates a this.http reference in the "class-less" service files, but the this is always undefined because it is an arrow function, so it results in a compile error.

For example:

export const postAuthenticationAuthenticate = (data: PostAuthenticationAuthenticateData = {}): Observable<PostAuthenticationAuthenticateResponse> => { return __request(OpenAPI, this.http, {
    method: 'POST',
    url: '/Authentication/Authenticate',
    body: data.requestBody,
    mediaType: 'application/json-patch+json'
}); };

OpenAPI specification (optional)

No response

Configuration

npx @hey-api/openapi-ts -c angular -i .\api\swaggger\auth-swagger.json -o .\api\generated\auth\ --schemas false

System information (optional)

Windows 11, Node 18.20.3, NPM 10.7.0

commented

Hey @szacskesz, there's a setting to get the previous default, tree-shaking is only enabled by default now but you can turn it off https://heyapi.vercel.app/openapi-ts/migrating.html#v0-46-0

Thanks for the fast response @mrlubos !

I know I can switch back to the previous behaviour, but the main reason I would like to use this library is the tree-shaking.
So I will wait until it's fixed.

commented

It might honestly take a while, Angular client isn't the priority at the moment!