Fastly · API Governance Rules

Fastly API Rules

Spectral linting rules defining API design standards and conventions for Fastly.

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

Rule Categories

fastly

Rules

error
fastly-operation-tag-required
Every operation must have at least one tag matching a Fastly API surface.
$.paths[*][get,put,post,delete,patch,head,options]
warn
fastly-operation-summary-title-case
Operation summaries must use Title Case.
$.paths[*][get,put,post,delete,patch,head,options].summary
warn
fastly-operationid-camel-case
operationId must be lowerCamelCase.
$.paths[*][get,put,post,delete,patch,head,options].operationId
info
fastly-fastly-key-security
Operations should be secured via the Fastly-Key API key header.
$
error
fastly-no-numeric-status-keys-without-description
Every response must have a description.
$.paths[*][get,put,post,delete,patch,head,options].responses[*]
error
fastly-server-url-https
Servers must use https.
$.servers[*].url
error
fastly-info-required
Every spec must define info.title, info.description, and info.version.
$.info

Spectral Ruleset

Raw ↑
extends: ["spectral:oas"]

documentationUrl: https://github.com/api-evangelist/fastly/blob/main/rules/fastly-rules.yml

rules:
  # Fastly conventions
  fastly-operation-tag-required:
    description: Every operation must have at least one tag matching a Fastly API surface.
    severity: error
    given: $.paths[*][get,put,post,delete,patch,head,options]
    then:
      field: tags
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 1

  fastly-operation-summary-title-case:
    description: Operation summaries must use Title Case.
    severity: warn
    given: $.paths[*][get,put,post,delete,patch,head,options].summary
    then:
      function: pattern
      functionOptions:
        match: "^([A-Z][a-zA-Z0-9]*)( [A-Z][a-zA-Z0-9]*)*$"

  fastly-operationid-camel-case:
    description: operationId must be lowerCamelCase.
    severity: warn
    given: $.paths[*][get,put,post,delete,patch,head,options].operationId
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  fastly-fastly-key-security:
    description: Operations should be secured via the Fastly-Key API key header.
    severity: info
    given: $
    then:
      field: components.securitySchemes
      function: truthy

  fastly-no-numeric-status-keys-without-description:
    description: Every response must have a description.
    severity: error
    given: $.paths[*][get,put,post,delete,patch,head,options].responses[*]
    then:
      field: description
      function: truthy

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

  fastly-info-required:
    description: Every spec must define info.title, info.description, and info.version.
    severity: error
    given: $.info
    then:
      - field: title
        function: truthy
      - field: description
        function: truthy
      - field: version
        function: truthy