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.46k stars 234 forks source link

Deprecate documentation rules #2350

Open philsturgeon opened 1 year ago

philsturgeon commented 1 year ago

User story. As a Spectral CLI user who has never hard of Stoplight, I can validate the bare necessities of my OpenAPI documents, without getting any Stoplight-centric rules or opinions about what would make good quality OpenAPI-documentation in your tooling, so that I can focus on just making OAS that works. If I am interested in making better documentation and/or Stoplight specific displays I can use https://github.com/stoplightio/spectral-documentation.

Is this related to a problem?

These rules do not related to whether OpenAPI is valid or not, so moving them into an optional ruleset helps reduce noise for new users who don't know any different, giving them more time to focus on building their APIs.

Describe the solution you'd like

Many of the most opinionated rules were either removed in previous versions, or bumped down to recommended: false, but there are more we could remove now that spectral-documentation is complete.

magicmatatjahu commented 1 year ago

Hi! If you are going to make a PR for this please also remember to remove rules from AsyncAPI rulesets like:

They are also opinionated as in OpenAPI and work (validate) in this sam way. Also we should change asyncapi-operation-operationId from error to the warning severity, because operationId in AsyncAPI is not obligatory - or even remove that rule.

Let me know when you will wanna do that changes.

philsturgeon commented 1 year ago

I have started creating a new OpenAPI ruleset for this which can live in a new spectral-openapi repo, to allow spectral:oas to be deprecated.

Currently there are a few blockers.

  1. oasSchema.test.ts requires spectral core in a way I'm not sure how to include. import { RulesetFunctionContext } from "@stoplight/spectral-core/src";
  2. helper/tester.ts needs spectral/test-utils which is not on npm, only in the monorepo.

I'll see what I can copy paste hack for now, but I think this could be a good chance to tidy up the test-utils for public usage, so the various spectral-owasp, spectral-url-versioning, etc aren't all copy/pasting testing helpers.

philsturgeon commented 1 year ago

Making some progress!

https://github.com/philsturgeon/spectral-openapi