At the current version of the spec, you can’t really provide two completely 
different structures, even if sent as JSON and XML.

 

You can define examples at the model level per media type. I don’t have a 
sample to share, but take a look at 
http://docs.swagger.io/swagger-core/current/apidocs/index.html?io/swagger/annotations/Example.html.

 

 

 

From: <[email protected]> on behalf of Emerald 
<[email protected]>
Reply-To: "[email protected]" 
<[email protected]>
Date: Monday, 10 April 2017 at 10:37
To: Swagger <[email protected]>
Subject: Override Example panel

 

@GET

@Path("/{xxx}{yyy:(/.+)?}")

@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })

@ApiOperation(value = "Some infos", notes = "Some notes")

@ApiResponses(value = {

 @ApiResponse(code = 200, message = STATUS_MESSAGE_OK, response = Object.class)

 

})

public Response read(

    @HeaderParam("Accept") @ApiParam(hidden = true) String responseContentType

) {

Object response;

if (responseContentType.equals(MediaType.APPLICATION_JSON)) {

   response = ...

} else {

   response = ...

}

return Response.ok(response).build();

}
 
Hi gurus,
 
I'm implementing this to return a JSON depending on what the response content 
type is.
 
The first type is Foo and the second is a Map<String, Object>.
 
The problem is the Example Panel uses the "response" param to show the response 
structure but in this case it's Object and it shows {}.
 
How can I fix it? Is there a way to override the Example panel?
 
Regards,
Emerald
-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to