Spin · API Governance Rules

Spin API Rules

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

7 Rules error 2 warn 5
View Rules File View on GitHub

Rule Categories

spin

Rules

warn
spin-operation-summary-title-case
All operation summaries must use Title Case
$.paths[*][*].summary
warn
spin-tags-title-case
All tags must use Title Case
$.tags[*].name
error
spin-operation-id
All operations must have an operationId
$.paths[*][get,post,put,patch,delete]
error
spin-operation-tags
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
warn
spin-operation-description
All operations should have a description
$.paths[*][get,post,put,patch,delete]
warn
spin-schema-descriptions
All schema properties should have descriptions
$.components.schemas[*].properties[*]
warn
spin-info-contact
API info should include contact details
$.info

Spectral Ruleset

spin-rules.yml Raw ↑
extends: spectral:oas
rules:
  spin-operation-summary-title-case:
    description: All operation summaries must use Title Case
    message: Operation summary "{{value}}" should be in Title Case
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*([ ][A-Z][a-zA-Z0-9]*)*$"

  spin-tags-title-case:
    description: All tags must use Title Case
    message: Tag "{{value}}" should be in Title Case
    severity: warn
    given: "$.tags[*].name"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*([ ][A-Z][a-zA-Z0-9]*)*$"

  spin-operation-id:
    description: All operations must have an operationId
    message: Operation must have an operationId
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  spin-operation-tags:
    description: All operations must have at least one tag
    message: Operation must have at least one tag
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  spin-operation-description:
    description: All operations should have a description
    message: Operation should have a description
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  spin-schema-descriptions:
    description: All schema properties should have descriptions
    message: Schema property should have a description
    severity: warn
    given: "$.components.schemas[*].properties[*]"
    then:
      field: description
      function: truthy

  spin-info-contact:
    description: API info should include contact details
    message: API info should have a contact object with url
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy