title: Can we force Swagger to "inline" objects in "anyOf" instead of using $ref to an object when generating an openapi docs
body: <p>I am wondering if there is a way to force Swagger and Spring (maybe using annotations?) to &quot;inline&quot; objects when generating openapi docs.
  An example of how it works right now:</p>
  <pre><code>  paths:
      /pets:
        patch:
          requestBody:
            content:
              application/json:
                schema:
                  anyOf:
                    - $ref: '#/components/schemas/PetByAge'
                    - $ref: '#/components/schemas/PetByType'
          responses:
            '200':
              description: Updated
    components:
      schemas:
        PetByAge:
          type: object
          properties:
            age:
              type: integer
            nickname:
              type: string
          required:
            - age
    
        PetByType:
          type: object
          properties:
            pet_type:
              type: string
              enum: [Cat, Dog]
            hunts:
              type: boolean
          required:
            - pet_type
    
        Dog:
          type: object
          properties:
            bark:
              type: boolean
            breed:
              type: string
    
        Cat:
          type: object
          properties:
            hunts:
              type: boolean
            age:
              type: integer
  </code></pre>
  <p>An example of how I would like it to work:</p>
  <pre><code>    paths:
        /pets:
          patch:
            requestBody:
              content:
                application/json:
                  schema:
                    anyOf:
                      - type: object
                        properties:
                          age:
                            type: integer
                          nickname:
                            type: string
                        required:
                          - age
                      - type: object
                        properties:
                          pet_type:
                            type: string
                            enum: [ Cat, Dog ]
                          hunts:
                            type: boolean
                        required:
                          - pet_type
            responses:
              '200':
                description: Updated
      
      
      components:
        schemas:
          PetByAge:
            type: object
            properties:
              age:
                type: integer
              nickname:
                type: string
            required:
              - age
      
          PetByType:
            type: object
            properties:
              pet_type:
                type: string
                enum: [Cat, Dog]
              hunts:
                type: boolean
            required:
              - pet_type
      
          Dog:
            type: object
            properties:
              bark:
                type: boolean
              breed:
                type: string
      
          Cat:
            type: object
            properties:
              hunts:
                type: boolean
              age:
                type: integer
  </code></pre>
  <p>I use @Schema annotation on the class together with anyOf = {PetByAge.class, PetByType.class}
  Unfortunately, I can't use any JSON string instead of .class.</p>
  <p>Does anyone have any idea how this can be achieved?</p>