asyncapi-operation-security
Operation have to reference a defined security schemes.
- Applies to
security- Selects
$.channels[*][publish,subscribe].security.*- Function
asyncApiSecurity- Specs
- AsyncAPI 2.x
- Message
{{error}}
Use it
This rule ships with OpenLint in spectral:asyncapi. Extending the ruleset turns it on:
extends: spectral:asyncapi
rules:
asyncapi-operation-security: error # or off, or another severity
Definition
As defined in @openlint/openlint-rulesets. Functions show by name.
asyncapi-operation-security:
description: Operation have to reference a defined security schemes.
message: '{{error}}'
severity: error
recommended: true
formats:
- AsyncAPI 2.x
given: '$.channels[*][publish,subscribe].security.*'
then:
function: asyncApiSecurity
functionOptions:
objectType: Operation
About this rule
Operation security values must match a scheme defined in the components.securitySchemes object. It also checks if there are oauth2 scopes that have been defined for the given security.
Good Example
channels:
"user/signup":
publish:
security:
- petstore_auth: []
components:
securitySchemes:
petstore_auth: ...
Bad Example
channels:
"user/signup":
publish:
security:
- not_defined: []
components:
securitySchemes:
petstore_auth: ...