US Department of Defense · API Governance Rules

US Department of Defense API Rules

Spectral linting rules defining API design standards and conventions for US Department of Defense.

10 Rules error 2 warn 6 info 2
View Rules File View on GitHub

Rule Categories

cwms

Rules

warn
cwms-operation-ids-camel-case
Operation IDs must use camelCase naming
$.paths[*][*].operationId
error
cwms-operations-have-summaries
All operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
cwms-operations-have-tags
All operations should be tagged for grouping
$.paths[*][get,post,put,patch,delete]
info
cwms-office-param-described
Office parameter should have a description explaining valid values
$.paths[*][*].parameters[?(@.name == 'office')]
warn
cwms-response-200-defined
All GET operations should define a 200 response
$.paths[*][get]
error
cwms-servers-defined
API must define servers for base URL
$
warn
cwms-info-contact-present
API should have contact information
$.info
warn
cwms-tags-title-case
Tags must use Title Case naming
$.tags[*].name
info
cwms-time-params-iso8601
Time parameters should specify ISO 8601 format
$.paths[*][*].parameters[?(@.name == 'begin' || @.name == 'end')]
warn
cwms-path-lowercase
API paths should use lowercase
$.paths

Spectral Ruleset

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

  cwms-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

  cwms-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

  cwms-office-param-described:
    description: Office parameter should have a description explaining valid values
    message: Query parameter 'office' should have a description
    severity: info
    given: "$.paths[*][*].parameters[?(@.name == 'office')]"
    then:
      field: description
      function: truthy

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

  cwms-servers-defined:
    description: API must define servers for base URL
    message: No servers defined in the API specification
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

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

  cwms-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 &]*$"

  cwms-time-params-iso8601:
    description: Time parameters should specify ISO 8601 format
    message: Time parameter should specify format in description
    severity: info
    given: "$.paths[*][*].parameters[?(@.name == 'begin' || @.name == 'end')]"
    then:
      field: description
      function: truthy

  cwms-path-lowercase:
    description: API paths should use lowercase
    message: Path should be lowercase
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z\\/\\{\\}\\-]*$"