I'm trying to add an object in an array, but this seems not be possible. I've tried the following, but I get always the error:
Property Name is not allowed.
This is shown for all items defined in the devices
array. How can I define items in an array in OpenAPI?
/demo/:
post:
summary: Summary
requestBody:
description: Description.
required: true
content:
application/json:
schema:
type: object
properties:
Name:
type: string
Number:
type: array
items:
type: string
description:
type: string
type:
type: string
devices:
type: array
items:
Name:
type: string
descripiton:
type: string
Number:
type: integer
enabled:
type: boolean
required:
- Name
- Number
- devices
responses:
'201': # status code
description: Created.
'500':
description: Error.
'405':
description: Invalid body has been presented.
You need to add two extra lines inside items
to specify that the item type is an object:
devices:
type: array
items:
type: object # <----------
properties: # <----------
Name:
type: string
descripiton:
type: string
Number:
type: integer
enabled:
type: boolean
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With