Mathpix · API Governance Rules

Mathpix API Rules

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

8 Rules error 3 warn 4 info 1
View Rules File View on GitHub

Rule Categories

mathpix

Rules

error
mathpix-versioned-base-path
All Mathpix endpoints must live under /v3 to match docs.mathpix.com routing.
$.paths
warn
mathpix-dual-apikey-security
Server-side operations must require both app_id and app_key headers (except /v3/app-tokens which only needs app_key).
$.components.securitySchemes
warn
mathpix-snake-case-parameters
All parameter names use snake_case to match Mathpix request/response field naming.
$.paths[*][*].parameters[*].name
warn
mathpix-operation-id-camel-case
operationId must be lowerCamelCase (e.g. processImage, downloadDocx).
$.paths[*][*].operationId
warn
mathpix-title-case-summaries
Operation summaries must use Title Case.
$.paths[*][*].summary
error
mathpix-tag-present
Every operation must declare at least one tag (Images, Documents, Conversions, Batches, Strokes, App Tokens, Usage).
$.paths[*][*]
info
mathpix-contact-email
info.contact must point to [email protected].
$.info.contact
error
mathpix-production-server
servers[] must declare https://api.mathpix.com.
$.servers[*].url

Spectral Ruleset

Raw ↑
extends: ["spectral:oas"]
documentationUrl: https://docs.mathpix.com
description: >
  Spectral ruleset enforcing the conventions observed across the Mathpix OpenAPI specs:
  versioned /v3 base path, dual app_id + app_key API key security, snake_case operation parameters,
  Title Case operation summaries, and required tags scoped to the API's business surface.
functions: []
rules:
  mathpix-versioned-base-path:
    description: All Mathpix endpoints must live under /v3 to match docs.mathpix.com routing.
    severity: error
    given: $.paths
    then:
      function: pattern
      field: "@key"
      functionOptions:
        match: "^/v3(/|$)"

  mathpix-dual-apikey-security:
    description: Server-side operations must require both app_id and app_key headers (except /v3/app-tokens which only needs app_key).
    severity: warn
    given: $.components.securitySchemes
    then:
      function: truthy

  mathpix-snake-case-parameters:
    description: All parameter names use snake_case to match Mathpix request/response field naming.
    severity: warn
    given: $.paths[*][*].parameters[*].name
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-z0-9_]*$|^(Content-Type|app_id|app_key|app_token)$"

  mathpix-operation-id-camel-case:
    description: operationId must be lowerCamelCase (e.g. processImage, downloadDocx).
    severity: warn
    given: $.paths[*][*].operationId
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  mathpix-title-case-summaries:
    description: Operation summaries must use Title Case.
    severity: warn
    given: $.paths[*][*].summary
    then:
      function: pattern
      functionOptions:
        match: "^([A-Z][a-zA-Z0-9]*)(\\s[A-Z][a-zA-Z0-9]*)*$"

  mathpix-tag-present:
    description: Every operation must declare at least one tag (Images, Documents, Conversions, Batches, Strokes, App Tokens, Usage).
    severity: error
    given: $.paths[*][*]
    then:
      field: tags
      function: truthy

  mathpix-contact-email:
    description: info.contact must point to [email protected].
    severity: info
    given: $.info.contact
    then:
      field: email
      function: pattern
      functionOptions:
        match: "^support@mathpix\\.com$"

  mathpix-production-server:
    description: servers[] must declare https://api.mathpix.com.
    severity: error
    given: $.servers[*].url
    then:
      function: pattern
      functionOptions:
        match: "^https://api\\.mathpix\\.com$"