I converted my jsonschema that works in the script to YAML format for swagger documentation. The issue is that in line 8 (-type: string) swagger shows error: should be object, 'items' must be an object.
type: object
properties:
answers:
type: array
minItems: 4
maxItems: 4
items:
- type: string
enum: ['Not really', 'Slightly', 'Significantly']
- type: string
enum: ['Not really', 'Slightly', 'Significantly']
- type: string
enum: ['Not really', 'Slightly', 'Significantly']
- type: string
enum: ['Yes', 'No']
Json schema
"type": "object",
"properties": {
"answers": {
"type": "array",
"items": [
{
"type": "string",
"enum": ["Not really", "Slightly", "Significantly"]
},
{
"type": "string",
"enum": ["Not really", "Slightly", "Significantly"]
},
{
"type": "string",
"enum": ["Not really", "Slightly", "Significantly"]
},
{
"type": "string",
"enum": ["Yes", "No"]
},
],
"minItems": 4,
"maxItems": 4,
}
},
}
It because
itemsshould be an object (i.e. YAML mapping) but you give an array (i.e. YAML sequence).You probably want to use
prefixItemsbecause you seem to want to validate the array as tuple:See docs: