wcandillon / swagger-js-codegen

A Swagger Codegen for typescript, nodejs & angularjs
Apache License 2.0
693 stars 286 forks source link

generated get calls include body by default #213

Open Malchia7 opened 6 years ago

Malchia7 commented 6 years ago

So I was generating code to work with the EVE Online api and was getting bad requests returned by the server.

Dug into it and it was because the generated code included empty but non-null bodies in all requests and the server was rejecting them. Presumably their server is just being more strict than the HTTP spec which allows for GET to have a body that would be ignored.

Is it worth adding an option to codegen that would tell the templates to not include an empty body on verbs like GET/DELETE? is there a reason not to? I have this half-implemented (template modified, but no opt) and would be happy to submit a PR if its something desired.

ksherard commented 6 years ago

I was just dealing with this today(2nd time this year). It's painful enough to troubleshoot that I hope we can get a fix for this, it looks like they are lacking contributors right now: https://github.com/wcandillon/swagger-js-codegen/issues/167

EDIT:

GET, DELETE and HEAD are no longer allowed to have request body because it does not have defined semantics as per RFC 7231. https://swagger.io/docs/specification/describing-request-body/

oliverhr commented 6 years ago

@duffman03 accordingly to what you mention in the edition added to your comment, this issue should be marked as closed?

ksherard commented 6 years ago

Actually my edit shows that swagger codegen is actually out of spec now. Previously it was tolerable to include empty bodies in those requests, but now its agaisnt spec.