Smithsonian Institution · API Governance Rules

Smithsonian Institution API Rules

Spectral linting rules defining API design standards and conventions for Smithsonian Institution.

8 Rules error 2 warn 6
View Rules File View on GitHub

Rule Categories

smithsonian

Rules

error
smithsonian-operation-ids
All operations must have an operationId in camelCase
$.paths[*][*]
warn
smithsonian-operation-tags
All operations must have at least one tag
$.paths[*][*]
warn
smithsonian-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
error
smithsonian-api-key-required
All operations must require an api_key query parameter
$.paths[*].get
warn
smithsonian-pagination-support
Search endpoints should support start/rows pagination
$.paths[*search*].get
warn
smithsonian-json-response
All successful responses should return application/json
$.paths[*][*].responses.200.content
warn
smithsonian-no-trailing-slashes
API paths must not have trailing slashes
$.paths
warn
smithsonian-error-401
All operations must document 401 Unauthorized response
$.paths[*][*].responses

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  smithsonian-operation-ids:
    description: All operations must have an operationId in camelCase
    severity: error
    given: "$.paths[*][*]"
    then:
      field: operationId
      function: truthy

  smithsonian-operation-tags:
    description: All operations must have at least one tag
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  smithsonian-summary-title-case:
    description: Operation summaries must use Title Case
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 ]*$"

  smithsonian-api-key-required:
    description: All operations must require an api_key query parameter
    severity: error
    given: "$.paths[*].get"
    then:
      field: parameters
      function: truthy

  smithsonian-pagination-support:
    description: Search endpoints should support start/rows pagination
    severity: warn
    given: "$.paths[*search*].get"
    then:
      field: parameters
      function: truthy

  smithsonian-json-response:
    description: All successful responses should return application/json
    severity: warn
    given: "$.paths[*][*].responses.200.content"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - 'application/json'

  smithsonian-no-trailing-slashes:
    description: API paths must not have trailing slashes
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        notMatch: "/$"

  smithsonian-error-401:
    description: All operations must document 401 Unauthorized response
    severity: warn
    given: "$.paths[*][*].responses"
    then:
      field: '401'
      function: truthy