title: <Spring Boot / Springfox> Swagger UI not showing example value and model
body: <p>I was generating Swagger API specification from Spring Boot REST controllers using Springfox.</p>
  <p>I noticed an issue where the example value/model could not be shown for response.</p>
  <p>As an investigation, I checked the JSON API doc at http://localhost:8080/v2/api-docs ,
  and converted it to YMAL at <a href="https://editor.swagger.io/" rel="nofollow noreferrer">https://editor.swagger.io/</a> , which it could not show the example value/model as well.
  This seems to caused by the schema is not referring to the model object (&quot;Car&quot; here) correctly.</p>
  <p><a href="https://i.stack.imgur.com/EpO1s.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EpO1s.png" alt="Swagger_Editor_01" /></a></p>
  <p><a href="https://i.stack.imgur.com/Irivb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Irivb.png" alt="Swagger_Editor_02" /></a></p>
  <p>But from the API documentation of Swagger (<a href="https://docs.swagger.io/swagger-core/v1.5.0/apidocs/io/swagger/annotations/ApiResponse.html#response()" rel="nofollow noreferrer">https://docs.swagger.io/swagger-core/v1.5.0/apidocs/io/swagger/annotations/ApiResponse.html#response()</a>), it says that the &quot;response&quot; attribute of the annotation @ApiResponse should correspond to the &quot;schema&quot; field of the specification.</p>
  <p><a href="https://i.stack.imgur.com/NRaki.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NRaki.png" alt="enter image description here" /></a></p>
  <p>By specifying response = &quot;Object.class&quot;, shouldn't the Swagger UI populate the example value/model accordingly?</p>
  <p>Welcome for any advice, and please kindly correct if I have any misconfigurations/misconceptions, thank you very much.</p>
  <br/>
  REST controller and the annotations:
  <pre><code>@GetMapping(path = &quot;/car&quot;)
  @ApiOperation(value = &quot;Get car by color.&quot;, response = Car.class)
  @ApiParam(value = &quot;Color of the car.&quot;, required = true)
  @ApiResponses(value = { @ApiResponse(code = 200, message = &quot;OK.&quot;, response = Car.class),
          @ApiResponse(code = 400, message = &quot;Invalid color provided.&quot;),
          @ApiResponse(code = 404, message = &quot;Car not found.&quot;) })
  public ResponseEntity&lt;Object&gt; getCarByColor(@RequestParam String color) {
      return ResponseEntity.ok(testService.getCarByColor(color));
  }
  </code></pre>
  <p>Model:</p>
  <pre><code>package com.example.demo.model;
  
  import javax.validation.constraints.Max;
  import javax.validation.constraints.NotNull;
  import javax.validation.constraints.Pattern;
  
  import io.swagger.annotations.ApiModel;
  import io.swagger.annotations.ApiModelProperty;
  import lombok.Data;
  
  @ApiModel(value = &quot;Car&quot;, description = &quot;The model for car&quot;)
  @Data
  public class Car {
      @ApiModelProperty(notes = &quot;Car ID.&quot;, example = &quot;12345&quot;, required = false, position = 0)
      private Long id;
  
      @ApiModelProperty(notes = &quot;Car name.&quot;, example = &quot;Suzuki Swift 2020&quot;, required = true, position = 1)
      @NotNull
      @Max(value = 30, message = &quot;Name can only have a maximum length of 30&quot;)
      private String name;
  
      @ApiModelProperty(notes = &quot;Car color.&quot;, example = &quot;blue&quot;, required = true, position = 2)
      @NotNull
      @Max(value = 30, message = &quot;Color can only have a maximum length of 30&quot;)
      @Pattern(regexp = &quot;^(blue|yellow)$&quot;, message = &quot;Only blue or yellow color is allowed.&quot;)
      private String color;
  
      public Car(Long id, String name, String color) {
          this.id = id;
          this.name = name;
          this.color = color;
      }
  }
  </code></pre>
  <p>Swagger UI:</p>
  <p><a href="https://i.stack.imgur.com/bSbEq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bSbEq.png" alt="Example_Value_and_Model_not_shown" /></a></p>
  <p>Springfox dependency in pom.xml:</p>
  <pre><code>    &lt;dependency&gt;
          &lt;groupId&gt;io.springfox&lt;/groupId&gt;
          &lt;artifactId&gt;springfox-boot-starter&lt;/artifactId&gt;
          &lt;version&gt;3.0.0&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  <br/>
  <br/>
  <br/>
  <br/>
  <br/>
  <p>&lt;UPDATE (31 Jul 2020)&gt;</p>
  <p>Made the following changes to use OAS3.0 specification and annotations, but still have issue. It also gives an error in Swagger UI.</p>
  <p>REST controller and the annotations:</p>
  <pre><code>import io.swagger.v3.oas.annotations.Operation;
  import io.swagger.v3.oas.annotations.media.Content;
  import io.swagger.v3.oas.annotations.media.Schema;
  import io.swagger.v3.oas.annotations.responses.ApiResponse;
  
  ...
  ......
  
  @GetMapping(path = &quot;/car&quot;, produces = &quot;application/json&quot;)
  @Operation(summary = &quot;Get car by color.&quot;, responses = {
          @ApiResponse(responseCode = &quot;200&quot;, description = &quot;OK.&quot;, content = {
                  @Content(mediaType = &quot;application/json&quot;, schema = @Schema(type = &quot;object&quot;, implementation = Car.class)) }) })
  public ResponseEntity&lt;Object&gt; getCarByColor(@RequestParam String color) {
      return ResponseEntity.ok(testService.getCarByColor(color));
  }
  </code></pre>
  <p>Model:</p>
  <pre><code>package com.example.demo.model;
  
  import javax.validation.constraints.Max;
  import javax.validation.constraints.NotNull;
  import javax.validation.constraints.Pattern;
  
  import io.swagger.annotations.ApiModel;
  import io.swagger.annotations.ApiModelProperty;
  import io.swagger.v3.oas.annotations.media.Schema;
  import lombok.Data;
  
  @ApiModel(value = &quot;Car&quot;, description = &quot;The model for car&quot;)
  @Schema
  @Data
  public class Car {
      @ApiModelProperty(notes = &quot;Car ID.&quot;, example = &quot;12345&quot;, required = false, position = 0)
      private Long id;
  
      @ApiModelProperty(notes = &quot;Car name.&quot;, example = &quot;Suzuki Swift 2020&quot;, required = true, position = 1)
      @NotNull
      @Max(value = 30, message = &quot;Name can only have a maximum length of 30&quot;)
      private String name;
  
      @ApiModelProperty(notes = &quot;Car color.&quot;, example = &quot;blue&quot;, required = true, position = 2)
      @NotNull
      @Max(value = 30, message = &quot;Color can only have a maximum length of 30&quot;)
      @Pattern(regexp = &quot;^(blue|yellow)$&quot;, message = &quot;Only blue or yellow color is allowed.&quot;)
      private String color;
  
      public Car(Long id, String name, String color) {
          this.id = id;
          this.name = name;
          this.color = color;
      }
  }
  </code></pre>
  <p>Swagger UI:</p>
  <p><a href="https://i.stack.imgur.com/Ncsz6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ncsz6.png" alt="Swagger_UI_Error_01" /></a></p>
  <p><a href="https://i.stack.imgur.com/GAB0S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GAB0S.png" alt="Swagger_UI_Error_02" /></a></p>