redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

$.components.schemas.*.example are not validated when no path reference them.

Open cykl opened this issue 4 months ago • 2 comments

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:

  1. Given any redocly.yaml file
  2. 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"
  1. Run this command with these arguments... redocly ...
redocly lint test.yaml
  1. Observe that no warning was raised regarding the absent id property 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

cykl avatar Mar 15 '24 13:03 cykl