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

[REQ][typescript-angular] Angular 9 providedIn support #6432

Closed
UnleashSpirit opened this issue May 26, 2020 · 5 comments · Fixed by #8324
Closed

[REQ][typescript-angular] Angular 9 providedIn support #6432

UnleashSpirit opened this issue May 26, 2020 · 5 comments · Fixed by #8324

Comments

@UnleashSpirit
Copy link
Contributor

Hello,
Angular 9 brings new level for @Injectable, 'any' and 'platform'

Is your feature request related to a problem? Please describe.

No

Describe the solution you'd like

Removing the 'providedInRoot' option as boolean and gives a new one.
Something like 'providedIn' with all the choices :

  • none
  • root
  • any
  • platform

May be with keeping default as root ?
And may be a ApiModule.forPlatform() ? (don't even know if it makes sense)

Additional context

I face that 'issue', which is not a real one for now more an improvement, during Angular Elements creation (WebComponent).
In my case I have a service provided un 'platform' level which also depend on generated service from openapi v3. But a 'platform' service can't use a root level service (null injector)

In any case I think that supporting the new levels of Angular 9 Injectable would be appreciate

@macjohnny
Copy link
Member

@UnleashSpirit would you like to implement this?

@UnleashSpirit
Copy link
Contributor Author

Waow hmm yeah I can try.
Don't know when but I could be fun :)
How it works ? Fork then modify then pull request right ?

@macjohnny
Copy link
Member

Waow hmm yeah I can try.

great

How it works ? Fork then modify then pull request right ?

exactly, here are some starting points:

this.cliOptions.add(CliOption.newBoolean(PROVIDED_IN_ROOT,
"Use this property to provide Injectables in root (it is only valid in angular version greater or equal to 6.0.0).",
false));

{{^providedInRoot}}
@Injectable()
{{/providedInRoot}}
{{#providedInRoot}}
@Injectable({
providedIn: 'root'
})
{{/providedInRoot}}

@macjohnny macjohnny changed the title [REQ] Angular 9 providedIn support [REQ][typescript-angular] Angular 9 providedIn support May 28, 2020
@jogelin
Copy link

jogelin commented Sep 30, 2020

@UnleashSpirit did you progress on this one ?

@UnleashSpirit
Copy link
Contributor Author

Hi, unfortunately not yet :(
Trying to find time but hard these days

UnleashSpirit added a commit to UnleashSpirit/openapi-generator that referenced this issue Jan 6, 2021
Adding new option, providedIn, for generator typescript-angular
Keep providedInRoot for backward compatibility but mark as deprecated
for Angular 9+

fix: OpenAPITools#6432
macjohnny pushed a commit that referenced this issue Jan 6, 2021
* feat: add providedIn for Angular 9+

Adding new option, providedIn, for generator typescript-angular
Keep providedInRoot for backward compatibility but mark as deprecated
for Angular 9+

fix: #6432

* doc: providedIn

infos about providedIn
Mark providedInRoot as deprecated

* doc: run generate-samples for typescript

using typescript-angular-v9-provided-in-any.yaml

* refactor: runned ensure-up-to-date locally

* refactor: api.module.mustache rely on providedIn too

* doc: re-generate samples
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants