Vercel · API Governance Rules

Vercel API Rules

Spectral linting rules defining API design standards and conventions for Vercel.

11 Rules error 5 warn 6
View Rules File View on GitHub

Rule Categories

vercel

Rules

error
vercel-bearer-auth
Vercel APIs must use Bearer token authentication
$.components.securitySchemes[*]
error
vercel-operation-id-required
All operations must define an operationId
$.paths[*][get,post,put,patch,delete]
warn
vercel-operation-id-camel-case
operationId should use camelCase
$.paths[*][get,post,put,patch,delete].operationId
warn
vercel-summary-title-case
Operation summaries must use Title Case
$.paths[*][get,post,put,patch,delete].summary
error
vercel-summary-required
All operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
vercel-ai-gateway-path-version
AI Gateway paths must use /v1/ prefix
$.paths[*]~
error
vercel-401-response
All operations must document 401 Unauthorized response
$.paths[*][get,post,put,patch,delete].responses
warn
vercel-429-response
Operations should document 429 rate limit response
$.paths[*][post].responses
warn
vercel-path-kebab-case
Path segments should use kebab-case
$.paths[*]~
warn
vercel-info-contact
API info must include contact information
$.info
error
vercel-servers-defined
API must define server URLs
$

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  # Vercel APIs use Bearer token authentication
  vercel-bearer-auth:
    description: Vercel APIs must use Bearer token authentication
    message: Security scheme must use Bearer scheme
    severity: error
    given: "$.components.securitySchemes[*]"
    then:
      field: scheme
      function: pattern
      functionOptions:
        match: "^bearer$"

  # All operations must have operationId
  vercel-operation-id-required:
    description: All operations must define an operationId
    message: Operation must have an operationId
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  # operationId should be camelCase
  vercel-operation-id-camel-case:
    description: operationId should use camelCase
    message: "operationId '{{value}}' should use camelCase"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  # Summaries must be Title Case
  vercel-summary-title-case:
    description: Operation summaries must use Title Case
    message: "Summary '{{value}}' must use Title Case"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z]*(\\s[A-Z][a-zA-Z]*)*$"

  # All operations need summaries
  vercel-summary-required:
    description: All operations must have a summary
    message: Operation must have a summary
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  # API Gateway endpoints use /v1/ prefix
  vercel-ai-gateway-path-version:
    description: AI Gateway paths must use /v1/ prefix
    message: "Path '{{value}}' must start with /v1/"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^/v1/"

  # Must define 401 response
  vercel-401-response:
    description: All operations must document 401 Unauthorized response
    message: Operation must define a 401 response
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      field: "401"
      function: truthy

  # Must define 429 rate limit response for AI APIs
  vercel-429-response:
    description: Operations should document 429 rate limit response
    message: Operation should define a 429 Too Many Requests response
    severity: warn
    given: "$.paths[*][post].responses"
    then:
      field: "429"
      function: truthy

  # Use kebab-case for path segments
  vercel-path-kebab-case:
    description: Path segments should use kebab-case
    message: "Path segment should use kebab-case"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/v[0-9]+)?(/[a-z0-9-]+(/{[a-zA-Z]+})?)*$"

  # Contact info required
  vercel-info-contact:
    description: API info must include contact information
    message: API info must include contact details
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy

  # Servers must be defined
  vercel-servers-defined:
    description: API must define server URLs
    message: API must define at least one server
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy