StockData · API Governance Rules

StockData API Rules

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

8 Rules error 3 warn 3 info 2
View Rules File View on GitHub

Rule Categories

stockdata

Rules

error
stockdata-api-token-required
All StockData API endpoints must require the api_token query parameter.
$.paths.*.*.parameters[?(@.name == 'api_token')]
warn
stockdata-operationid-camel-case
StockData operationIds must use camelCase to match the existing SDK conventions.
$.paths[*][*].operationId
warn
stockdata-tags-title-case
All tags on operations must use Title Case.
$.paths[*][*].tags[*]
error
stockdata-response-200-required
All StockData GET operations must define a 200 success response.
$.paths[*].get
info
stockdata-pagination-params
Collection endpoints returning lists should support page and limit query parameters for pagination.
$.paths[*].get[?(@.operationId =~ /^(get|list|search)/)]
warn
stockdata-no-empty-descriptions
All parameters must have non-empty descriptions.
$.paths[*][*].parameters[*]
info
stockdata-symbols-param-description
The symbols parameter must clearly state it accepts comma-separated ticker symbols.
$.paths[*][*].parameters[?(@.name == 'symbols')]
error
stockdata-server-v1-prefix
The StockData API server URL must include /v1 in the base path.
$.servers[*].url

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  stockdata-api-token-required:
    description: All StockData API endpoints must require the api_token query parameter.
    message: "Missing required api_token query parameter on operation '{{operationId}}'."
    severity: error
    given: "$.paths.*.*.parameters[?(@.name == 'api_token')]"
    then:
      field: required
      function: truthy

  stockdata-operationid-camel-case:
    description: >-
      StockData operationIds must use camelCase to match the existing SDK
      conventions.
    message: "OperationId '{{value}}' must be camelCase."
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  stockdata-tags-title-case:
    description: All tags on operations must use Title Case.
    message: "Tag '{{value}}' must use Title Case."
    severity: warn
    given: "$.paths[*][*].tags[*]"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 &-]*$"

  stockdata-response-200-required:
    description: All StockData GET operations must define a 200 success response.
    message: "Operation '{{operationId}}' is missing a 200 response."
    severity: error
    given: "$.paths[*].get"
    then:
      field: responses.200
      function: defined

  stockdata-pagination-params:
    description: >-
      Collection endpoints returning lists should support page and limit
      query parameters for pagination.
    message: "List operation '{{operationId}}' should define 'page' and 'limit' parameters."
    severity: info
    given: "$.paths[*].get[?(@.operationId =~ /^(get|list|search)/)]"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            parameters:
              type: array

  stockdata-no-empty-descriptions:
    description: All parameters must have non-empty descriptions.
    message: "Parameter '{{path}}' must have a description."
    severity: warn
    given: "$.paths[*][*].parameters[*]"
    then:
      field: description
      function: truthy

  stockdata-symbols-param-description:
    description: >-
      The symbols parameter must clearly state it accepts comma-separated
      ticker symbols.
    message: "The 'symbols' parameter description should mention comma-separated ticker symbols."
    severity: info
    given: "$.paths[*][*].parameters[?(@.name == 'symbols')]"
    then:
      field: description
      function: truthy

  stockdata-server-v1-prefix:
    description: The StockData API server URL must include /v1 in the base path.
    message: "StockData server URL must include /v1."
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: ".*/v1$"