how to use openapi-generator-cli typescript-client code for error handling

990 Views Asked by At

Using angular 13 I generate my service methods from an open-api 3.0 spec file with the following command:

"openapi-gen": "openapi-generator-cli generate -g typescript-angular -o src/generated/api -i ../oeltank-api/src/main/resources/static/oeltank.api.yaml",

The generated service now can be uses with

    this.oeltankService.calculateLiterFromCm(cm).subscribe(
      data => this.result = data,
      error => this.error = error.error
    );

This works for the good case and the error case.

BUT the subscribe method is deprecated with the message:

deprecated
Observable<number>.subscribe(
     next?: ((value:number) => void) | null | undefined,
     error?: ((error:any) => void | null | undefined,
     complete?: (() => void) | null | undefined): Subscription

Instead of passing separate callback arguments, use an observer argument. Signatures taking separate callback argments will be removed in v8. 
Details: https://rxjs.dev/deprecations/subscribe-arguments

But the rxjs.dev-page does not give any help. So how do I have to use the observer correctly?

0

There are 0 best solutions below