WHOOP · API Governance Rules

WHOOP API Rules

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

6 Rules error 2 warn 3 info 1
View Rules File View on GitHub

Rule Categories

whoop

Rules

error
whoop-server-host
The single canonical WHOOP API server is https://api.prod.whoop.com/developer.
$.servers[*]
error
whoop-version-prefix
WHOOP paths must be under /v1/ (legacy mapping) or /v2/ (current).
$.paths[*]~
warn
whoop-snake-case-properties
WHOOP JSON property names use snake_case.
$.components.schemas[*].properties[*]~
warn
whoop-title-case-summaries
Operation summaries should use Title Case.
$.paths[*][get,post,put,patch,delete].summary
warn
whoop-oauth-scopes
Member-data OAuth scopes must follow the read: pattern.
$.components.securitySchemes.OAuth.flows.authorizationCode.scopes
info
whoop-uuid-id-format
v2 resource IDs (sleep, workout) must use the uuid format.
$.components.schemas[Sleep,WorkoutV2].properties.id

Spectral Ruleset

Raw ↑
extends:
  - "spectral:oas"
formats:
  - oas3
rules:
  whoop-server-host:
    description: The single canonical WHOOP API server is https://api.prod.whoop.com/developer.
    message: "Server URL must be https://api.prod.whoop.com/developer."
    severity: error
    given: $.servers[*]
    then:
      field: url
      function: pattern
      functionOptions:
        match: "^https://api\\.prod\\.whoop\\.com/developer$"

  whoop-version-prefix:
    description: WHOOP paths must be under /v1/ (legacy mapping) or /v2/ (current).
    message: "Path must begin with /v1/ or /v2/."
    severity: error
    given: $.paths[*]~
    then:
      function: pattern
      functionOptions:
        match: "^/v[12]/"

  whoop-snake-case-properties:
    description: WHOOP JSON property names use snake_case.
    message: "Schema property '{{property}}' must use snake_case."
    severity: warn
    given: $.components.schemas[*].properties[*]~
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-z0-9_]*$"

  whoop-title-case-summaries:
    description: Operation summaries should use Title Case.
    message: "Summary should use Title Case: '{{value}}'."
    severity: warn
    given: $.paths[*][get,post,put,patch,delete].summary
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z0-9]"

  whoop-oauth-scopes:
    description: Member-data OAuth scopes must follow the read:<resource> pattern.
    message: "Scope name '{{property}}' must match read:<resource>."
    severity: warn
    given: $.components.securitySchemes.OAuth.flows.authorizationCode.scopes
    then:
      field: "@key"
      function: pattern
      functionOptions:
        match: "^read:[a-z_]+$"

  whoop-uuid-id-format:
    description: v2 resource IDs (sleep, workout) must use the uuid format.
    message: "id field should declare format: uuid."
    severity: info
    given: $.components.schemas[Sleep,WorkoutV2].properties.id
    then:
      field: format
      function: enumeration
      functionOptions:
        values: ["uuid"]