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

Fix code generation for Angular 10 #10464

Merged
merged 2 commits into from
Oct 15, 2020

Conversation

derkoe
Copy link
Contributor

@derkoe derkoe commented Sep 17, 2020

Make ModuleWithProviders generic for all Angular version >= 10 because it is mandatory.

Fixes #10417

Signed-off-by: Christian Köberl christian.koeberl@porscheinformatik.com

PR checklist

  • Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

This adds a generic type info to the ModuleWithProviders in the api.module.ts - this is needed because otherwise the generated code will not compile with Angular >= 10.

Make ModuleWithProviders generic for all Angular version >= 10 because it is mandatory.

Fixes swagger-api#10417

Signed-off-by: Christian Köberl <christian.koeberl@porscheinformatik.com>
@HugoMario
Copy link
Contributor

please build

@HugoMario
Copy link
Contributor

thanks a lot @derkoe !!

@HugoMario HugoMario merged commit 755481e into swagger-api:master Oct 15, 2020
@HugoMario HugoMario added this to the M10 milestone Oct 15, 2020
@Michi-2142
Copy link

When would the maven package 2.4.17 including this changes be pushed to maven central?

@loutocky
Copy link

loutocky commented Nov 4, 2020

I need this fix in codegen cli 3.0.23 (https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.23/). How can I get it there?

@Poitrin
Copy link

Poitrin commented Nov 5, 2020

I need this fix in codegen cli 3.0.23 (https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.23/). How can I get it there?

@loutocky I think the problem lies here: https://github.com/swagger-api/swagger-codegen-generators/blob/master/src/main/resources/handlebars/typescript-angular/api.module.mustache

If I got it right, the code in this repo is used by the codegen CLI (3.0.23). There is already a PR for the -generators repo: swagger-api/swagger-codegen-generators#730

And I agree with #10417 (comment), "The typescript-angular generator maintenance could be better".

@jose-hernandez-iop
Copy link

I have added a comment to swagger-api/swagger-codegen-generators#730 with a suggestion for backwards compatibility with versions of Angular earlier that 10 which is in line with the solution already merged-in for V2.

I would really appreciate it if someone was kind enough to merge these fixes in so that we can generate code for Angular 10 without the need for a custom local build of the code generator plug-in.

@twopelu
Copy link

twopelu commented Feb 3, 2021

I have just tested version 2.4.17 and 18 of swagger-codegen-cli and it still generates the ApiModule as in previous versions, it does not fix the problem. Is that the correct version with the fix? Is is related to this other issue? swagger-api/swagger-codegen-generators#730?

@Michi-2142
Copy link

Which version of angular are you using? Have you added --additional-properties ngVersion=10 to your generate call? See my stackoverflow answer.

@twopelu
Copy link

twopelu commented Mar 5, 2021

I have tested it with 2.4.19 (just released) and it works properly adding the --additional-properties ngVersion=10. Many thanks!

@giovanni-bertoncelli
Copy link

Hi, I've installed the 3.0.25 swagger-codegen version and the issue remains...
The command run was:

swagger-codegen generate -i "http://127.0.0.1:${SERVER_PORT}${DOCS_PATH}/json" -l typescript-angular -o "${DESTINATION_ROOT}" --config "${PROJECT_ROOT}/sdk/sdk.config.json"

Where sdk.config.json is like this:

{
  "ngVersion": "10.0.0",
  "supportsES6": true
}

Am I missing something?

@Michi-2142
Copy link

Please try to set version via --additional-properties ngVersion=10 or try to set angular version in your config file to "ngVersion": "10" and check whether issue remains.

This was referenced Mar 11, 2021
@giovanni-bertoncelli
Copy link

Please try to set version via --additional-properties ngVersion=10 or try to set angular version in your config file to "ngVersion": "10" and check whether issue remains.

@Michi-2142 Already tried both with no luck...

@twopelu
Copy link

twopelu commented May 29, 2021

Just a question, does this fix avoids the need of setting --additional-properties ngVersion=10 to make it work?

@Michi-2142
Copy link

Just a question, does this fix avoids the need of setting --additional-properties ngVersion=10 to make it work?

Sadly no, in this version you need to set settings explicitly.

@raman-nbg
Copy link

@giovanni-bertoncelli did you resolve your issue? I got stuck with the same problem. --additional-properties ngVersion=10 doesn't have any effect...

@raman-nbg
Copy link

With which version is this change available? I'm using 3.0.24.

@HighSoftWare96
Copy link

HighSoftWare96 commented Jun 2, 2021

@raman-nbg I surrendered and replaced the value inline with sed

@raman-nbg
Copy link

I created a local copy of the mustache template (api.module.mustache) in my own repo and applied it with -t argument. That was the quickest workaround I could find.

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

Successfully merging this pull request may close these issues.

[typescript-angular] Bug ModuleWithProviders missing generic type for Angular 10
10 participants