The Bureau of Economic Analysis · API Governance Rules

The Bureau of Economic Analysis API Rules

Spectral linting rules defining API design standards and conventions for The Bureau of Economic Analysis.

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

Rule Categories

bea

Rules

error
bea-operation-must-have-userid-param
All BEA API operations must include a UserID query parameter for authentication.
$.paths[*][get].parameters[*]
error
bea-operation-must-have-method-param
All BEA API GET operations must include a 'method' query parameter specifying the API method to invoke.
$.paths[*][get]
warn
bea-result-format-enum
ResultFormat parameter must only accept JSON or XML values.
$.paths[*][get].parameters[?(@.name == 'ResultFormat')].schema
warn
bea-operations-must-have-tags
All operations must be tagged to organize by domain (Metadata, National Accounts, Regional, Industry, International).
$.paths[*][get]
warn
bea-operations-must-have-summary
All operations must have a summary using Title Case.
$.paths[*][get]
error
bea-responses-must-include-200
All BEA API operations must define a 200 success response.
$.paths[*][get].responses
warn
bea-responses-must-include-400
All BEA API operations should define a 400 error response for invalid request parameters.
$.paths[*][get].responses
error
bea-userid-must-be-required
The UserID parameter must be marked as required on all endpoints.
$.paths[*][get].parameters[?(@.name == 'UserID')]
warn
bea-parameters-must-have-descriptions
All parameters must have descriptions to aid API consumers.
$.paths[*][get].parameters[*]
warn
bea-info-must-have-contact
The API info object should include contact information for developer support.
$.info

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  bea-operation-must-have-userid-param:
    description: All BEA API operations must include a UserID query parameter for authentication.
    severity: error
    given: "$.paths[*][get].parameters[*]"
    then:
      field: name
      function: pattern
      functionOptions:
        match: "^UserID$"

  bea-operation-must-have-method-param:
    description: All BEA API GET operations must include a 'method' query parameter specifying the API method to invoke.
    severity: error
    given: "$.paths[*][get]"
    then:
      field: parameters
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            type: object
            properties:
              name:
                type: string
                enum: ["method"]
              in:
                type: string
                enum: ["query"]

  bea-result-format-enum:
    description: ResultFormat parameter must only accept JSON or XML values.
    severity: warn
    given: "$.paths[*][get].parameters[?(@.name == 'ResultFormat')].schema"
    then:
      field: enum
      function: truthy

  bea-operations-must-have-tags:
    description: All operations must be tagged to organize by domain (Metadata, National Accounts, Regional, Industry, International).
    severity: warn
    given: "$.paths[*][get]"
    then:
      field: tags
      function: truthy

  bea-operations-must-have-summary:
    description: All operations must have a summary using Title Case.
    severity: warn
    given: "$.paths[*][get]"
    then:
      field: summary
      function: truthy

  bea-responses-must-include-200:
    description: All BEA API operations must define a 200 success response.
    severity: error
    given: "$.paths[*][get].responses"
    then:
      field: "200"
      function: truthy

  bea-responses-must-include-400:
    description: All BEA API operations should define a 400 error response for invalid request parameters.
    severity: warn
    given: "$.paths[*][get].responses"
    then:
      field: "400"
      function: truthy

  bea-userid-must-be-required:
    description: The UserID parameter must be marked as required on all endpoints.
    severity: error
    given: "$.paths[*][get].parameters[?(@.name == 'UserID')]"
    then:
      field: required
      function: truthy

  bea-parameters-must-have-descriptions:
    description: All parameters must have descriptions to aid API consumers.
    severity: warn
    given: "$.paths[*][get].parameters[*]"
    then:
      field: description
      function: truthy

  bea-info-must-have-contact:
    description: The API info object should include contact information for developer support.
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy