stoplightio / spectral

A flexible JSON/YAML linter for creating automated style guides, with baked in support for OpenAPI (v3.1, v3.0, and v2.0), Arazzo v1.0, as well as AsyncAPI v2.x.
https://stoplight.io/spectral
Apache License 2.0
2.51k stars 241 forks source link

[AsyncAPI] Identify more orphaned components besides schemas #1103

Open nulltoken opened 4 years ago

nulltoken commented 4 years ago

In #974, the asyncapi ruleset has been initiated with a rule which will identify unused/orphaned schemas, under components.

As identified in #1073 this rule could really benefit from being extended to be able to detect other kinds of orphan objects (messageTraits, ...).

/cc @derberg

jonaslagoni commented 2 years ago

I have/plan to create sub-issues for solving this issue, it is based on the available components in https://www.asyncapi.com/docs/specifications/v2.3.0#componentsObject.

List of sub-issues:

jonaslagoni commented 2 years ago

Before adding the rest of the issues, a thought came to mind. Do we want all of these checks as part of one rule or split into multiple, as it seems https://github.com/stoplightio/spectral/pull/1440/files introduced 🤔

Or asked another way, have you folks seen a reason why someone might want to only check some of the components instead of all?

cc @P0lip

jonaslagoni commented 2 years ago

cc @magicmatatjahu @smoya

magicmatatjahu commented 2 years ago

I wa surprised that a rule was made that only checks for one type of component (I have in mind that PR with servers). I would prefer to go the way it is done in OpenAPI (as you mentioned) - one rule for all types of components.

jonaslagoni commented 2 years ago

Alright, let's keep it consistent then.