title: Java Spring Boot OpenApi 3 - How to add @Schema for RequestBody?
body: <ol>
  <li></li>
  </ol>
  <pre><code>@PostMapping(produces = &quot;application/json&quot;, consumes = &quot;application/json&quot;)
  public ResponseEntity&lt;Book&gt; addBook(
          @RequestBody(description = &quot;Book to add.&quot;, required = true,
                      content = @Content(
                              schema=@Schema(implementation = Book.class)))   
          @Valid Book book
  ) {
      return ResponseEntity.ok(bookRepository.add(Book));
  </code></pre>
  <p>}</p>
  <p>2.</p>
  <pre><code>    @PostMapping(produces = &quot;application/json&quot;, consumes = &quot;application/json&quot;)
  public ResponseEntity&lt;BasicBook&gt; addBook(
          @RequestBody(description = &quot;Book to add.&quot;, required = true,
                      content = @Content(
                              schema=@Schema(allOf = BasicBook.class, oneOf = {
                                  HomeScience.class, GeneralScience.class })))   
          @Valid BasicBook book
  ) {
      return ResponseEntity.ok(bookRepository.add(Book));
  </code></pre>
  <p>}</p>
  <p>Above <strong>snippet 1.</strong> is working fine. In the Swagger UI I can see the RequestBody with example value where I can execute that.</p>
  <p>but for <strong>snippet 2.</strong> when I am trying inheritance (i.e. oneOf, allOf or anyOf), this schema is not working.
  Only BasicBook properties are coming in (Swagger UI)RequestBody's example value.</p>
  <p>I have tried with @Parameter also. Here is the code</p>
  <p>3.</p>
  <pre><code>        @PostMapping(produces = &quot;application/json&quot;, consumes = &quot;application/json&quot;)
  public ResponseEntity&lt;BasicBook&gt; addBook(
          @Parameter(required = true, description = &quot;DTO for book.&quot;, content = {
                  @Content(mediaType = &quot;application/json&quot;, schema = @Schema(allOf = BasicBook.class, oneOf = {
                          HomeScience.class, GeneralScience.class }, discriminatorMapping = {
                                  @DiscriminatorMapping(value = &quot;HOME&quot;, schema = HomeScience.class),
                                  @DiscriminatorMapping(value = &quot;GENERAL&quot;, schema = GeneralScience.class) }, discriminatorProperty = &quot;type&quot;)) }) 
          @RequestBody @Valid BasicBook book
  ) {
      return ResponseEntity.ok(bookRepository.add(Book));
  </code></pre>
  <p>}</p>
  <p><strong>snippet 3.</strong> also not giving desired result.</p>
  <p>How can I use oneOf, allOf or anyOf in the RequestBody.</p>