swagger-api / swagger-api/swagger-codegen
[Typescript-Angular] Generate client code with rxjs for Angular6+
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Feature Request
The client code generated for typescript-angular uses old version of rxjs which is not supported in Angular6+ projects. To make it work you have to manually install rxjs-compat package with npm: npm install rxjs-compat.
Swagger-codegen version
Swagger Hub
Swagger declaration file content or url
Find attached the api definition in yml:
Code generated with Swagger Hub:
typescript-angular-client-generated.zip
Command line used for generation
Error in ng build:
BUILD ERROR
diary-shit-client-lib/src/lib/api/diary.service.ts(229,1): error TS1005: '}' expected.
../node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
diary-shit-client-lib/src/lib/api/diary.service.ts(19,10): error TS2305: Module '"D:/DANI/vscode/dairy-shit-libs/node_modules/rxjs/Observable"' has no exported member 'Observable'.
Error: diary-shit-client-lib/src/lib/api/diary.service.ts(229,1): error TS1005: '}' expected.
../node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
diary-shit-client-lib/src/lib/api/diary.service.ts(19,10): error TS2305: Module '"D:/DANI/vscode/dairy-shit-libs/node_modules/rxjs/Observable"' has no exported member 'Observable'.
at Object.<anonymous> (D:\DANI\vscode\dairy-shit-libs\node_modules\ng-packagr\lib\ngc\compile-source-files.js:65:19)
at Generator.next (<anonymous>)
at fulfilled (D:\DANI\vscode\dairy-shit-libs\node_modules\ng-packagr\lib\ngc\compile-source-files.js:4:58)
at <anonymous>
diary-shit-client-lib/src/lib/api/diary.service.ts(229,1): error TS1005: '}' expected.
../node_modules/rxjs/Observable.d.ts(1,15): error TS2307: Cannot find module 'rxjs-compat/Observable'.
diary-shit-client-lib/src/lib/api/diary.service.ts(19,10): error TS2305: Module '"D:/DANI/vscode/dairy-shit-libs/node_modules/rxjs/Observable"' has no exported member 'Observable'.
Steps to reproduce
- Generate code with Swagger Hub from yml file (see attached)
- Download generated code for typescript-angular (see attached)
- Create new angular project with ng-cli and copy generated code
- Compile with ng build - see errors in console
Suggest a fix/enhancement
Generate the client code with the latest versions of rxjs for Angular6+.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the typescript-angular generator templates and the generated imports shown in diary.service.ts, then reproduce the ng build failure using the attached OpenAPI and generated client archives. Done means the generated Angular client builds for Angular 6+ without requiring rxjs-compat and without the reported TypeScript errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100