title: Swagger 3 custom Example Value for 3rd party class
body: <p>I am trying to document an API build on Spring Boot 2.5.3 and Swagger 3 (springdoc-openapi version 1.5.10). It's my first contact with Swagger, but until now I managed to rely on the docs to get some things done.</p>
  <p>For a specific property of an object (will post details below), I want to provide a hardcoded JSON value for a better idea about what to expect. For my own objects, adding  <code>@Schema(example = &quot;SomeStringValue&quot;)</code> to object's fields works as expected, meaning that in Swagger-ui the response example value is &quot;SomeStringValue&quot;.</p>
  <p>Problem is that for a field with a type from 3rd party code (core Spring, in fact), the annotation is ignored and default example is generated, like it wouldn't be annotated at all.</p>
  <p>What I have now is below.</p>
  <p>Controller:</p>
  <pre><code>@RestController
  @RequestMapping(&quot;/auth&quot;)
  @RequiredArgsConstructor
  @Slf4j
  @Tag(name = &quot;1. Authentication Controller&quot;)
  public class AuthenticationController {
  
      // [...]
  
      @PostMapping(value = &quot;/login&quot;, consumes = MediaType.APPLICATION_JSON_VALUE)
      @Operation(description = &quot;Login endpoint&quot;)
      public ResponseEntity&lt;AuthenticationC&gt; login(@RequestBody @Valid UserAuthDto userAuthDto, 
          HttpServletRequest request,
          HttpServletResponse response) {
  
          // [...]
          ResponseEntity&lt;AuthenticationC&gt; authResponse = [...]
          // [...]
          return authResponse;
  
      }
  
  }
  </code></pre>
  <p>AuthenticationC class:</p>
  <pre><code>@Data
  @Slf4j
  public class AuthenticationC {
  
      // [...]
  
      @Schema(example = &quot;Any string I want&quot;)
      // This is my own POJO and example works without a problem
      private AuthTokenDetails tokenDetails;
  
      @Schema(example = &quot;Another string I want&quot;)
      // This ignores the example value from @Schema
      private org.springframework.security.oauth2.core.endpoint.OAuth2AccessTokenResponse oAuth2AccessTokenResponse;
  
      // [...]
  
  }
  </code></pre>
  <p>I could workaround that by using a wrapper class, but don't want to modify my objects just to accomodate Swagger.</p>
  <p>Another question would be how Jackson is involved in Swagger, as I noticed fields annotated with <code>@JsonIgnore</code> are also ignored in Example Value output.</p>
  <p>Thank you.</p>