Sophos · API Governance Rules

Sophos API Rules

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

10 Rules error 3 warn 6 info 1
View Rules File View on GitHub

Rule Categories

sophos

Rules

error
sophos-requires-api-key-header
All Sophos SIEM operations must require the x-api-key header parameter
$.paths[*][get,post,put,patch,delete].parameters[?(@.name == 'x-api-key')]
warn
sophos-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][get,post,put,patch,delete].summary
warn
sophos-operation-has-tags
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
info
sophos-cursor-pagination
Sophos APIs use cursor-based pagination; use 'cursor' query parameter
$.paths[*][get].parameters[?(@.name == 'limit')]
warn
sophos-401-response
Operations with auth must document 401 Unauthorized response
$.paths[*][get,post,put,patch,delete].responses
error
sophos-operation-id-required
All operations must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
sophos-operation-id-camel-case
OperationId must use camelCase convention
$.paths[*][get,post,put,patch,delete].operationId
warn
sophos-response-schema-defined
Successful responses must have a schema
$.paths[*][get,post,put,patch,delete].responses['200','201'].content['application/json']
warn
sophos-tags-title-case
All tags in the spec must use Title Case
$.tags[*].name
error
sophos-security-defined
Security must be defined at the global or operation level
$

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  # Sophos API uses x-api-key header + Bearer token dual auth - enforce both
  sophos-requires-api-key-header:
    description: All Sophos SIEM operations must require the x-api-key header parameter
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].parameters[?(@.name == 'x-api-key')]"
    then:
      field: required
      function: truthy

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

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

  # Pagination cursor pattern - Sophos uses cursor-based pagination
  sophos-cursor-pagination:
    description: Sophos APIs use cursor-based pagination; use 'cursor' query parameter
    severity: info
    given: "$.paths[*][get].parameters[?(@.name == 'limit')]"
    then:
      field: schema.maximum
      function: defined

  # Operations must have 401 response for missing auth
  sophos-401-response:
    description: Operations with auth must document 401 Unauthorized response
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      field: "401"
      function: defined

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

  # operationId must use camelCase
  sophos-operation-id-camel-case:
    description: OperationId must use camelCase convention
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  # Response schemas must be defined
  sophos-response-schema-defined:
    description: Successful responses must have a schema
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses['200','201'].content['application/json']"
    then:
      field: schema
      function: defined

  # All tags must be Title Case
  sophos-tags-title-case:
    description: All tags in the spec must use Title Case
    severity: warn
    given: "$.tags[*].name"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*([ ][A-Z][a-zA-Z0-9]*)*$"

  # Security must be defined at global or operation level
  sophos-security-defined:
    description: Security must be defined at the global or operation level
    severity: error
    given: "$"
    then:
      field: security
      function: defined