It seems the Swagger UI (version: 3.8.1) merges examples when one model 
schema is composed via allOf. Below is a simple OpenAPI 2.0 spec
which shows two model schema, one named 'hal' which includes an example, 
and a second schema 'model' which uses allOf.
The example for the 'model' should stand alone (with only the 'self' link), 
but Swagger UI merges it with the example for 'hal' - note the appearance
of the 'up' link in the 200 response:

<https://lh3.googleusercontent.com/-Zmxg8Y2tcQo/Wmds6tdmxtI/AAAAAAAAAAM/y85I2xLE2zcz-qWVTuePxmChn67vy19TACLcBGAs/s1600/Screen%2BShot%2B2018-01-23%2Bat%2B12.11.34%2BPM.png>

Is this a bug (I think so) or intentional behavior, perhaps due applying 
'allOf' to build the schema?
Is there a Swagger UI configuration option which can disable this?
(I don't want to have to copy/paste the specific example in each response 
object that uses that schema)

thanks,
djb

swagger: '2.0'

info:

  title: Examples are merged
basePath: /exampleApi
paths:
  /models/1:
    get:
      responses:
        '200':
           description: OK
           schema: 
             $ref: '#/definitions/model'
             
definitions:
  hal:
    properties:
      _links:
        desciption: Links to related resources or operations on this 
resource
        type: object
        additionalProperties:
          $ref: "#/definitions/link"
    example:
      _links:
        self:
          href: /exampleApi/things/r12300
        up:
          href: /exampleApi/otherThings

  link:
    type: object
    required:
      - href
    properties:
      href:
        type: string
        format: uri
        description: 'The URI or URI template for the resource/operation 
this link refers to.'

  model:
    allOf:
    - $ref: '#/definitions/hal'
    - type: object
      properties:
         date:
           desription: "The model's date"
           type: string
           format: date-time
         id:
           desription: "The model's unique ID"
           type: string
    example:
      id: 977648bf-fd6e-4d6f-8230-a72df6aa3f9e
      date: 2018-01-22T03:43:57.375Z
      _links:
        self:
          href: /exampleApi/models/977648bf-fd6e-4d6f-8230-a72df6aa3f9e



-- 
You received this message because you are subscribed to the Google Groups 
"Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to