Swagger-ui: Non-JSON request bodies are broken in 3.11.0

Created on 26 Feb 2018  路  5Comments  路  Source: swagger-api/swagger-ui

The 3.11.0 release broken handling of request bodies other than application/json (e.g. application/xml and others) in OpenAPI 2.0 definitions.
The responses are OK though.

| Q | A
| ------------------------------- | -------
| Bug or feature request? | Bug
| Which Swagger/OpenAPI version? | 2.0 (3.0 specs don't have this issue)
| Which Swagger-UI version? | 3.11.0
| How did you install Swagger-UI? | http://petstore.swagger.io, http://editor.swagger.io
| Which browser & version? | Chrome
| Which operating system? | Windows 7

Demonstration API definition

swagger: '2.0'
info:
 title: XML test
 version: '0.1'
host: httpbin.org
schemes:
  - http
paths:
  /post:
    post:
      consumes: 
        - application/xml 
      produces:
        - application/xml
      parameters:
        - in: body
          name: body
          required: true
          schema:
            $ref: '#/definitions/user'
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/user'

definitions:
  user:
    type: object
    properties:
      id:
        type: integer
      name:
        type: string
    required:
      - id
      - name

Expected Behavior

Request body appears as XML, with the application/xml media type.
image

Current Behavior

Request body appears as JSON, with the application/json media type.
image

P1 lock-bot regression

Most helpful comment

@jonnyry Yes I can get it to work on earlier versions

Broken on latest:
http://petstore.swagger.io/?filter=default&url=http://heldersepu.github.io/hs-scripts/swagger/4257_swagger.yaml#/default/post_post

Working on Older (3.9.1):
http://nhc-noaa.azurewebsites.net/swagger/ui/index?filter=default&url=http://heldersepu.github.io/hs-scripts/swagger/4257_swagger.yaml#/default/post_post

Working on last version (3.10.0):
http://swashbuckletest.azurewebsites.net/swagger/ui/index?filter=default&url=http://heldersepu.github.io/hs-scripts/swagger/4257_swagger.yaml#/default/post_post

All 5 comments

Can anyone get this to work in an earlier version of Swagger UI? I've tried 3.5.0 and 3.10.0 but with no luck.

@jonnyry Yes I can get it to work on earlier versions

Broken on latest:
http://petstore.swagger.io/?filter=default&url=http://heldersepu.github.io/hs-scripts/swagger/4257_swagger.yaml#/default/post_post

Working on Older (3.9.1):
http://nhc-noaa.azurewebsites.net/swagger/ui/index?filter=default&url=http://heldersepu.github.io/hs-scripts/swagger/4257_swagger.yaml#/default/post_post

Working on last version (3.10.0):
http://swashbuckletest.azurewebsites.net/swagger/ui/index?filter=default&url=http://heldersepu.github.io/hs-scripts/swagger/4257_swagger.yaml#/default/post_post

OK. I must have been doing something wrong. Just tried now with 3.10.0 and all working OK. Thanks for the information.

This is fixed! It should be live by the end of the week, if this is _really_ a problem for anyone let me know, we can try for a hotfix release before Friday.

Locking due to inactivity.

This is done to avoid resurrecting old issues and bumping long threads with new, possibly unrelated content.

If you think you're experiencing something similar to what you've found here: please open a new issue, follow the template, and reference this issue in your report.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings