flowup / api-client-generator

Angular REST API client generator from Swagger YAML or JSON file with camel case settigs
MIT License
115 stars 21 forks source link

Type Errors #15

Closed warmans closed 6 years ago

warmans commented 6 years ago

Hi,

I'm having some issues with my generated code. On build I get a bunch of errors like:

.../api-client-service.ts(379,59): error TS2345: Argument of type 'HttpOptions' is not assignable to parameter of type '{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: "body"; params?: Ht...'.
  Types of property 'responseType' are incompatible.
    Type '"text" | "arraybuffer" | "blob" | "json"' is not assignable to type '"json"'.
      Type '"text"' is not assignable to type '"json"'.

This seem to me like it's probably a versioning issue, e.g. the typescript or angular versions are wrong. I'm using Angular 4.x.x with typescript 2.4.0. I tried angular 5.x.x and TS 2.6.x and has the same issues. Maybe the code you generate targets an older angular version?

Additionally HttpObserve is not exported in /common/http. To get the generated code to build at all I've edited the HttpOptions interface as follows:

interface HttpOptions {
  headers?: HttpHeaders,
  params?: HttpParams,
  reportProgress?: boolean,
  withCredentials?: boolean,
}

Any ideas?

vmasek commented 6 years ago

@warmans please try again with the latest version and let me know if there is some error.

warmans commented 6 years ago

Yep, all working as expected now. Thanks.