no-invalid-media-type-examples | not working as expected
Open
@Daryna-del is already working on this.
Since Jun 30, 2026.
governance
p2
Type: Enhancement
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 228
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 48
Description
Describe the bug
i've looked at the OAS schema and it uses either a ref or example object. We are using an example schema in our definition but the external file is not a valid example per the linter. I can't share the full schema for a repo of the issue but my external schema file is matching the expected response body schema, is there any reason why the linter says it should be type object? my external document is a valid uri
$ redocly lint --config ~/repos/.redocly.yaml openapi.json --format stylish
validating specs/openapi.json...
openapi.json:
101:22 warning no-invalid-media-type-examples Example value must conform to the schema: type must be object.
openapi.json
"content": {
"application/json": {
"schema": {
"$ref": "./schemas/response-schema_v01.json"
},
"examples": {
"response": {
"externalValue": "./examples/success-response_v01.json"
}
}
}
}
Response body schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "ActivityLogs",
"description": "Activity Logs",
"type": "object",
"properties": {
"ActivityLogs": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"activityLog": {
"$ref": "../../../../common/logEntryBaseType_v02.json"
},
"links": {
"type": "array",
"items": {
"$ref": "../../../../common/linkType_v01.json"
}
}
}
}
}
},
"additionalProperties": false
}
Example
{
"ActivityLogs": [
{
"activityLog": { ...
OAS meta schema
"examples": {
"properties": {
"example": true,
"examples": {
"type": "object",
"additionalProperties": {
"$ref": "#/$defs/example-or-reference"
}
}
}
},
"$defs": {
"example-or-reference": {
"if": {
"type": "object",
"required": [
"$ref"
]
},
"then": {
"$ref": "#/$defs/reference"
},
"else": {
"$ref": "#/$defs/example"
}
}
},
"example": {
"$comment": "https://spec.openapis.org/oas/v3.1.0#example-object",
"type": "object",
"properties": {
"summary": {
"type": "string"
},
"description": {
"type": "string"
},
"value": true,
"externalValue": {
"type": "string",
"format": "uri"
}
},
"not": {
"required": [
"value",
"externalValue"
]
},
"$ref": "#/$defs/specification-extensions",
"unevaluatedProperties": false
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.