Convex · API Governance Rules

Convex API Rules

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

7 Rules error 4 warn 3
View Rules File View on GitHub

Rule Categories

convex

Rules

error
convex-http-info-title
HTTP API OpenAPI info.title must reference Convex HTTP API
$.info.title
error
convex-http-server-defined
At least one server URL must be defined for the deployment
$.servers
warn
convex-http-server-pattern
HTTP API server URLs must match the convex.cloud deployment pattern
$.servers[*].url
warn
convex-http-tag-required
Tags must declare Queries, Mutations, Actions, or Functions scope
$.tags[*].name
error
convex-http-operation-id-camelcase
Every operation must define an operationId using camelCase
$.paths.*[get,put,post,delete,patch].operationId
error
convex-http-paths-prefix
HTTP API paths must live under /api
$.paths
warn
convex-http-post-only
Function execution endpoints must be POST
$.paths[?(@property =~ /^\/api\/(query|mutation|action|run)/)]

Spectral Ruleset

Raw ↑
extends:
  - "spectral:oas"
documentationUrl: https://docs.convex.dev/http-api/
rules:
  convex-http-info-title:
    description: HTTP API OpenAPI info.title must reference Convex HTTP API
    severity: error
    given: "$.info.title"
    then:
      function: pattern
      functionOptions:
        match: "(?i)Convex\\s+HTTP"
  convex-http-server-defined:
    description: At least one server URL must be defined for the deployment
    severity: error
    given: "$.servers"
    then:
      function: length
      functionOptions:
        min: 1
  convex-http-server-pattern:
    description: HTTP API server URLs must match the convex.cloud deployment pattern
    severity: warn
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "convex\\.cloud"
  convex-http-tag-required:
    description: Tags must declare Queries, Mutations, Actions, or Functions scope
    severity: warn
    given: "$.tags[*].name"
    then:
      function: enumeration
      functionOptions:
        values:
          - Queries
          - Mutations
          - Actions
          - Functions
  convex-http-operation-id-camelcase:
    description: Every operation must define an operationId using camelCase
    severity: error
    given: "$.paths.*[get,put,post,delete,patch].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"
  convex-http-paths-prefix:
    description: HTTP API paths must live under /api
    severity: error
    given: "$.paths"
    then:
      field: "@key"
      function: pattern
      functionOptions:
        match: "^/api/"
  convex-http-post-only:
    description: Function execution endpoints must be POST
    severity: warn
    given: "$.paths[?(@property =~ /^\\/api\\/(query|mutation|action|run)/)]"
    then:
      function: defined
      field: post