Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
cykl opened this issue Mar 15, 2024 · 2 comments
Open
Labels
p2 Type: Bug Something isn't working

Comments

@cykl
Copy link

cykl commented Mar 15, 2024

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 cykl added the Type: Bug Something isn't working label Mar 15, 2024
@adamaltman
Copy link
Member

Also,

Component: "MySchema" is never used.

10 | schemas:
11 |
12 |   MySchema:
13 |     x-tags:
14 |       - my-tag

Warning was generated by the no-unused-components rule.

Even though it is used via x-tags.

@tatomyr
Copy link
Contributor

tatomyr commented Mar 18, 2024

Good catch! Thanks for reporting it.

@tatomyr tatomyr added the p2 label Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2 Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants