Just wondering if there is an angular2 client in the works?
If not, I'll take a crack one.
There's one for Typescript and here is an example for Petstore: https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/typescript-angular.
Would that meet your requirement?
Yes, I found those ones, but they're all for angular1.
Looking at utilising Typescript and Angular2
What about updating that to support Angular2?
For the Java client, we can use the library option to specify which HTTP library (e.g. Retrofit, Jersey, etc) to use. Maybe we can use similar approach to support both Angular1.x and 2.x in the same typescript-angular client.
cc @tandrup @mhardorf as they might have some work in progress for typescript angular2
Started some work on a template here https://github.com/damienpontifex/TypescriptAngular2CodeGen and using the typescript-angular language with the swagger-codegen tool.
Still to sort out some issues with imports of the model classes, but a start that generates with the updated types and angular2 style
+1
+1
++1
+1
Thanks @damienpontifex. May I know if you need any help with the import of model classes?
Hi @wing328 yes, help with importing model classes would be good.
Currently I have all types exported via api.d.ts similar to how typings would have worked with angular1. Although having issues getting the appropriate import statement when there is an intra dependency.
As an example, if you run swagger-codegen generate -i http://petstore.swagger.io/v2/swagger.json -o client/petstore -l typescript-angular -t . from inside my template repo, the generated Pet class requires an import of Category and Tag but I haven't come across anything thus far to put just the required import statements in the model.mustache file for generators.
Hope this makes some sort of sense.
Also, I agree with your previous comment, that it would be good to have a flag to specify which version. Maybe library or --angular2 as appropriate. I'm still to dig through the Java side of the codebase to breakdown how this needs to be integrated. Any assistance here, would also be appreciated.
You can use the {{imports}} mustache tag. For example, ObjC model template (header)
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/objc/model-header.mustache#L10
outputs the following for Pestore
https://github.com/swagger-api/swagger-codegen/blob/master/samples/client/petstore/objc/SwaggerClient/SWGPet.h
For specifying the library option in the Java code generator, here are some good starting points:
https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaClientCodegen.java#L105
@damienpontifex has submitted a PR to include the work he's done so far.
If anyone from the community wants to continue the work, please reply to let us know.
I've created a client project, using some of damienpontifex 's templates, altering them a bit to make the generated code compile and actually work, and included them in a java project created using the swagger cli. see here:
https://github.com/sapienstech/typescript-angular2-swagger-codegen
Works great for our rather complex typescript project.
Please let me know if you'd like me to submit a PR.
I created a pull request based on roni-fratchi's work. see #2645.
PR merged into master. Please pull the latest.
Most helpful comment
I created a pull request based on roni-fratchi's work. see #2645.