stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI (v3.1, v3.0, and v2.0), Arazzo v1.0, as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.48k stars 233 forks source link

Unable to lint open api if it is wrapped by object #2621

Open school-coder opened 4 months ago

school-coder commented 4 months ago

Describe the bug When openapi is wrapped in a object ( JSON or YAML), extends: [spectral:oas] is not able to be reused.

To Reproduce

  1. Given this document, image spec attribute needs to comply with spectral:oas ruleset.

  2. When i try to start the node js server, with the below rule, image

I am getting the following error

RulesetValidationError: the rule must have at least "given" and "then" properties

Expected behavior When a rule extends a certain rule set (as we have done for 'spectral:oas' for 'spec' attribute) for a given attribute, linting needs to be done for that attribute and corresponding linting responses needs to be provided. 'then' must be optional if 'extends' is provided.