The Interfaces team is working on an OpenAPI Spect linting rules that would support the OpenAPI style guide for REST APIs in production. As part of that work, we'd like to explore a method to add the linting rules as a CI operation that can be activated for relevant repositories that have OpenAPI spec.
We've been utilizing Spectral, an open source library for OpenAPI style guide linting. We have the operation running in a visual linting tool on toolforge: https://wmf-openapi-linter.toolforge.org/ (code: https://gitlab.wikimedia.org/toolforge-repos/wmf-openapi-linter )
The plan is to extract the linting rules themselves (here) into their own npm package (similar to what we do with ESLint) and then enable a linting capability (using Spectral, and the wikimedia OpenApi linting rules) in CI.
This ticket is meant to describe the necessary steps to make that happen and enable linting of OpenAPI spec in production CI.
Conditions of acceptance
- Create a linting package for CI
- Enable OpenAPI spec for the MediaWiki generated spec, and allow activating that test for repos (mediawiki core and extensions) that have REST Handlers that produce a spec.
- (optional?) Allow external services with OpenAPI spec to enable the linter for their specs.
Steps to get the OpenAPI linter into CI
(preliminary list)
- Split the linting rules out of the linter tool into a dedicated repo
- Create an npm package (could be initially beta/internal so it's easier for us to iterate a bit faster over versions)
- The package itself should be the rulesets; Spectral can be used for tests.
- Validate pass/fail conditions (warnings vs errors, etc) over the core spec before we make it CI test
- Come up with a reporting schema / template for the Spectral results in terminal
- Check into where to add Spectral and the linting rules into CI (talk to DevEx)