swagger-api / swagger-api/swagger-codegen

[Typescript-Angular] Generate client code with rxjs for Angular6+

Open
#9,227 5 comments 12 reactions 0 assignees View on GitHub

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:

openapi.zip

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
  1. Generate code with Swagger Hub from yml file (see attached)
  2. Download generated code for typescript-angular (see attached)
  3. Create new angular project with ng-cli and copy generated code
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.