Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7acc84a
feat: add 'asyncapi-operation-security-defined' rule
harshit078 Apr 21, 2026
ddcf5e1
Merge branch 'main' into add-asyncapi-rule
harshit078 Apr 21, 2026
e1a30b6
feat: added asyncapi-operation-security-define rule in tests
harshit078 Apr 21, 2026
1fa95ec
feat: added async operation function and updated rules
harshit078 Apr 22, 2026
14e7719
Merge branch 'main' into add-asyncapi-rule
harshit078 Apr 22, 2026
d6df2bf
feat: updated lint md docs and added tests
harshit078 Apr 22, 2026
d31dfbc
feat: added changset
harshit078 Apr 24, 2026
ce2789b
Merge branch 'main' into add-asyncapi-rule
harshit078 Apr 24, 2026
726a43e
fix: address comments by cursor
harshit078 Apr 24, 2026
bb01316
Merge branch 'main' into add-asyncapi-rule
harshit078 Apr 24, 2026
f671deb
Merge branch 'main' into add-asyncapi-rule
harshit078 Apr 30, 2026
573cbef
fix: removed v1 doc update for async api
harshit078 Apr 30, 2026
e0229df
fix: adress comments and remove shared helper
harshit078 Apr 30, 2026
27f2667
fix: security defined package
harshit078 Apr 30, 2026
0663a44
Merge branch 'main' into add-asyncapi-rule
harshit078 Apr 30, 2026
dd80e01
fix: address cursor comment
harshit078 Apr 30, 2026
cc6133e
Merge branch 'main' into add-asyncapi-rule
harshit078 May 5, 2026
4bd8b15
removed: asyncapi from v1 docs
harshit078 May 6, 2026
f2aee8b
fix: renamed v2 docs and updated to security defined
harshit078 May 6, 2026
c970602
fix: cursor comments
harshit078 May 6, 2026
4675ac4
fix: updated AsyncAPI3 docs and files
harshit078 May 6, 2026
75bf960
fix: removed v1 docs for async api
harshit078 May 6, 2026
bf96d18
fix: address cursor comments
harshit078 May 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-dryers-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@redocly/openapi-core": minor
---

Added `asyncapi-operation-security-defined` rule for AsyncAPI 2.x that reports when a security scheme referenced from an operation or server `security` array is not defined in `components.securitySchemes`.
1 change: 1 addition & 0 deletions docs/@v1/rules/ruleset-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ rules:
info-contact: off
info-license-strict: warn
operation-operationId: warn
asyncapi-operation-security-defined: error
tag-description: warn
tags-alphabetical: off
channels-kebab-case: off
Expand Down
1 change: 1 addition & 0 deletions docs/@v2/guides/lint-asyncapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ The currently supported rules are:

- `info-contact`: the `Info` section must contain a valid `Contact` field.
- `operation-operationId`: every operation must have a valid `operationId`.
- `security-defined`: every scheme referenced from an operation or server `security` array must be defined in `components.securitySchemes` (AsyncAPI 2.x and 3.0).
- `channels-kebab-case`: channel address should be `kebab-case` (lowercase with hyphens).
- `no-channel-trailing-slash`: channel names must not have trailing slashes in their address.
- `tag-description`: all tags require a description.
Expand Down
120 changes: 120 additions & 0 deletions docs/@v2/rules/async/security-defined.md
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code uses the rule name security-defined, but the docs still say asyncapi-operation-security-defined
Can you update related changes?

Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# security-defined

Verifies that every security scheme referenced from an operation or server `security` array is defined in `components.securitySchemes`.

| AsyncAPI | Compatibility |
| -------- | ------------- |
| 2.6 | ✅ |
| 3.0 | ✅ |
Comment thread
cursor[bot] marked this conversation as resolved.

## API design principles

In AsyncAPI 2.x, `security` entries on operations and servers are bare security scheme names that must match a key under `components.securitySchemes`.
A typo or rename leaves the reference dangling, and the document remains structurally valid — the mismatch is only visible to clients at runtime.

In AsyncAPI 3.0, `security` entries are `SecurityScheme` objects, typically expressed as `$ref`s into `components.securitySchemes`. The rule reports when a security `$ref` does not point into `components.securitySchemes` or when it points at a name that is not defined there.

This rule catches those name mismatches at lint time.

## Configuration

| Option | Type | Description |
| -------- | ------ | ------------------------------------------------------------------------------------------ |
| severity | string | Possible values: `off`, `warn`, `error`. Default `error` (in `recommended` configuration). |

An example configuration:

```yaml
rules:
security-defined: error
```

## Examples

Given this configuration:

```yaml
rules:
security-defined: error
```

