Search code examples
swagger-2.0swagger-editor

swagger editor reference definition inside another definition


Inside my definitions I'm using inheritance. In the example below, the PERSON-PATCH properties are coming in without issue. Now I want to take the PERSON-BIO properties and show that's a sub-object inside the PersonGet. I can't figure out the syntax to do that.

PersonBio:
  type: object
  properties: &PERSON-BIO
    nickname:
      type: string
      description: The nickname for the Person
    ... other properties chopped out ...
  minProperties: 1

PersonGet:
  type: object
  properties:
    <<: *PERSON-PATCH
    ident:
      type: integer
      format: int32
      description: The SQL ident of the Person
    bio:
      <<: *PERSON-BIO

Solution

  • OK, just figured this out;

    PersonGet:
      type: object
      properties:
        <<: *PERSON-PATCH
        bio:
          $ref: '#/definitions/PersonBio'