title: Show XML/JSON sample value in Swagger UI using swagger's annotations
body: <p>I am implementing Jersey based REST API and using swagger to generate HTML based documentation for the same. I am using swagger's annotations to read and scan the resources to generate documentation. I have specified response for each resource using @ApiResponse annotation as below:</p>
  
  <pre><code>@Path("/hello")
  @Api(value = "Hello World" )
  public class HelloRest
  {
      @GET
      @ApiOperation(value="Hello world", httpMethod="GET")
      @ApiResponses(value={ @ApiResponse(code = 200, message = "Success", response = WebservicesErrorResponse.class, reference = "C:/Desktop/hello.json")
                            @ApiResponse(code = 404, message = "Not found", response = WebservicesErrorResponse.class)})
      @Produces({"application/json", "application/xml"})
      public Response helloWorld() 
      {
          return Response.status(WebservicesCommonTypes.SUCCESS).entity("Hello rest API").build();
      }
  }
  </code></pre>
  
  <p>It is working fine and it is generating HTML based documentation as below:
  <a href="https://i.stack.imgur.com/SkHlq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SkHlq.png" alt="Snap shot which is generated by Swagger UI for Jersey based REST API"></a></p>
  
  <p>As it shows the complete structure (Model and example value) of response if response code is 404. And in example value, it is not showing the values, only showing the type for each parameter for the model.</p>
  
  <p>I want to show the sample example schema for the response so that client can understand that what would be the exact response for each response. I researched on it and I found that there is one attribute:</p>
  
  <p>@ApiResponse(reference = "") - Specifies a reference to the response type. The specified reference can be either local or remote and will be used as-is, and will override any specified response() class.</p>
  
  <p>I tried it and I give it a path for my sample.json file as below:</p>
  
  <pre><code>@ApiResponse(code = 200, message = "Success", response = WebServicesErrorResponse, reference = "http://localhost:9001/myinstanceofapplication/html/api-doc/hello.json")
  </code></pre>
  
  <p>and I also tried to give another path that is local path like below:</p>
  
  <pre><code>@ApiResponse(code = 200, message = "Success", response = WebservicesErrorResponse.class, reference = "C:/Desktop/hello.json")
  </code></pre>
  
  <p>but when swagger generate document for it then it gives following:</p>
  
  <p><a href="https://i.stack.imgur.com/Xar3t.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Xar3t.png" alt=""></a></p>
  
  <p>It is showing C:/Desktop/hello.json is not defined!</p>
  
  <p>I have researched and tried lot many solutions but couldn't able to give proper reference to it. I found that this is an issue by <a href="https://github.com/swagger-api/swagger-ui/issues/1700" rel="noreferrer">https://github.com/swagger-api/swagger-ui/issues/1700</a> and <a href="https://github.com/swagger-api/swagger-js/issues/606" rel="noreferrer">https://github.com/swagger-api/swagger-js/issues/606</a>. </p>
  
  <p>So how can I use reference attribute of @ApiResponse to that swagger could show the sample XML/JSON swagger UI. My model class is below:</p>
  
  <pre><code>@XmlRootElement(name="response")
  @XmlAccessorType(XmlAccessType.FIELD)
  public class WebservicesErrorResponse
  {
      @XmlElement
      private int code;
  
      @XmlElement
      private String message;
  
      public WebservicesErrorResponse(){ }
  
  
      public WebservicesErrorResponse(int code, String message)
      {
          this.code = code;
          this.message = message;
      }
  
      public int getCode()
      {
          return code;
      }
      public void setCode(int code)
      {
          this.code = code;
      }
  
      public String getMessage()
      {
          return message;
      }
      public void setMessage(String message)
      {
          this.message = message;
      }
  } 
  </code></pre>
  
  <p>and I want to show following sample XML in the swagger UI:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;response&gt;
    &lt;code&gt;200&lt;/code&gt;
    &lt;message&gt;success&lt;/message&gt;
  &lt;/response&gt;
  </code></pre>