Description
A schema’s $ref must point to a valid Schema Object. An incorrect path or target prevents request or response fields and types from being resolved.
Potential impact
Validation or model generation may fail, or data structure information may be missing from documentation.
Remediation
Reference existing shared models under #/components/schemas/.... Valid external schemas are also supported; check both the name and the target’s object type.
Examples
These excerpts correct schemads to schemas in the GeneralError reference. The tshirt example definition and the operation using the request body are omitted.
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"
}
}
}
}
}
}
}
}