Swagger-UI Response Content Type

John picture John · Apr 21, 2016 · Viewed 11.6k times · Source

Is it possible to add the Response Content Type select box without creating the Response Class (Status 200) schema?

My web services return JSON or XML format depending on the accept header. I need this dropdown after that.

Answer

anyarms picture anyarms · May 2, 2016

You can populate the valued for the 'Response Content Type' dropdown with the produces property of the Swagger definition:

---
swagger: '2.0'
info:
  version: 0.0.0
  title: Simple API
produces:
  - application/xml
  - application/json
paths:
  /:
    get:
      responses:
        200:
          description: OK

You'll eventually need to define your response schema as well, but that definition can be independent of the response content type (json vs xml).