-
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add spectral ruleset docs (#790)
Co-authored-by: Sergio Moya <[email protected]>
- Loading branch information
1 parent
c6f0a10
commit 6f84151
Showing
7 changed files
with
1,282 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
node_modules | ||
.vscode | ||
.DS_Store | ||
/docs/api.md | ||
/coverage | ||
/lib | ||
/esm | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# AsyncAPI Spectral Ruleset | ||
|
||
ParserJS has some built-in Spectral rulesets that validate AsyncAPI documents and inform about good practices. Those are: | ||
|
||
- [Core Ruleset](./core-ruleset.md) - validates the overall structure of AsyncAPI documents (applied for each version, starting from `2.0.0`). | ||
- [Recommended Ruleset](./recommended-ruleset.md) - verifies good practices within AsyncAPI documents structure (applied for each version, starting from `2.0.0`). | ||
- [v2 Core Ruleset](./v2-core-ruleset.md) - validates the overall structure of AsyncAPI version `2.x.x` documents. | ||
- [v2 Recommended Ruleset](./v2-recommended-ruleset.md) - verifies good practices within AsyncAPI version `2.x.x` documents. | ||
|
||
> **Note** | ||
> The described rulesets are similar to the one found at https://github.com/stoplightio/spectral/blob/develop/docs/reference/asyncapi-rules.md. They have been adapted under the rights of the Apache-2.0 license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# AsyncAPI Core Ruleset | ||
|
||
The core ruleset validates the overall structure of AsyncAPI documents. | ||
|
||
> **Note** | ||
> These rules will apply to each version, starting from `2.0.0`. | ||
## Rules | ||
|
||
### asyncapi-is-asyncapi | ||
|
||
The input must be a document with a supported version of AsyncAPI. | ||
|
||
#### Good example | ||
|
||
```yaml | ||
asyncapi: 2.0.0 | ||
... | ||
``` | ||
|
||
#### Bad example | ||
|
||
```yaml | ||
openapi: 3.1.0 | ||
... | ||
``` | ||
|
||
```yaml | ||
asyncapi: 2.1.37 | ||
... | ||
``` | ||
|
||
### asyncapi-latest-version | ||
|
||
Checking if the AsyncAPI document is using the latest version. | ||
|
||
#### Good example | ||
|
||
Assuming the latest version is `2.6.0`: | ||
|
||
```yaml | ||
asyncapi: 2.6.0 | ||
... | ||
``` | ||
|
||
#### Bad example | ||
|
||
```yaml | ||
asyncapi: 2.5.0 | ||
... | ||
``` | ||
|
||
### asyncapi-document-resolved | ||
|
||
Checking if the AsyncAPI document has a valid resolved (with resolved references) structure based on the specification's JSON Schema. | ||
|
||
#### Good example | ||
|
||
```yaml | ||
asyncapi: 2.0.0 | ||
info: | ||
title: Valid AsyncAPI document | ||
version: 1.0 | ||
channels: | ||
user/signup: | ||
publish: | ||
message: | ||
$ref: '#/components/messages/user' | ||
components: | ||
messages: | ||
user: {...} | ||
``` | ||
#### Bad example | ||
```yaml | ||
asyncapi: 2.0.0 | ||
info: | ||
title: Invalid AsyncAPI document | ||
version: 1.0 | ||
``` | ||
### asyncapi-document-unresolved | ||
Checking if the AsyncAPI document has a valid unresolved (with unresolved references) structure based on the specification's JSON Schema. | ||
#### Good example | ||
```yaml | ||
asyncapi: 2.0.0 | ||
info: | ||
title: Valid AsyncAPI document | ||
version: 1.0 | ||
channels: | ||
user/signup: | ||
publish: | ||
message: | ||
$ref: '#/components/messages/user' | ||
components: | ||
messages: | ||
user: {...} | ||
``` | ||
#### Bad example | ||
```yaml | ||
asyncapi: 2.0.0 | ||
info: | ||
title: Invalid AsyncAPI document | ||
version: 1.0 | ||
channels: | ||
user/signup: | ||
publish: | ||
$ref: '#/components/x-operations/someOperation' | ||
components: | ||
'x-operations': | ||
someOperation: {} | ||
``` |
Oops, something went wrong.