Specify a mandatory object in an array
Hello,
I am trying to define an array of objects (Name = "Name" and value= "value") using '$ref', where one particular object has to be defined as mandatory . The number of objects may vary in future. Below is the code snippet that I have built but dont find it as a best solution. Any suggestions to make it better are appreciated. Thanks in advance
characteristic:
type: array
items:
$ref: '#/definitions/createObject_characteristic'
createObject_characteristic:
allOf:
- $ref: '#/definitions/createObject_term'
- $ref: '#/definitions/createObject_service'
- $ref: '#/definitions/createObject_stage'
createObject_term:
type: object
properties:
name:
type: string
example: term
description: name of the charateristic
value:
type: string
example: 12 or 36
description: value of the characteristic given in name
createObject_service:
type: object
properties:
name:
type: string
example: service
description: name of the charateristic
value:
type: string
example: AVPN or MIS
description: value of the characteristic given in name
createObject_stage:
type: object
required:
- name
- value
properties:
name:
type: string
example: stage
description: name of the charateristic
value:
type: string
example: createAndRegisterObject
description: value of the characteristic given in name