Example of an **incorrect** security definition due to a mismatch between the referenced name and `components.securitySchemes`:

```yaml
asyncapi: '2.6.0'
channels:
user/signedup:
subscribe:
security:
- OAuth: [] # no matching scheme in components.securitySchemes
message:
messageId: UserSignedUp
components:
securitySchemes:
JWT:
type: http
scheme: bearer
```

Example of a **correct** AsyncAPI 2.x security definition:

```yaml
asyncapi: '2.6.0'
channels:
user/signedup:
subscribe:
security:
- JWT: []
message:
messageId: UserSignedUp
components:
securitySchemes:
JWT:
type: http
scheme: bearer
```

Example of an **incorrect** AsyncAPI 3.0 security definition where the `$ref` points at an undefined scheme:

```yaml
asyncapi: '3.0.0'
operations:
sendMessage:
action: send
channel:
$ref: '#/channels/userSignedUp'
security:
- $ref: '#/components/securitySchemes/OAuth'
components:
securitySchemes:
JWT:
type: http
scheme: bearer
```

Example of a **correct** AsyncAPI 3.0 security definition:

```yaml
asyncapi: '3.0.0'
operations:
sendMessage:
action: send
channel:
$ref: '#/channels/userSignedUp'
security:
- $ref: '#/components/securitySchemes/JWT'
components:
securitySchemes:
JWT:
type: http
scheme: bearer
```

## Related rules

- [security-defined](../oas/security-defined.md) — equivalent rule for OpenAPI.

## Resources

