Description
Misspelled standard properties in an OpenAPI 2.0 object may be rejected or ignored by tools, leaving the intended definition unapplied. Distinguish standard fields from data-model property names and permitted x- extensions.
Potential impact
- Documentation or client generation may fail or omit necessary information.
- Incorrectly written schema constraints can prevent tools from interpreting the intended data structure.
Remediation
Check the names and locations of properties for each OpenAPI 2.0 object, and correct misspellings. Use the x- prefix for custom metadata on objects that support extensions. Do not replace data field names under schema properties with standard specification field names.
Examples
The first example misspells description as descripption and properties as propppperties.
Before
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/{id}": {
"get": {
"summary": "List API versions",
"responses": {
"200": {
"description": "OK"
}
},
"operationId": "listVersionsv2"
},
"parameters": [
{
"descripption": "ID of pet to use",
"required": true,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "csv",
"name": "id",
"in": "path"
}
]
}
},
"definitions": {
"ErrorModel": {
"type": "object",
"required": [
"message",
"code"
],
"propppperties": {
"message": {
"type": "string"
},
"code": {
"type": "integer",
"minimum": 100,
"maximum": 600
}
}
}
}
}
After
{
"swagger": "2.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0"
},
"paths": {
"/{id}": {
"get": {
"summary": "List API versions",
"responses": {
"200": {
"description": "OK"
}
},
"operationId": "listVersionsv2"
},
"parameters": [
{
"description": "ID of pet to use",
"required": true,
"type": "array",
"items": {
"type": "string"
},
"collectionFormat": "csv",
"name": "id",
"in": "path"
}
]
}
},
"definitions": {
"ErrorModel": {
"type": "object",
"required": [
"message",
"code"
],
"properties": {
"message": {
"type": "string"
},
"code": {
"type": "integer",
"minimum": 100,
"maximum": 600
}
}
}
}
}
The second example uses the standard property names correctly. For custom extensions, follow the extension rules supported by the relevant object.