LintGPT: Write API Style Guides in natural language
Write an API Style Guide as bullet points, Optic will enforce it during design and in CI.
openapi: 3.0.1 ... paths: /authors: get: responses: 200: content: application/json: schema: properties: id: type: stringfirstName: type: string ...
Style Guides made easy
Save time writing Spectral Rules
Save hours writing and debugging Spectral rules. Optic lets you write rules in your language and makes it easier for everyone on your team to understand your style guide.
- Enforce Consistent design
- for naming, pagination, security, etc.
- Prevent Breaking Changes
- that matter to your consumers
- Improve documentation
- by requiring a consistent style in your descriptions and summaries
Use cases:
// Spectral rule
json-field-names-snake-case:
message: Field name must be lower snake_case
severity: error
given: "$.paths.*.*[responses,requestBody]..content..schema..properties.*~"
then:
function: pattern
functionOptions:
match: ^[a-z_][a-z_0-9]*$
lintgpt:
- Property names must be lower snake case ie "snake_case"
Your API Design Co-Pilot
Automate more of API Design Reviews
LintGPT makes it possible to automatically check for API design practices that required manual review before. Large language models are great at understanding code and identifying patterns we care about.
lintgpt:
- "Responses that return an array at their root MUST wrap that array in an object. ie {'users': []}"
- "Responses that return lists must have a pagination strategy that uses offsets."
- "MUST use nouns in URIs to represent resources"
- "All resources in a response should have an `id` `created_at` and `updated_at` property"
- "Arrays must never be null. Clients expect empty arrays to be an array w/ length 0."
- "No endpoint should allow users to create multiple resources at once."
- "If a GET operation has query parameters that appear sensitive or have pii (ie. `token` or `first_name`) require it to use POST method instead."
Visual API Diffs, right in CI
Run locally and in CI
LintGPT is integrated into Optic so your rules run withOptic's breaking change checks, your existing Spectral rules, and Optic contract testing. Results are visualized in CI so they can be fixed before they ship.