US Army · API Governance Rules

US Army API Rules

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

7 Rules error 2 warn 4 info 1
View Rules File View on GitHub

Rule Categories

army

Rules

warn
army-operations-have-tags
All US Army API operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
info
army-paths-use-v1-prefix
All Army API paths should use the /api/v1 prefix via servers configuration
$.servers[*].url
error
army-get-operations-have-200
All GET operations must define a 200 response
$.paths[*][get]
warn
army-operations-have-operation-ids
All Army API operations must have operationId for SDK generation
$.paths[*][get,post,put,patch,delete]
warn
army-parameters-have-descriptions
All parameters should have descriptions
$.paths[*][*].parameters[*]
warn
army-responses-have-schemas
All 200 responses should define a content schema
$.paths[*][*].responses.200
error
army-server-https
US Army API servers must use HTTPS
$.servers[*].url

Spectral Ruleset

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

  army-paths-use-v1-prefix:
    description: All Army API paths should use the /api/v1 prefix via servers configuration
    severity: info
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: ".*\/v[0-9].*"

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

  army-operations-have-operation-ids:
    description: All Army API operations must have operationId for SDK generation
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  army-parameters-have-descriptions:
    description: All parameters should have descriptions
    severity: warn
    given: "$.paths[*][*].parameters[*]"
    then:
      field: description
      function: truthy

  army-responses-have-schemas:
    description: All 200 responses should define a content schema
    severity: warn
    given: "$.paths[*][*].responses.200"
    then:
      field: content
      function: truthy

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