USDA Agricultural Research Service (ARS) API Rules

Spectral linting rules defining API design standards and conventions for USDA Agricultural Research Service (ARS).

7 Rules error 2 warn 3 info 2
View Rules File View on GitHub

Rule Categories

usda

Rules

error
usda-ars-operation-summary
All operations must have a summary
$.paths[*][*]
warn
usda-ars-operation-tags
All operations must have tags
$.paths[*][*]
error
usda-ars-get-200-response
GET operations must define a 200 response
$.paths[*].get
info
usda-ars-api-key-authentication
FoodData Central API requires api_key parameter
$.paths[*].get.parameters[*]
warn
usda-ars-path-params-documented
Path parameters must have descriptions
$.paths[*][*].parameters[?(@.in == 'path')]
info
usda-ars-license-info
APIs should document the CC0 license
$.info
warn
usda-ars-contact-info
APIs should have contact information
$.info

Spectral Ruleset

Raw ↑
extends: "spectral:oas"
rules:
  usda-ars-operation-summary:
    description: All operations must have a summary
    message: "Operation missing summary"
    severity: error
    given: "$.paths[*][*]"
    then:
      field: summary
      function: truthy

  usda-ars-operation-tags:
    description: All operations must have tags
    message: "Operation missing tags"
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  usda-ars-get-200-response:
    description: GET operations must define a 200 response
    message: "GET operation missing 200 response"
    severity: error
    given: "$.paths[*].get"
    then:
      field: responses.200
      function: truthy

  usda-ars-api-key-authentication:
    description: FoodData Central API requires api_key parameter
    message: "FDC API endpoints should document api_key query parameter"
    severity: info
    given: "$.paths[*].get.parameters[*]"
    then:
      function: truthy

  usda-ars-path-params-documented:
    description: Path parameters must have descriptions
    message: "Path parameter missing description"
    severity: warn
    given: "$.paths[*][*].parameters[?(@.in == 'path')]"
    then:
      field: description
      function: truthy

  usda-ars-license-info:
    description: APIs should document the CC0 license
    message: "API should include license information (CC0 1.0 Universal)"
    severity: info
    given: "$.info"
    then:
      field: license
      function: truthy

  usda-ars-contact-info:
    description: APIs should have contact information
    message: "API missing contact information"
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy