Skip to content
This repository has been archived by the owner on Nov 11, 2017. It is now read-only.

Support of content negotiation with accept,content-type / produces,consumes #44

Open
jschnasse opened this issue Aug 26, 2013 · 2 comments

Comments

@jschnasse
Copy link

Current master of swagger-ui supports content negotiation. Swagger-jaxrs-doclet should support this too. See: swagger-api/swagger-core#77

"consumes": [
      "application/json"
    ],
    "produces": [
      "application/json"
    ]

A common jaxrs pattern to provide content negotiation is

@Path("/resource")
@Produces({ "application/formatA" })
public Response getFormatA()
{

}
@Path("/resource")
@Produces({ "application/formatB" })
public Response getFormatB()
{

}

The expected result in swagger is:

"path" : "/resource",
    "description" : "",
    "operations" : [ {
      "httpMethod" : "GET",
      "nickname" : "getResource", 
      "produces": [
      "application/formatA", "application/formatB"
       ],
      "responseClass" : "Response",
      "summary" : "",
      "notes" : ""
    }, 

and NOT

"path" : "/resource",
    "description" : "",
    "operations" : [ {
      "httpMethod" : "GET",
      "nickname" : "getFormatA",
      "responseClass" : "Response",
      "summary" : "",
      "notes" : ""
    }, {
      "httpMethod" : "GET",
      "nickname" : "getFormatB",
      "responseClass" : "Response",
      "summary" : "",
      "notes" : ""
    }

The former looks way cooler in the UI. You get a dropdown to choose your format from.

@jerome-leclercq
Copy link
Contributor

See also swagger-api/swagger-core#308, which IMHO is the second half of the problem.

@iamcrunch
Copy link

I just created pull request #79 to address this. Almost exactly a year later.

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

No branches or pull requests

3 participants