Centeva / TypeScripter

A tool to generate Typescript classes from c# models.
MIT License
4 stars 5 forks source link

Handle null and undefined values in generated DataService GET methods #43

Closed pdeffendol closed 5 years ago

pdeffendol commented 5 years ago

If a parameter to a GET call is set to null or undefined, then leave that parameter blank in the generated URL.

Fixes #38

For example, the original generated code would look like this:

getStuff: (id: number): Observable<AgencyPart> => this.http.get<Stuff>(`${this.apiRelativePath}/Stuff/GetStuff?id=${id}`).pipe(map(value => new Stuff(value))).pipe(catchError(this.handleError))

Resulting in a URL like this if a null was passed:

/api/Stuff/GetStuff?id=null

This update would result in:

/api/Stuff/GetStuff?id=