-
Notifications
You must be signed in to change notification settings - Fork 6k
Fix code generation for Angular 10 #10464
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
Conversation
Make ModuleWithProviders generic for all Angular version >= 10 because it is mandatory. Fixes swagger-api#10417 Signed-off-by: Christian Köberl <[email protected]>
please build |
thanks a lot @derkoe !! |
When would the maven package 2.4.17 including this changes be pushed to maven central? |
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". |
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. |
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? |
Which version of angular are you using? Have you added |
I have tested it with 2.4.19 (just released) and it works properly adding the |
Hi, I've installed the 3.0.25 swagger-codegen version and the issue remains...
Where {
"ngVersion": "10.0.0",
"supportsES6": true
} Am I missing something? |
Please try to set version via |
@Michi-2142 Already tried both with no luck... |
Just a question, does this fix avoids the need of setting |
Sadly no, in this version you need to set settings explicitly. |
@giovanni-bertoncelli did you resolve your issue? I got stuck with the same problem. |
With which version is this change available? I'm using 3.0.24. |
@raman-nbg I surrendered and replaced the value inline with |
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. |
Make ModuleWithProviders generic for all Angular version >= 10 because it is mandatory.
Fixes #10417
Signed-off-by: Christian Köberl [email protected]
PR checklist
./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\
.3.0.0
branch for changes related to OpenAPI spec 3.0. Default:master
.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.