John
John

Reputation: 4981

Swagger-UI Response Content Type

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.

Upvotes: 2

Views: 15700

Answers (1)

anyarms
anyarms

Reputation: 349

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).

Upvotes: 2

Related Questions