swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Problem with POST to expressjs with no body and application/json content type

Open MannyC opened this issue 13 years ago • 3 comments

As noted at https://github.com/visionmedia/express/issues/1316 , express considers POST etc requests with a content type of "application/json" but no body to be malformed. This does not apply to "application/xml".

I have fixed this problem in my local version of swagger-ui by simply doing a check prior to sending the ajax request and changing the content type to "application/xml" if the body is empty (towards the end of OperationView.submitOperation).

MannyC avatar Feb 21 '13 01:02 MannyC

In #166 I have a patch that sets no content-type at all of there is no body. That might be a more generic solution than setting a magic "application/xml" for empty bodies.

JonnyJD avatar Mar 17 '13 22:03 JonnyJD

also see #166

fehguy avatar Mar 19 '13 06:03 fehguy

Yeah, no content type makes more sense than application/xml, I agree.

MannyC avatar Mar 19 '13 21:03 MannyC