api-client-generator
api-client-generator copied to clipboard
Include "observe" and "responseType" on a per request basis
Hey,
First of all: I really like this library and I use it for all of my projects at work, so thanks for the work you put into it.
My issue is the requestHttpOptions you are able to pass when executing a request. The HttpOptions currently contain these options:
export interface HttpOptions {
headers?: HttpHeaders;
params?: HttpParams;
reportProgress?: boolean;
withCredentials?: boolean;
}
What I'm missing is the observe and responseType option that the HttpClient has:
function get<T>(url: string, options?: {
headers?: HttpHeaders | {
[header: string]: string | string[];
};
observe?: 'body';
params?: HttpParams | {
[param: string]: string | string[];
};
reportProgress?: boolean;
responseType?: 'json';
withCredentials?: boolean;
}): Observable<T>;
It would also be nice to set these on a per request basis like the HttpClient allows you to.
The problem is that our API has an endpoint which downloads a file, so for only that one request I would have to set the responseType to 'blob' and the observe to 'response' so I can read the ContentDisposition-header and filename.
Would it be possible to add this? Thanks!
@Mvrlex Hello, thank you and thanks for the report :+1:
It shouldn't be a problem to add this functionality and I will have a look into it. It will require an overload to the methods and some changes to the method logic, so it will be out after some testing is done. I'll try to announce an ETA as soon as I'll have some estimate.
@vmasek Hello, are there any updates on this?
Hello, this was held up as it requires more test cases. But I could be able to prioritize it at least for experimental use.
We are currently refactoring our project and I've just added the new api-client-generator 5.0.0-beta.5. It works now. Nice implementation.