Skip to content
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

Support AsyncAPI linting using Spectral #3387

Closed
pjungermann opened this issue Feb 23, 2024 · 7 comments · Fixed by #3474
Closed

Support AsyncAPI linting using Spectral #3387

pjungermann opened this issue Feb 23, 2024 · 7 comments · Fixed by #3474
Labels
enhancement New feature or request

Comments

@pjungermann
Copy link
Contributor

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when […]

Currently, AsyncAPI definitions are not ignored/not linted by Spectral.

Describe the solution you'd like
A clear and concise description of what you want to happen.

There is a linter OPENAPI_SPECTRAL with the config file .openapirc.yml.
The default file shipped with MegaLinter contains

extends: spectral:oas

However, Spectral supports OpenAPI and AsyncAPI.

extends:
  - spectral:asyncapi
  - spectral:oas

could be used to validate both.

The recommended naming for the config file is .spectral.yaml according to their documentation.

However, the linter is called OPENAPI_SPECTRAL which sets the scope to OpenAPI only.

Similar to others like prettier, we could add an additional linter ASYNCAPI_SPECTRAL.
Either with a config file .asyncapirc.yml or using a shared config file .spectral.yaml as default.

Changing the default config filename would be fine as long as there is some backward compatibility
to custom .openapirc.yml files with repos.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

@pjungermann pjungermann added the enhancement New feature or request label Feb 23, 2024
@nvuillam
Copy link
Member

nvuillam commented Feb 28, 2024

@pjungermann would it just work if we update default config file shipped with MegaLinter ?

If not, we could also update the doc to tell to override the config file name using variable OPENAPI_SPECTRAL_CONFIG_FILE

Would you like to make a PR ? :)

@pjungermann
Copy link
Contributor Author

pjungermann commented Feb 28, 2024

@nvuillam updating the config file would be a viable option (+ updating docs).

  1. reuse same linter and config file
  2. separate linter
    1. separate config files (users could override it if they want to use one for both)
    2. shared config file
      1. stick to current file name
      2. use filename as of Spectral's docs

Based on the setup for other linters, I assumed there might be a preference for ASYNCAPI_SPECTRAL.

I'm willing to provide a PR. Before, I wanted to find out the right solution for this project.

@nvuillam
Copy link
Member

nvuillam commented Mar 2, 2024

@pjungermann I would prefer the option where OPENAPI_SPECTRAL can handle sync + async APIs ^^

Ypu could rename the default config file as .spectral.yml, and put the mixed config in default content

extends:
  - spectral:asyncapi
  - spectral:oas

Semantically, OPENAPI_SPECTRAL would analyze openapi + asyncapi , but i wouldn't like to create a new descriptor for each new capability

Another solution might be to deprecate OPENAPI descriptor and create a new descriptor API that would contain API_SPECTRAL, but in my opinion that's not mandatory

@pjungermann
Copy link
Contributor Author

I like the idea of changing OPENAPI to API as linter grouping 👍

I will have a look at preparing the necessary changes.

@nvuillam
Copy link
Member

nvuillam commented Mar 6, 2024

@pjungermann great :)

In order to ensure compatibility until the next major release (usually once a year), please do not remove the openapi descriptor, just add deprecated and create a new api descriptor aside :)

Copy link
Contributor

github-actions bot commented Apr 6, 2024

This issue has been automatically marked as stale because it has not had recent activity.
It will be closed in 14 days if no further activity occurs.
Thank you for your contributions.

If you think this issue should stay open, please remove the O: stale 🤖 label or comment on the issue.

@github-actions github-actions bot added the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Apr 6, 2024
@pjungermann
Copy link
Contributor Author

not stale

@github-actions github-actions bot removed the O: stale 🤖 This issue or pull request is stale, it will be closed if there is no activity label Apr 8, 2024
pjungermann added a commit to pjungermann/megalinter that referenced this issue Apr 8, 2024
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: oxsecurity#3387
pjungermann added a commit to pjungermann/megalinter that referenced this issue Apr 8, 2024
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: oxsecurity#3387
pjungermann added a commit to pjungermann/megalinter that referenced this issue Apr 8, 2024
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: oxsecurity#3387
pjungermann added a commit to pjungermann/megalinter that referenced this issue Apr 8, 2024
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: oxsecurity#3387
pjungermann added a commit to pjungermann/megalinter that referenced this issue Apr 15, 2024
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: oxsecurity#3387
pjungermann added a commit to pjungermann/megalinter that referenced this issue Apr 22, 2024
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: oxsecurity#3387
pjungermann added a commit to pjungermann/megalinter that referenced this issue Apr 23, 2024
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: oxsecurity#3387
pjungermann added a commit to pjungermann/megalinter that referenced this issue Apr 24, 2024
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: oxsecurity#3387
nvuillam pushed a commit that referenced this issue Apr 24, 2024
…ort (#3474)

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants