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

POSTing Raw XML doesn't send the correct content-type

Open TheFoot opened this issue 10 years ago • 3 comments

When attempting to POST to an XML endpoint, sending the XML as the raw request body, it seems that the XML body gets sent, if no content-type is explicitly set. But if the content-type is set properly, the call doesn't send the request body.

With a missing content-type, the server endpoint often cannot parse the request body correctly.

This ALSO happens using the swagger-editor. Is it my definition that is incorrect?

  • swagger-ui version: 2.1.4
  • a swagger file reproducing the issue:
swagger: "2.0"
info:
  version: "0.0.1"
  description: 
    Test case for POSTing XML
  title: Test
host: localhost:3000
basePath: /
schemes:
  - http
consumes:
  - application/xml
produces:
  - application/xml
paths:
  /postxml:
    post:
      description: Test posting raw XML
      consumes: 
        - application/xml
      parameters:
        - in: body
          name: request
          schema:
             type: string
      responses:
        "200":
          description: Success
          schema:
            type: string
        default:
          description: Error message
          schema:
            type: string

TheFoot avatar Sep 05 '16 15:09 TheFoot

Can you please share what you see in the network console? Technically, your schema for the body parameter should be type: object since you're sending an XML object (I'm assuming).

fehguy avatar Sep 07 '16 21:09 fehguy

i'm having the same issue, swagger don't support try operation using XML?

igoralvess avatar Oct 17 '16 12:10 igoralvess

POSTing XML works fine - take a look at the pet store. The problem is probably with the definition of the request itself as a string.

webron avatar Oct 17 '16 16:10 webron