openapi-ts icon indicating copy to clipboard operation
openapi-ts copied to clipboard

Proper Angular support

Open mightymatth opened this issue 1 year ago • 4 comments

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?

mightymatth avatar Jun 10 '24 11:06 mightymatth

@mightymatth Can you share your config?

mrlubos avatar Jun 10 '24 11:06 mrlubos

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?

mightymatth avatar Jun 13 '24 15:06 mightymatth

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()?

lamuertepeluda avatar Jul 17 '24 15:07 lamuertepeluda

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 avatar Jul 17 '24 15:07 mrlubos

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

mrlubos avatar Nov 22 '24 12:11 mrlubos

Going to close this issue in favor of https://github.com/hey-api/openapi-ts/issues/1072, will be posting updates there!

mrlubos avatar Aug 11 '25 00:08 mrlubos