Description
items describes array elements. It has no effect on object fields or on the contents of a string.
Potential impact
Generated clients may expect a different data type, and validators may accept values the author meant to restrict.
Remediation
For an array, set type: array and describe each element with items. For an object, remove items and describe its fields under properties.
Examples
These OpenAPI 3.0 excerpts omit info and paths.
Before
json
{
"openapi": "3.0.0",
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"items": {
"type": "string"
}
}
}
}
}
After
json
{
"openapi": "3.0.0",
"components": {
"schemas": {
"GeneralError": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
The revision makes GeneralError an array of strings. Use that definition only when the API actually returns or accepts a string array.