hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.41k stars 106 forks source link

Proper Angular support #667

Open mightymatth opened 5 months ago

mightymatth commented 5 months ago

Description

It seems like Angular module compatibility has been broken after forking openapi-typescript-codegen. Previously, we used --name flag to set a module name that would contain all the services, and we could utilize OpenAPI and BaseHttpClient as injection tokens, which is a common way of doing configuration in Angular.

However, when generating the client via code (using createClient and setting UserConfig), there is no way of creating a module, thus not having the ability to use injection tokens at all.

I haven't seen any mentions of that topic in the changelog, so I'm curious if was that made on purpose or by mistake.

Btw. is there any ongoing effort to create an Angular plugin?

mrlubos commented 5 months ago

@mightymatth Can you share your config?

mightymatth commented 5 months ago

My config is irrelevant in this context. I'm just asking why name property is deprecated in ClientConfig. If something is deprecated, it should be noted what to use instead. If I understood the idea, you're making separate libraries for each client, and only in that case, name is deprecated.

So, can we still use name if using a legacy Angular client?

lamuertepeluda commented 4 months ago

hi there any news on this? I was happy with the older version because they support Angular, but now I see a lot of development going on but the angular generator is stuck to an older version.

Is there any plan about adding a new @hey-api/client-angular or should we consider Angular support as something legacy/dead?

And if it's legacy/dead, does anybody know if the fetch client is compatible with $httpService without breaking an existing angular application and without loosing the "advantages" of using $httpService over fetch()?

mrlubos commented 4 months ago

If there was more interest in Angular support it would get prioritised, but that's not the case right now @lamuertepeluda. I am definitely open to pull requests fixing any of the broken functionality. Sadly, I don't have a good overview of the state of the support for Angular at the moment because as you correctly noted, it has not been my focus.

@mightymatth feel free to use name as long as it's available. There's a discussion around its usage https://github.com/hey-api/openapi-ts/discussions/619, I need to understand for what use cases it's currently being used before removing it. And, of course, those use cases will need to be migrated or explicitly unhandled. For now it's a warning to get people to react.

tl;dr Angular support is not currently maintained for new features. If it works with any new features, that's a happy accident, but it's not being tested against them. If Angular became broken, please let me know what broke and I will try to fix. The goal is to keep Angular working as before, definitely not trying to kill it.

mrlubos commented 4 days ago

Related https://github.com/hey-api/openapi-ts/issues/1072