US Army Corps of Engineers · API Governance Rules

US Army Corps of Engineers API Rules

Spectral linting rules defining API design standards and conventions for US Army Corps of Engineers.

8 Rules error 2 warn 5 info 1
View Rules File View on GitHub

Rule Categories

usace

Rules

warn
usace-operations-have-tags
All USACE CWMS Data API operations must have at least one tag for grouping
$.paths[*][get,post,put,patch,delete]
warn
usace-operation-ids-kebab-case
Operation IDs should use camelCase as per USACE API conventions
$.paths[*][get,post,put,patch,delete].operationId
warn
usace-parameters-have-descriptions
All query parameters should have descriptions for CWMS API usability
$.paths[*][*].parameters[?(@.in == 'query')]
info
usace-pagination-page-size
CWMS Data API uses page-size parameter for pagination
$.paths[*][get].parameters[*]
error
usace-response-200-defined
All GET operations must define a 200 response
$.paths[*][get]
warn
usace-error-schema-defined
Error responses should reference the Error schema
$.paths[*][*].responses[?(@property >= '400')]
warn
usace-no-trailing-slash
API paths should not have trailing slashes
$.paths
error
usace-server-url-https
USACE API servers must use HTTPS
$.servers[*].url

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  usace-operations-have-tags:
    description: All USACE CWMS Data API operations must have at least one tag for grouping
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  usace-operation-ids-kebab-case:
    description: Operation IDs should use camelCase as per USACE API conventions
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  usace-parameters-have-descriptions:
    description: All query parameters should have descriptions for CWMS API usability
    severity: warn
    given: "$.paths[*][*].parameters[?(@.in == 'query')]"
    then:
      field: description
      function: truthy

  usace-pagination-page-size:
    description: CWMS Data API uses page-size parameter for pagination
    severity: info
    given: "$.paths[*][get].parameters[*]"
    then:
      function: schema
      functionOptions:
        schema:
          if:
            properties:
              name:
                const: page-size
          then:
            properties:
              schema:
                properties:
                  type:
                    const: integer

  usace-response-200-defined:
    description: All GET operations must define a 200 response
    severity: error
    given: "$.paths[*][get]"
    then:
      field: responses.200
      function: truthy

  usace-error-schema-defined:
    description: Error responses should reference the Error schema
    severity: warn
    given: "$.paths[*][*].responses[?(@property >= '400')]"
    then:
      field: content
      function: truthy

  usace-no-trailing-slash:
    description: API paths should not have trailing slashes
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        notMatch: ".*/$"

  usace-server-url-https:
    description: USACE API servers must use HTTPS
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"