Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can multiple response content types and parameter content type be set? #119

Closed
pietervogelaar opened this issue Dec 18, 2012 · 16 comments

Comments

@pietervogelaar
Copy link

At the moment only application/json is available. What is required to add application/xml as option to the selectbox?

@hsanjuan
Copy link

Im also interested

@hsanjuan
Copy link

So, I checked and you would need to add something like "supportedContentTypes : ['application/json', 'text/yaml']" in each of the "operations" objects. This will populate the select and set the Accept header when clicking "try out". It is not documented afaik, maybe wasnt in latest stable release. Cheers

@fehguy
Copy link
Contributor

fehguy commented Jan 11, 2013

Hi folks, you can use that current field, but for the next release, supportedContentTypes will be changed to follow the updated spec, which should have more clear naming, and inheretence and overrides at the method level. The supportedContentTypes is well written, but it will be renamed for the 1.2 spec, which hopefully will be wrapped up this month.

@caoilte
Copy link

caoilte commented May 18, 2013

Hi,
Did the 1.2 spec ever get released? I'm also interested in supporting xml and json. The only thing I could find was this,

https://github.com/wordnik/swagger-core/wiki/changelog

which suggests not.

@fehguy
Copy link
Contributor

fehguy commented May 18, 2013

No, it hasn't. The sticking point has been JSON schema (swagger-api/swagger-core#51), which many folks have asked for but seems insufficient for doing what swagger needs to. So until that gets resolved either way, the spec hasn't been released.

@caoilte
Copy link

caoilte commented May 18, 2013

Ok,
I've added support for the supportedContentTypes field in my fork of Scalatra, caoilte/scalatra@c70f002. Do you think it would be worth my while trying to get it merged into master?

@fehguy
Copy link
Contributor

fehguy commented May 18, 2013

Yes, I know @casualjim is looking at this as well so that'd be helpful for sure. Clarification though, 1.2 spec uses the names "produces" and "consumes". Sorry that wasn't clear

@cadenzajon
Copy link

I have had this working fine for months, with Swagger out of the box. My JSON looks like:

{
"swaggerVersion": "1.1",
"resourcePath": "/document_list",
"apis": [
{
"path": "/document_list",
"operations": [
{
"httpMethod": "GET",
"summary": "Search for documents based on a set of criteria",
"produces": [
"application/json",
"application/xml",
"application/atom+xml"
],
...

The most annoying thing is that two "Response Content Type" dropdowns appear in swagger-ui, one at the top of the operation (above the parameters) and one embedded within my Message Body parameter area (which is redundant and seems to be completely ignored).

For API calls with no Message Body parameter (i.e. a GET as opposed to PUT, POST) the UI works great and I have no complaints.

Is there any possibility that the "Response Content Type" dropdown could be suppressed within the Message Body parameter when it exists at the top level of the operation?

@AndrewCsontos
Copy link

There is a difference between the two. The top level one sets an "Accept" header. The parameter level one sets the "content-type" header.

So you could in theory post Json and ask for Xml back.

@cadenzajon
Copy link

Ah, of course. Is there a way to add items to that embedded "content-type"
list? I have had to add my own "Content-Type" parameter when I want to)
provide alternate options to JSON (like "application/xml").

On Tue, Jun 11, 2013 at 12:28 PM, AndrewCsontos [email protected]:

There is a difference between the two. The top level one sets an "Accept"
header. The parameter level one sets the "content-type" header.

So you could in theory post Json and ask for Xml back.


Reply to this email directly or view it on GitHubhttps://github.com//issues/119#issuecomment-19286396
.

@fehguy
Copy link
Contributor

fehguy commented Jul 7, 2013

This is added to 2.0-develop. Please try it out and post back if you see issues.

@fehguy fehguy closed this as completed Jul 7, 2013
@akhil
Copy link

akhil commented Sep 18, 2014

@fehguy produces works, but consumes doesnot when defaultValue is set.

@webron
Copy link
Contributor

webron commented Sep 19, 2014

@akhil - defaultValue of what?

@akhil
Copy link

akhil commented Sep 19, 2014

I used http://demo0536639.mockable.io/api-docs at http://petstore.swagger.wordnik.com/
In the http://demo0536639.mockable.io/api-docs/assets there is "defaultValue": "{}", in 'parameters'
The textbox gets populated by {} as expected. But the dropdown is missing.

When I remove the defaultValue entry I see the dropdown

@webron
Copy link
Contributor

webron commented Sep 19, 2014

@akhil - okay, this is an interesting issue, but it's somewhat different than the topic at hand. Can you open a separate issue with the details you gave here?

@akhil
Copy link

akhil commented Sep 19, 2014

done #593

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants