$.components.schemas.*.example are not validated when no path reference them.
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 228
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 48
Description
Describe the bug
It seems that examples in $.components.schemas are not validated if they are not referenced from a path.
Usually schemas are references from a path. However, x-tags allow to sometimes break this rule.
Observed behavior means that examples of those schemas are not validated which is unexpected and error prone.
To Reproduce
Steps to reproduce the behavior:
- Given any
redocly.yamlfile - And this OpenAPI file(s)
openapi: 3.1.0
info:
title: any
version: 2024-03-15
tags:
- name: my-tag
description: any
components:
schemas:
MySchema:
x-tags:
- my-tag
required:
- id
properties:
id:
type: string
example:
not-id: "any"
- Run this command with these arguments...
redocly ...
redocly lint test.yaml
- Observe that no warning was raised regarding the absent
idproperty in the example.
validating /data/docs/events/test.yaml...
/data/docs/events/test.yaml: validated in 8ms
Woohoo! Your API description is valid. 🎉
Expected behavior
All examples should be linted.
Logs
OpenAPI description
Redocly Version(s): 1.9.0
Node.js Version(s) v21.6.1
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.
Research direction
Reproduce the issue with the supplied OpenAPI content in test.yaml and run redocly lint test.yaml. Trace the lint validation entry point for schema examples, then add coverage for an unreferenced x-tags schema; done means its invalid example raises a warning while referenced examples continue to be checked.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, openapi, typescript
- Domain
- api, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100