- 
                Notifications
    
You must be signed in to change notification settings  - Fork 9.2k
 
Open
Description
I was wondering what the expected behavior of allOf with example is. For example I have:
/example:
  get:
    summary: Example
    responses:
      '200':
        content:
          application/json:
            schema:
              allOf:
                - $ref: '#/components/schemas/MySchema'
                - example:
                    my_string: "override"
                    my_array:
                      - "override"
components:
  schemas:
    MySchema
      type: object
      properties:
        my_string:
          type: string
        my_array:
          type: array
          items:
            type: string
      example:
        my_string: "original"
        my_array:
          - "original"   This results in the following example for the response:
{
  "my_string": "override",
  "my_array": [
    "original",
    "override"
  ]
}Swapping the order within the allOf block results in:
{
  "my_string": "original",
  "my_array": [
    "override",
    "original"
  ]
}For context, I have a Schema that I want to use in a few different response bodies. Some of these responses need certain values to be slightly different in the examples. I noticed the above behaviour and thought it would be convenient, although I want to make sure that this is expected / supported.
I'm also unsure if this is something specific to swagger-ui or if it's part of the OpenAPI spec, so apologies if I' have asked in the wrong place.
Thanks in advance :)
Metadata
Metadata
Assignees
Labels
No labels