
components:

    schemas:

        HsOfficeRelationType:
            type: string
            enum:
                - UNKNOWN
                - PARTNER
                - EX_PARTNER
                - DEBITOR
                - REPRESENTATIVE
                - VIP_CONTACT
                - OPERATIONS
                - OPERATIONS_ALERT
                - SUBSCRIBER

        HsOfficeRelation:
            type: object
            properties:
                uuid:
                    type: string
                    format: uuid
                anchor:
                    $ref: 'hs-office-person-schemas.yaml#/components/schemas/HsOfficePerson'
                holder:
                    $ref: 'hs-office-person-schemas.yaml#/components/schemas/HsOfficePerson'
                type:
                    type: string
                mark:
                    type: string
                    nullable: true
                contact:
                    $ref: 'hs-office-contact-schemas.yaml#/components/schemas/HsOfficeContact'

        HsOfficeRelationPatch:
            type: object
            properties:
                contact.uuid:
                    type: string
                    format: uuid
                    nullable: true

        # arbitrary relation with explicit type
        HsOfficeRelationInsert:
            type: object
            properties:
                anchor.uuid:
                    type: string
                    format: uuid
                holder.uuid:
                    type: string
                    format: uuid
                holder:
                    $ref: 'hs-office-person-schemas.yaml#/components/schemas/HsOfficePersonInsert'
                type:
                    type: string
                    nullable: true
                mark:
                    type: string
                    nullable: true
                contact.uuid:
                    type: string
                    format: uuid
                contact:
                    $ref: 'hs-office-contact-schemas.yaml#/components/schemas/HsOfficeContactInsert'
            required:
                - anchor.uuid
                - type
                # soon we might need to be able to use this:
                # https://community.smartbear.com/discussions/swaggerostools/defining-conditional-attributes-in-openapi/222410
                # For now we just describe the conditionally required properties:
            description:
                Additionally to `type` and `anchor.uuid`, either `anchor.uuid` or `anchor`
                and either `contact` or `contact.uuid` need to be given.

        # relation created as a sub-element with implicitly known type
        HsOfficeRelationSubInsert:
            type: object
            properties:
                anchor.uuid:
                    type: string
                    format: uuid
                holder.uuid:
                    type: string
                    format: uuid
                mark:
                    type: string
                    nullable: true
                contact.uuid:
                    type: string
                    format: uuid
            required:
                - anchor.uuid
                - holder.uuid
                - contact.uuid
