US House of Representatives · API Governance Rules

US House of Representatives API Rules

Spectral linting rules defining API design standards and conventions for US House of Representatives.

11 Rules error 1 warn 6 info 4
View Rules File View on GitHub

Rule Categories

congress

Rules

warn
congress-operation-ids-camel-case
Operation IDs must use camelCase naming
$.paths[*][*].operationId
error
congress-operations-have-summaries
All operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
congress-operations-have-tags
All operations should be tagged for grouping
$.paths[*][get,post,put,patch,delete]
warn
congress-response-200-defined
All GET operations should define a 200 response
$.paths[*][get]
info
congress-v3-path-prefix
All paths should use the v3 versioning format
$.servers[*].url
info
congress-format-param-documented
Format parameters should list valid values
$.paths[*][*].parameters[?(@.name == 'format')]
info
congress-limit-param-max
Limit parameters should specify the maximum allowed value
$.paths[*][*].parameters[?(@.name == 'limit')]
warn
congress-security-scheme-defined
API should define authentication/security scheme
$.components.securitySchemes
warn
congress-info-contact-present
API should include contact information
$.info
warn
congress-tags-title-case
Tags must use Title Case naming
$.tags[*].name
info
congress-path-versioned
API paths should not hardcode version numbers
$.paths

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  congress-operation-ids-camel-case:
    description: Operation IDs must use camelCase naming
    message: Operation ID "{{value}}" should use camelCase (e.g., listBills, getMember)
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  congress-operations-have-summaries:
    description: All operations must have a summary
    message: Operation is missing a summary
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  congress-operations-have-tags:
    description: All operations should be tagged for grouping
    message: Operation is missing tags
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  congress-response-200-defined:
    description: All GET operations should define a 200 response
    message: GET operation is missing a 200 OK response
    severity: warn
    given: "$.paths[*][get]"
    then:
      field: responses.200
      function: truthy

  congress-v3-path-prefix:
    description: All paths should use the v3 versioning format
    message: API paths should reflect versioning
    severity: info
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: ".*\/v[0-9]+$"

  congress-format-param-documented:
    description: Format parameters should list valid values
    message: Format parameter should specify valid options
    severity: info
    given: "$.paths[*][*].parameters[?(@.name == 'format')]"
    then:
      field: schema.enum
      function: truthy

  congress-limit-param-max:
    description: Limit parameters should specify the maximum allowed value
    message: Limit parameter should specify maximum value (250)
    severity: info
    given: "$.paths[*][*].parameters[?(@.name == 'limit')]"
    then:
      field: schema.maximum
      function: truthy

  congress-security-scheme-defined:
    description: API should define authentication/security scheme
    message: API specification should define security schemes
    severity: warn
    given: "$.components.securitySchemes"
    then:
      function: truthy

  congress-info-contact-present:
    description: API should include contact information
    message: API info is missing contact details
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy

  congress-tags-title-case:
    description: Tags must use Title Case naming
    message: Tag "{{value}}" should use Title Case
    severity: warn
    given: "$.tags[*].name"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 &]*$"

  congress-path-versioned:
    description: API paths should not hardcode version numbers
    message: Version should be in server URL, not paths
    severity: info
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        notMatch: "^\/v[0-9]+"