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

Request documentation on use of "Response Content Type" dropdown

Open hamx0r opened this issue 11 years ago • 9 comments

The dropdown in the Response Class section of the UI is labeled "Response Content Type". Since it's a dropdown, it implies it's an input for a user to select which type of response he would like to receive for the 200 response of the given method. However, the documentation does not say how the list of responses is intended to be used. What is the intended use of the dropdown? Is there a header value sent with a request which results in a response of a particular Content-Type?

hamx0r avatar Apr 22 '15 16:04 hamx0r

There is the 'Accepts' header which tells(or asks) the server for a particular mime type to be sent back. So selecting a 'Response Content Type' should have the desired effect.

ponelat avatar Apr 27 '15 10:04 ponelat

It also corresponds to the produces property of the operation.

webron avatar Apr 27 '15 10:04 webron

From @ponelat and @webron's comments, the dropdown is populated by the produces field of an Operation, and is used to first select what is sent to the server in a request Accepts header, which then dictates the MIME type of the response, right? This is good to know. What's the procedure for updating the spec? Using the Accepts header on the server-side code would be a cool check to use, now that I know it exists. In general, i've learned a lot about JSON API programming from using Swagger, and I assume others have as well.

hamx0r avatar Apr 28 '15 05:04 hamx0r

@hamx0r thanks for expanding the explanation. It's pretty simple to declare 'produces' (and 'consumes' - to tell the server what to expect of your request data).

they're just an array of strings, which will be interpreted as mime types...

...
produces: [
  'application/json',
  'application/xml'
]
...

They can go in your operations, or globally (i believe) The spec does detail their declaration, and you can always take a peek at the petstore example spec ( raw | beautiful ), to see where it gets used.

ponelat avatar Apr 28 '15 07:04 ponelat

Thanks @ponelat. To clarify, I saw that the spec details their declaration, but I didn't see where it details their usage. Perhaps to more experienced API devs, the usage (ie "The selected value from the dropdown selector goes into the requests Accepts header.") would have been known.

To prevent document bloat in the spec, would the team be open to using Github's wiki feature for the swagger-ui project? Currently, all discussion happens with bug reporting. Perhaps the spec doc could continue to remain the primary reference doc (concise), but the wiki could contain more info for those newer to Swagger and HTTP-based APIs. Thoughts?

hamx0r avatar Apr 29 '15 15:04 hamx0r

@hamx0r - we're working on a modified and expanded new website, which will include expanded docs. This is good input with regards to what can go there. I don't want to start a wiki here as all the docs may end up on that website.

webron avatar Apr 29 '15 15:04 webron

Great! I'll leave it up to you if this issue should then be closed, or linked to whatever is tracking that new website development.

hamx0r avatar Apr 29 '15 15:04 hamx0r

I've marked it as Documentation, but will close it for now. Once we ramp up the new docs, I'll go over all the documentation tickets to see what needs to be covered.

webron avatar Apr 29 '15 15:04 webron

cannot get any other options in dropdown have tried produces any help greatly appreciated https://stackoverflow.com/questions/44660772/swagger-ui-symfony-nelmioapidoc-add-multiple-responsetype-options

wraycode avatar Jun 20 '17 20:06 wraycode