-
-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add API descriptor with API_SPECTRAL with AsyncAPI/OpenAPI support #3474
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
openapi: '3.0.0' |
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,3 @@ | ||
{ | ||
"openapi": "3.0.0" | ||
} |
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,13 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: Example | ||
version: "1.0" | ||
contact: | ||
name: Justin Kalland | ||
email: [email protected] | ||
description: Test for mega-linter | ||
servers: | ||
- url: "http://localhost:3000" | ||
paths: {} | ||
tags: | ||
- name: example |
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,23 @@ | ||
{ | ||
"openapi": "3.0.0", | ||
"info": { | ||
"title": "Example", | ||
"version": "1.0", | ||
"contact": { | ||
"name": "Justin Kalland", | ||
"email": "[email protected]" | ||
}, | ||
"description": "Test for mega-linter" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://localhost:3000" | ||
} | ||
], | ||
"paths": {}, | ||
"tags": [ | ||
{ | ||
"name": "example" | ||
} | ||
] | ||
} |
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,28 @@ | ||
Results of spectral linter (version 5.6.0) | ||
See documentation on https://megalinter.io/descriptors/openapi_spectral/ | ||
----------------------------------------------- | ||
|
||
[ERROR] .automation/test/api/api_bad_1.yml | ||
OpenAPI 3.x detected | ||
|
||
.automation/test/api/api_bad_1.yml | ||
1:1 warning info-contact Info object should contain `contact` object. | ||
1:1 warning info-description OpenAPI object info `description` must be present and non-empty string. | ||
1:1 warning oas3-api-servers OpenAPI `servers` must be present and non-empty array. | ||
1:1 error oas3-schema Object should have required property `info`. | ||
1:1 warning openapi-tags OpenAPI object should have non-empty `tags` array. | ||
|
||
✖ 5 problems (1 error, 4 warnings, 0 infos, 0 hints) | ||
|
||
[ERROR] .automation/test/api/api_bad_2.json | ||
OpenAPI 3.x detected | ||
|
||
.automation/test/api/api_bad_2.json | ||
1:1 warning info-contact Info object should contain `contact` object. | ||
1:1 warning info-description OpenAPI object info `description` must be present and non-empty string. | ||
1:1 warning oas3-api-servers OpenAPI `servers` must be present and non-empty array. | ||
1:1 error oas3-schema Object should have required property `info`. | ||
1:1 warning openapi-tags OpenAPI object should have non-empty `tags` array. | ||
|
||
✖ 5 problems (1 error, 4 warnings, 0 infos, 0 hints) | ||
|
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,12 @@ | ||
Results of spectral linter (version 5.6.0) | ||
See documentation on https://megalinter.io/descriptors/api_spectral/ | ||
----------------------------------------------- | ||
|
||
[SUCCESS] .automation/test/api/api_good_1.yml | ||
OpenAPI 3.x detected | ||
No results with a severity of 'error' or higher found! | ||
|
||
[SUCCESS] .automation/test/api/api_good_2.json | ||
OpenAPI 3.x detected | ||
No results with a severity of 'error' or higher found! | ||
|
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,12 @@ | ||
TAP version 13 | ||
1..4 | ||
not ok 1 - api_bad_1.yml | ||
--- | ||
message: OpenAPI 3.x detected\n\n/tmp/lint/.automation/test/api/api_bad_1.ymlopenapi\n 1 1 warning info-contact Info object should contain `contact` object.\n 1 1 warning info-description OpenAPI object info `description` must be present and non-empty string.\n 1 1 warning oas3-api-servers OpenAPI `servers` must be present and non-empty array.\n 1 1 error oas3-schema Object should have required property `info`.\n 1 1 warning openapi-tags OpenAPI object should have non-empty `tags` array.\n\n✖ 5 problems (1 error, 4 warnings, 0 infos, 0 hints)\n | ||
... | ||
not ok 2 - api_bad_2.json | ||
--- | ||
message: OpenAPI 3.x detected\n\n/tmp/lint/.automation/test/api/api_bad_2.jsonopenapi\n 1 1 warning info-contact Info object should contain `contact` object.\n 1 1 warning info-description OpenAPI object info `description` must be present and non-empty string.\n 1 1 warning oas3-api-servers OpenAPI `servers` must be present and non-empty array.\n 1 1 error oas3-schema Object should have required property `info`.\n 1 1 warning openapi-tags OpenAPI object should have non-empty `tags` array.\n\n✖ 5 problems (1 error, 4 warnings, 0 infos, 0 hints)\n | ||
... | ||
ok 3 - api_good_1.yml | ||
ok 4 - api_good_2.json |
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 |
---|---|---|
|
@@ -521,6 +521,7 @@ | |
"asdict", | ||
"ashokm", | ||
"assignuser", | ||
"asyncapi", | ||
"autocorrect", | ||
"autocrlf", | ||
"autofix", | ||
|
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
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
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 and OpenAPI Linter rules ## | ||
####################################### | ||
####################################### | ||
|
||
extends: | ||
- spectral:asyncapi | ||
- spectral:oas |
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,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 | | | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nvuillam idea for improvement here: sort the required packages, to not have the order changed uselessly like here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
100% agreed, can be done in another PR :)