Description
A request or response schema reference must point to a Schema Object that defines the shape of the data.
Potential impact
A broken reference can stop validation or model generation, or leave fields and types undocumented.
Remediation
Use a schema under #/components/schemas/... or in an external file. Check the path spelling and the type of object it identifies.
Examples
In the NewItem multipart body, changing schemads to schemas resolves GeneralError. The excerpt omits the tshirt example definition and the operation that uses NewItem.
Before
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0",
"contact": {
"name": "contact",
"url": "https://www.google.com/",
"email": "user@gmail.c"
}
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"petType"
]
}
},
"requestBodies": {
"NewItem": {
"description": "Multipart item data",
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemads/GeneralError"
},
"examples": {
"tshirt": {
"$ref": "#/components/examples/tshirt"
}
}
}
}
}
}
}
}
After
json
{
"openapi": "3.0.0",
"info": {
"title": "Simple API Overview",
"version": "1.0.0",
"contact": {
"name": "contact",
"url": "https://www.google.com/",
"email": "user@gmail.c"
}
},
"paths": {
"/": {
"get": {
"operationId": "listVersionsv2",
"summary": "List API versions",
"responses": {
"200": {
"description": "200 response",
"content": {
"application/json": {
"examples": {
"foo": {
"value": {
"versions": [
{
"status": "CURRENT",
"updated": "2011-01-21T11:33:21Z",
"id": "v2.0",
"links": [
{
"href": "http://127.0.0.1:8774/v2/",
"rel": "self"
}
]
}
]
}
}
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"GeneralError": {
"type": "object",
"discriminator": {
"propertyName": "petType"
},
"properties": {
"code": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"petType"
]
}
},
"requestBodies": {
"NewItem": {
"description": "Multipart item data",
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"$ref": "#/components/schemas/GeneralError"
},
"examples": {
"tshirt": {
"$ref": "#/components/examples/tshirt"
}
}
}
}
}
}
}
}