Skip to content

Commit

Permalink
feat: add API descriptor with API_SPECTRAL with AsyncAPI/OpenAPI support
Browse files Browse the repository at this point in the history
Add API descriptor as modified copy of the OPENAPI descriptor.
Deprecate the contained linter OPENAPI_SPECTRAL.

Add `.spectral.yaml` as default config file to `TEMPLATE/`
as modified copy of `.openapirc.yml` with rulesets for
AsyncAPI and OpenAPI (previously, only OpenAPI).

Closes: #3387
  • Loading branch information
pjungermann committed Apr 22, 2024
1 parent cee23e5 commit b6603a4
Show file tree
Hide file tree
Showing 76 changed files with 797 additions and 65 deletions.
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@
"asdict",
"ashokm",
"assignuser",
"asyncapi",
"autocorrect",
"autocrlf",
"autofix",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-BETA-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ jobs:
[
"action_actionlint",
"ansible_ansible_lint",
"api_spectral",
"arm_arm_ttk",
"bash_exec",
"bash_shellcheck",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-DEV-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
[
"action_actionlint",
"ansible_ansible_lint",
"api_spectral",
"arm_arm_ttk",
"bash_exec",
"bash_shellcheck",
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-RELEASE-linters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
[
"action_actionlint",
"ansible_ansible_lint",
"api_spectral",
"arm_arm_ttk",
"bash_exec",
"bash_shellcheck",
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Note: Can be used with `oxsecurity/megalinter@beta` in your GitHub Action mega-l
- Media

- New linters
- `API_SPECTRAL` was added as replacement for `OPENAPI_SPECTRAL` (deprecated), supporting AsyncAPI and OpenAPI by default. Uses Spectral's standard config file name `.spectral.yaml` instead of `.openapirc.yml` with a default config with rulesets for AsyncAPI and OpenAPI enabled. Fixes [#3387](https://github.com/oxsecurity/megalinter/issues/3387)

- Reporters
- Add ruff sarif support
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ WORKDIR /node-deps
RUN npm --no-cache install --ignore-scripts --omit=dev \
@salesforce/cli \
typescript \
@stoplight/spectral-cli \
@coffeelint/cli \
jscpd \
stylelint \
Expand Down Expand Up @@ -241,7 +242,6 @@ RUN npm --no-cache install --ignore-scripts --omit=dev \
markdownlint-cli \
markdown-link-check \
markdown-table-formatter \
@stoplight/spectral-cli \
secretlint \
@secretlint/secretlint-rule-preset-recommend \
@secretlint/secretlint-formatter-sarif \
Expand Down
11 changes: 11 additions & 0 deletions TEMPLATES/.spectral.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

#######################################
#######################################
## AsyncAPI and OpenAPI Linter rules ##
#######################################
#######################################

extends:
- spectral:asyncapi
- spectral:oas
39 changes: 39 additions & 0 deletions docs/descriptors/api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
---
title: API linters in MegaLinter
description: spectral is available to analyze API files in MegaLinter
---
<!-- markdownlint-disable MD003 MD020 MD033 MD041 -->
<!-- @generated by .automation/build.py, please don't update manually -->
<!-- Instead, update descriptor file at https://github.com/oxsecurity/megalinter/tree/main/megalinter/descriptors/api.yml -->
# API

## Linters

| Linter | Additional |
|-----------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| [**spectral**](api_spectral.md)<br/>[_API_SPECTRAL_](api_spectral.md) | [![GitHub stars](https://img.shields.io/github/stars/stoplightio/spectral?cacheSeconds=3600)](https://github.com/stoplightio/spectral) |

## Linted files

- File extensions:
- `.yml`
- `.yaml`
- `.json`

- Detected file content:
- `"asyncapi":`
- `"openapi":`
- `"swagger":`
- `asyncapi:`
- `openapi:`
- `swagger:`

## Configuration in MegaLinter

| Variable | Description | Default value |
|--------------------------|-------------------------------------------------|---------------|
| API_PRE_COMMANDS | List of bash commands to run before the linters | None |
| API_POST_COMMANDS | List of bash commands to run after the linters | None |
| API_FILTER_REGEX_INCLUDE | Custom regex including filter | |
| API_FILTER_REGEX_EXCLUDE | Custom regex excluding filter | |

134 changes: 134 additions & 0 deletions docs/descriptors/api_spectral.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/descriptors/clojure_cljstyle.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ This linter is available in the following flavours

| <!-- --> | Flavor | Description | Embedded linters | Info |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------|:--------------------------|:----------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 122 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 123 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |

## Behind the scenes

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/dart_dartanalyzer.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ This linter is available in the following flavours

| <!-- --> | Flavor | Description | Embedded linters | Info |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------|:--------------------------|:----------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 122 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 123 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |

## Behind the scenes

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/latex_chktex.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ This linter is available in the following flavours

| <!-- --> | Flavor | Description | Embedded linters | Info |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------|:--------------------------|:----------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 122 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 123 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |

## Behind the scenes

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/lua_luacheck.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ This linter is available in the following flavours

| <!-- --> | Flavor | Description | Embedded linters | Info |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------|:--------------------------|:----------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 122 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 123 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |

## Behind the scenes

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/markdown_remark_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ This linter is available in the following flavours

| <!-- --> | Flavor | Description | Embedded linters | Info |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------|:--------------------------|:----------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 122 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 123 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |

## Behind the scenes

Expand Down
6 changes: 3 additions & 3 deletions docs/descriptors/openapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ description: spectral is available to analyze OPENAPI files in MegaLinter

## Linters

| Linter | Additional |
|-----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|
| [**spectral**](openapi_spectral.md)<br/>[_OPENAPI_SPECTRAL_](openapi_spectral.md) | [![GitHub stars](https://img.shields.io/github/stars/stoplightio/spectral?cacheSeconds=3600)](https://github.com/stoplightio/spectral) |
| Linter | Additional |
|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [**spectral**](openapi_spectral.md)<br/>[_OPENAPI_SPECTRAL_](openapi_spectral.md) | ![deprecated](https://shields.io/badge/-deprecated-red) [![GitHub stars](https://img.shields.io/github/stars/stoplightio/spectral?cacheSeconds=3600)](https://github.com/stoplightio/spectral) |

## Linted files

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/perl_perlcritic.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ This linter is available in the following flavours

| <!-- --> | Flavor | Description | Embedded linters | Info |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------|:--------------------------|:----------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 122 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 123 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |

## Behind the scenes

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/puppet_puppet_lint.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ This linter is available in the following flavours

| <!-- --> | Flavor | Description | Embedded linters | Info |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------|:--------------------------|:----------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 122 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 123 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |

## Behind the scenes

Expand Down
2 changes: 1 addition & 1 deletion docs/descriptors/r_lintr.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ This linter is available in the following flavours

| <!-- --> | Flavor | Description | Embedded linters | Info |
|:--------------------------------------------------------------------------------------------------------------------------------------------------------:|:-----------------------------------------------------|:--------------------------|:----------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 122 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |
| <img src="https://github.com/oxsecurity/megalinter/raw/main/docs/assets/images/mega-linter-square.png" alt="" height="32px" class="megalinter-icon"></a> | [all](https://megalinter.io/beta/supported-linters/) | Default MegaLinter Flavor | 123 | ![Docker Image Size (tag)](https://img.shields.io/docker/image-size/oxsecurity/megalinter/beta) ![Docker Pulls](https://img.shields.io/docker/pulls/oxsecurity/megalinter) |

## Behind the scenes

Expand Down
Loading

0 comments on commit b6603a4

Please sign in to comment.