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'
4.1.0
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:

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
馃憤 Thanks for opening this issue!
馃彿 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
how about changing it to body?: Object|FormData and also adapting
https://github.com/siada/openapi-generator/blob/b54a5266ac9824306e5904554275d809dcd66057/modules/openapi-generator/src/main/resources/typescript-inversify/HttpClient.mustache#L40
to handle undefined/null values?
@gualtierim what is your opinion?
For handling the undefined/null values should getJsonBody return null, empty string, or {} ?
For handling the undefined/null values should getJsonBody return null, empty string, or
{}?
good question, I guess undefined ?
I agree to change the signature of httpClient with Object|FormData. getJsonBody should return undefined, I will try it the next week
Also, addJsonHeaders's headers parameter should be optional.
@deluksic I already fixed that in PR #3607 this issue has been opened as a discussion from that
@gualtierim Did you manage to get around to trying the solution out yet?
Most helpful comment
@deluksic I already fixed that in PR #3607 this issue has been opened as a discussion from that