- [AsyncAPI 2.x rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/async2/security-defined.ts)
- [AsyncAPI 3.0 rule source](https://github.com/Redocly/redocly-cli/blob/main/packages/core/src/rules/async3/security-defined.ts)
1 change: 1 addition & 0 deletions docs/@v2/rules/built-in-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ Other rules, such as the `struct` and `info.*`, also apply to AsyncAPI.

- [channels-kebab-case](./async/channels-kebab-case.md): Channels must be in `kebab-case` format
- [no-channel-trailing-slash](./async/no-channel-trailing-slash.md): No trailing slashes on channels
- [security-defined](./async/security-defined.md): Security scheme names referenced from operations or servers must be defined in `components.securitySchemes`

## Arazzo rules

Expand Down
4 changes: 4 additions & 0 deletions docs/@v2/rules/ruleset-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ rules:
no-required-schema-properties-undefined: warn
no-schema-type-mismatch: warn
operation-operationId: warn
security-defined: warn
struct: error
tag-description: warn
```
Expand All @@ -163,6 +164,7 @@ rules:
no-required-schema-properties-undefined: warn
no-schema-type-mismatch: warn
operation-operationId: warn
security-defined: warn
struct: error
tag-description: warn
```
Expand Down Expand Up @@ -357,6 +359,7 @@ rules:
no-required-schema-properties-undefined: warn
no-schema-type-mismatch: error
operation-operationId: warn
security-defined: error
struct: error
tag-description: warn
```
Expand All @@ -372,6 +375,7 @@ rules:
no-required-schema-properties-undefined: warn
no-schema-type-mismatch: error
operation-operationId: warn
security-defined: error
struct: error
tag-description: warn
```
Expand Down
1 change: 1 addition & 0 deletions docs/@v2/v2.sidebars.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@
- separator: AsyncAPI
- page: rules/async/channels-kebab-case.md
- page: rules/async/no-channel-trailing-slash.md
- page: rules/async/security-defined.md
- separator: Open-RPC
- page: rules/openrpc/spec-no-duplicated-method-params.md
- page: rules/openrpc/spec-no-required-params-after-optional.md
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ exports[`resolveConfig > should ignore minimal from the root and read local file
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "error",
"operation-operationId": "warn",
"security-defined": "error",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand All @@ -57,6 +58,7 @@ exports[`resolveConfig > should ignore minimal from the root and read local file
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "error",
"operation-operationId": "warn",
"security-defined": "error",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand Down Expand Up @@ -428,6 +430,7 @@ exports[`resolveConfig > should resolve extends with local file config which con
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "error",
"operation-operationId": "warn",
"security-defined": "error",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand All @@ -444,6 +447,7 @@ exports[`resolveConfig > should resolve extends with local file config which con
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "error",
"operation-operationId": "warn",
"security-defined": "error",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand Down
12 changes: 12 additions & 0 deletions packages/core/src/config/__tests__/load.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "warn",
"operation-operationId": "warn",
"security-defined": "warn",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand All @@ -179,6 +180,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "warn",
"operation-operationId": "warn",
"security-defined": "warn",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand Down Expand Up @@ -487,6 +489,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "error",
"operation-operationId": "warn",
"security-defined": "error",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand All @@ -503,6 +506,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "error",
"operation-operationId": "warn",
"security-defined": "error",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand Down Expand Up @@ -816,6 +820,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "warn",
"operation-operationId": "warn",
"security-defined": "warn",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand All @@ -832,6 +837,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "warn",
"operation-operationId": "warn",
"security-defined": "warn",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand Down Expand Up @@ -1229,6 +1235,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "warn",
"operation-operationId": "warn",
"security-defined": "warn",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand All @@ -1245,6 +1252,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "warn",
"operation-operationId": "warn",
"security-defined": "warn",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand Down Expand Up @@ -1553,6 +1561,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "error",
"operation-operationId": "warn",
"security-defined": "error",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand All @@ -1569,6 +1578,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "error",
"operation-operationId": "warn",
"security-defined": "error",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand Down Expand Up @@ -1882,6 +1892,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "warn",
"operation-operationId": "warn",
"security-defined": "warn",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand All @@ -1898,6 +1909,7 @@ describe('loadConfig', () => {
"no-required-schema-properties-undefined": "warn",
"no-schema-type-mismatch": "warn",
"operation-operationId": "warn",
"security-defined": "warn",
"tag-description": "warn",
"tags-alphabetical": "off",
},
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/config/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ const all: RawGovernanceConfig<'built-in'> = {
'info-license-strict': 'error',
'no-channel-trailing-slash': 'error',
'operation-operationId': 'error',
'security-defined': 'error',
'tag-description': 'error',
'tags-alphabetical': 'error',
'no-duplicated-tag-names': 'error',
Expand All @@ -270,6 +271,7 @@ const all: RawGovernanceConfig<'built-in'> = {
'info-license-strict': 'error',
'no-channel-trailing-slash': 'error',
'operation-operationId': 'error',
'security-defined': 'error',
'tag-description': 'error',
'tags-alphabetical': 'error',
'no-duplicated-tag-names': 'error',
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/config/minimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ const minimal: RawGovernanceConfig<'built-in'> = {
'no-required-schema-properties-undefined': 'warn',
'no-schema-type-mismatch': 'warn',
'operation-operationId': 'warn',
'security-defined': 'warn',
'tag-description': 'warn',
'tags-alphabetical': 'off',
},
Expand All @@ -254,6 +255,7 @@ const minimal: RawGovernanceConfig<'built-in'> = {
'no-required-schema-properties-undefined': 'warn',
'no-schema-type-mismatch': 'warn',
'operation-operationId': 'warn',
'security-defined': 'warn',
'tag-description': 'warn',
'tags-alphabetical': 'off',
},
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/config/recommended-strict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ const recommendedStrict: RawGovernanceConfig<'built-in'> = {
'no-required-schema-properties-undefined': 'error',
'no-schema-type-mismatch': 'error',
'operation-operationId': 'error',
'security-defined': 'error',
'tag-description': 'error',
'tags-alphabetical': 'off',
},
Expand All @@ -254,6 +255,7 @@ const recommendedStrict: RawGovernanceConfig<'built-in'> = {
'no-required-schema-properties-undefined': 'error',
'no-schema-type-mismatch': 'error',
'operation-operationId': 'error',
'security-defined': 'error',
'tag-description': 'error',
'tags-alphabetical': 'off',
},
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/config/recommended.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ const recommended: RawGovernanceConfig<'built-in'> = {
'no-required-schema-properties-undefined': 'warn',
'no-schema-type-mismatch': 'error',
'operation-operationId': 'warn',
'security-defined': 'error',
'tag-description': 'warn',
'tags-alphabetical': 'off',
},
Expand All @@ -254,6 +255,7 @@ const recommended: RawGovernanceConfig<'built-in'> = {
'no-required-schema-properties-undefined': 'warn',
'no-schema-type-mismatch': 'error',
'operation-operationId': 'warn',
'security-defined': 'error',
'tag-description': 'warn',
'tags-alphabetical': 'off',
},
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/config/spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ const spec: RawGovernanceConfig<'built-in'> = {
'no-required-schema-properties-undefined': 'off',
'no-schema-type-mismatch': 'off',
'operation-operationId': 'off',
'security-defined': 'off',
'tag-description': 'off',
'tags-alphabetical': 'off',
},
Expand All @@ -254,6 +255,7 @@ const spec: RawGovernanceConfig<'built-in'> = {
'no-required-schema-properties-undefined': 'off',
'no-schema-type-mismatch': 'off',
'operation-operationId': 'off',
'security-defined': 'off',
'tag-description': 'off',
'tags-alphabetical': 'off',
},
Expand Down
Loading
Loading