spectral:oas warn on by default

oas3-operation-security-defined

Operation "security" values must match a scheme defined in the "components.securitySchemes" object.

Applies to
security
Selects
#SecurityRequirementObject
Function
oasSecurityDefined
Specs
OpenAPI 3.0OpenAPI 3.1OpenAPI 3.2
Message
{{error}}

Use it

This rule ships with OpenLint in spectral:oas. Extending the ruleset turns it on:

extends: spectral:oas
rules:
  oas3-operation-security-defined: warn   # or off, or another severity

Definition

As defined in @openlint/openlint-rulesets. Functions show by name.

oas3-operation-security-defined:
  description: >-
    Operation "security" values must match a scheme defined in the
    "components.securitySchemes" object.
  message: '{{error}}'
  recommended: true
  formats:
    - OpenAPI 3.x
  given: '#SecurityRequirementObject'
  then:
    function: oasSecurityDefined
    functionOptions:
      oasVersion: 3

About this rule

Operation security values must match a scheme defined in the components.securitySchemes object.

Sources