ryankennedy / swagger-jaxrs-doclet

Apache License 2.0
87 stars 136 forks source link

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

Open jschnasse opened 11 years ago

jschnasse commented 11 years ago

Current master of swagger-ui supports content negotiation. Swagger-jaxrs-doclet should support this too. See: https://github.com/wordnik/swagger-core/issues/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 commented 11 years ago

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

iamcrunch commented 10 years ago

I just created pull request https://github.com/ryankennedy/swagger-jaxrs-doclet/pull/79 to address this. Almost exactly a year later.