๐Ÿ›ก๏ธ 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