Looking at the lines https://github.com/swagger-api/swagger-codegen/blob/f3e19e0fdc1ae6416c37bb637521323d88939a9f/modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache#L241-L252
If no body and form params are defined in put or post (which is possible), the generated code looks like this:
return this.httpClient.put<any>(`${this.basePath}/some-url/${encodeURIComponent(String(id))}`, {
headers: headers,
withCredentials: this.configuration.withCredentials
});
which causes
{
headers: headers,
withCredentials: this.configuration.withCredentials
}
to be treated and sent as the body. This means a body, which isn't expected by the server, is sent and headers, which are expected, are not sent.
Master branch, latest commit I have is https://github.com/swagger-api/swagger-codegen/commit/bf74e33c52cdb125bcd30e7742d116352f8f9ded
This is when the bug was introduced - https://github.com/swagger-api/swagger-codegen/pull/6295
I'm not sure what would be the best way to fix it. For the template it would be easiest to just have always some default body param if necessary, which would be simply null, for the Java backend code it would be nicer to solve it simply on the template, but since you need a check if it's a PATCH, PUT or POST operation, I don't see how to do it in mustache. Maybe introducing a flag like expectsBody?
@pgrm can you check whether this is still an issue with https://github.com/swagger-api/swagger-codegen/pull/6574?
@macjohnny I've just now used the latest master to generate my new client, and the issue is still there
@pgrm I will try to create a fix and open a new PR
@macjohnny FYI, this is how I solved it for now - https://github.com/apaleo/swagger-codegen/commit/57cf9b6388c78bd821263ff9c02d989be4781caf (I can see that I forgot to update the comment :wink: but it seems to be working)
@pgrm glad to see you found a fix. could you please open a new PR with your changes and generate the samples? I guess you should also be aware of https://github.com/swagger-api/swagger-codegen/pull/6496, which will hopefully be merged soon.
Hi @pgrm @macjohnny
Any news on this one ,
IMO it is important bug fix
@topce I'll submit a PR later today
@pgrm I already filed a PR with your changes and some indentation-improvements here: https://github.com/swagger-api/swagger-codegen/pull/6754
Most helpful comment
@macjohnny FYI, this is how I solved it for now - https://github.com/apaleo/swagger-codegen/commit/57cf9b6388c78bd821263ff9c02d989be4781caf (I can see that I forgot to update the comment :wink: but it seems to be working)