Commodity Futures Trading Commission · API Governance Rules

Commodity Futures Trading Commission API Rules

Spectral linting rules defining API design standards and conventions for Commodity Futures Trading Commission.

6 Rules error 4 warn 2
View Rules File View on GitHub

Rule Categories

cftc

Rules

error
cftc-cot-info-title
COT OpenAPI info.title must reference Commitments of Traders or CFTC
$.info.title
error
cftc-cot-server-defined
At least one server URL must be defined for the SODA endpoint
$.servers
error
cftc-cot-server-publicreporting
Server URL must point to publicreporting.cftc.gov
$.servers[*].url
warn
cftc-cot-tag-required
COT-related tags must be declared at the document level
$.tags[*].name
error
cftc-cot-operation-id-camelcase
Every operation must define an operationId using camelCase
$.paths.*[get,put,post,delete,patch].operationId
warn
cftc-cot-soda-resource-path
COT paths should resolve to a Socrata four-by-four .json resource path
$.paths

Spectral Ruleset

Raw ↑
extends:
  - "spectral:oas"
documentationUrl: https://publicreporting.cftc.gov/
rules:
  cftc-cot-info-title:
    description: COT OpenAPI info.title must reference Commitments of Traders or CFTC
    severity: error
    given: "$.info.title"
    then:
      function: pattern
      functionOptions:
        match: "(?i)(CFTC|Commitments\\s+of\\s+Traders)"
  cftc-cot-server-defined:
    description: At least one server URL must be defined for the SODA endpoint
    severity: error
    given: "$.servers"
    then:
      function: length
      functionOptions:
        min: 1
  cftc-cot-server-publicreporting:
    description: Server URL must point to publicreporting.cftc.gov
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "publicreporting\\.cftc\\.gov"
  cftc-cot-tag-required:
    description: COT-related tags must be declared at the document level
    severity: warn
    given: "$.tags[*].name"
    then:
      function: enumeration
      functionOptions:
        values:
          - COT
          - Legacy
          - Disaggregated
          - TFF
          - Supplemental
  cftc-cot-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]+$"
  cftc-cot-soda-resource-path:
    description: COT paths should resolve to a Socrata four-by-four .json resource path
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "/[a-z0-9]{4}-[a-z0-9]{4}\\.json"