Starter Templates
Jumpstart your API gateway development process with our pre-built starter templates
API Linting
See how to use API linting to enforce api consistency and require Zuplo features like policies.
npx create-zuplo-api --example api-lintingAPI Linting with Vacuum
This example demonstrates how to lint your Zuplo API using Vacuum, an OpenAPI linter. It includes both built-in OpenAPI rules and custom rules specific to Zuplo projects, such as requiring certain policies on all routes.
Prerequisites
- A Zuplo account. You can sign up for free.
- Node.js installed locally
Working with this Example
Locally
Working locally is the best way to explore and understand the code for this example. You can get a local version by using the Zuplo CLI:
Then, in the project directory run the following commands:
Deploy this example to Zuplo
It is also possible to deploy this example directly to your Zuplo account and work with it via the Zuplo Portal. You can do this by clicking the Deploy to Zuplo button anywhere on this page.
How It Works
Ruleset Configuration
The linting rules are defined in config/api-ruleset.yaml. This file configures both standard OpenAPI rules and custom Zuplo-specific rules.
Built-in Rules
Standard OpenAPI validation rules can be enabled:
Custom Zuplo Rules
This example includes custom rules that enforce Zuplo-specific requirements:
1. Valid Path Mode
Ensures x-zuplo-path.pathMode is either open-api or url-pattern:
2. Required Route Configuration
Ensures all operations have x-zuplo-route with required properties:
3. Required Policy
Ensures all routes have a specific policy (e.g., authentication):
4. Path Prefix
Ensures all paths start with a specific value (e.g., /v1):
Project Structure
Running the Linter
Run the linter against your routes:
Example output when rules fail:
Customizing Rules
Change Required Policy Name
Edit config/api-ruleset.yaml:
Change Required Path Prefix
Add More Custom Functions
Create a new JavaScript file in lint-functions/ and reference it in your ruleset:
CI/CD Integration
Add linting to your CI pipeline to catch issues before deployment:
Learn More
Other Examples
Jumpstart your API gateway development process with our pre-built starter templates