๐ก๏ธ OWASP API Governance
April 4, 2025 ยท View on GitHub
A lightweight project for enforcing API governance using Spectral. It ensures your OpenAPI specifications follow best practices, consistent naming conventions, and organization-wide rules.
๐ Features
- โ Lint OpenAPI 2.0 & 3.0 specs
- โ Custom governance rules with Spectral
- โ Naming conventions, summaries, tags, and more
- โ Optimized with compiled rulesets
- โ GitHub Actions support for CI linting
๐ Project Structure
api-governance/ โโโ .spectral.yaml # Main ruleset config โโโ compiled-ruleset.json # Compiled version (faster linting) โโโ governance-rules/ # Custom rule files โ โโโ governance-rules.yaml โ โโโ naming-conventions.yaml โ โโโ functions/ โโโ specs/ # Sample OpenAPI specs โโโ docs/ # Documentation โโโ .github/workflows/ # GitHub CI โ โโโ lint-api.yml โโโ package.json โโโ README.md
๐งช Linting Commands
Install dependencies:
npm install
Compile ruleset:
npm run lint:compile
Lint all API specs:
npm run lint:api
Lint a single API spec:
npx spectral lint -r compiled-ruleset.json specs/example-api.yaml
๐ค Contributing
Fork this repo
Create a new branch
Make changes
Run npm run lint:compile and npm run lint:api
Submit a PR ๐
๐ License
Apache 2.0 License
๐ Resources
OWASP API Security
Spectral Documentation