[BUG][typescript-inversify] Type mismatch between service model and HttpClient requirement
Created by: siada
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
When using typescript in strict
mode, the code won't compile if your spec has an optional requestBody because the HttpClient defines body
as {}
which means 'any except null or undefined'
openapi-generator version
4.1.0
Steps to reproduce
Generated service method:
public apiAccountLoginPost(loginViewModel?: LoginViewModel, observe?: 'body', headers?: Headers): Promise<LoginViewModelResult>;
public apiAccountLoginPost(loginViewModel?: LoginViewModel, observe?: 'response', headers?: Headers): Promise<HttpResponse<LoginViewModelResult>>;
public apiAccountLoginPost(loginViewModel?: LoginViewModel, observe: any = 'body', headers: Headers = {}): Promise<any> {
HttpClient:
post(url: string, body: {}|FormData, headers?: Headers): Observable<HttpResponse> {
return this.performNetworkCall(url, "POST", this.getJsonBody(body), this.addJsonHeaders(headers));
}
Error:
Related issues/PRs
#3607
Suggest a fix
I believe changing the {}
to any
in the HttpClient will resolve this, however I don't know enough about typescript to understand the impact this may have
I'm happy to organise the PR for this if you agree with this change