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 as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.35k stars 226 forks source link

oas3-operation-security-defined scopes validation not using resolved securitySchemes #2617

Open cuttingclyde opened 2 months ago

cuttingclyde commented 2 months ago

fdxapi.components.test.yaml.txt fdxapi.tax.fails.yaml.txt fdxapi.tax.passes.yaml.txt

Describe the bug The oas3-operation-security-defined rule fires even though the referenced securityScheme contains the referenced scopes.

To Reproduce

  1. Given attached fdxapi.tax.fails.yaml OpenAPI document which references securitySchemes in attached fdxapi.components.test.yaml OpenAPI document
  2. Run the spectral:oas ruleset
  3. Which returns error:
    36:15  warning  oas3-operation-security-defined  "fdx:customerpersonal:read" must be listed among scopes.  paths./tax-forms.get.security[0].OAuthFapi1Advanced[0]
  4. Given attached fdxapi.tax.passes.yaml OpenAPI document which includes the full securitySchemes definition copied exactly from fdxapi.components.test.yaml
  5. Run the spectral:oas ruleset
  6. Which succeeds without firing the rule

Expected behavior The original rule failure should not occur, since the referenced scope fdx:customerpersonal:read is defined in the referenced file's securitySchemes.

Environment (remove any that are not applicable):