Sumo Logic · API Governance Rules

Sumo Logic API Rules

Spectral linting rules defining API design standards and conventions for Sumo Logic.

9 Rules error 2 warn 5 info 2
View Rules File View on GitHub

Rule Categories

sumo

Rules

warn
sumo-logic-versioned-paths
Sumo Logic API paths must be versioned with /v1/ or /v2/
$.paths
error
sumo-logic-operation-summary-required
All Sumo Logic operations must have a summary
$.paths[*][get,post,put,patch,delete]
error
sumo-logic-operation-id-required
All Sumo Logic operations must have an operationId
$.paths[*][get,post,put,patch,delete]
warn
sumo-logic-operation-id-camel-case
Sumo Logic operationIds should use camelCase
$.paths[*][*].operationId
warn
sumo-logic-basic-auth
Sumo Logic uses Basic authentication (accessId:accessKey)
$.components.securitySchemes
warn
sumo-logic-operation-tags-required
All Sumo Logic operations must be tagged
$.paths[*][get,post,put,patch,delete]
info
sumo-logic-error-response-code
Sumo Logic error responses should include errorCode
$.components.schemas[?(@.properties.errorCode)]
warn
sumo-logic-get-response-schema
Sumo Logic GET operations should have a 200 response schema
$.paths[*].get.responses['200']
info
sumo-logic-pagination-limit
Sumo Logic uses 'limit' for pagination page size
$.paths[*][*].parameters[?(@.name == 'pageSize' || @.name == 'count')]

Spectral Ruleset

Raw ↑
extends: [[spectral:oas, recommended]]

rules:
  # Sumo Logic uses versioned paths /v1/ and /v2/
  sumo-logic-versioned-paths:
    description: Sumo Logic API paths must be versioned with /v1/ or /v2/
    message: "{{description}} - path '{{property}}' must start with /v1/ or /v2/"
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^/v[12]/"

  # All operations must have summaries
  sumo-logic-operation-summary-required:
    description: All Sumo Logic operations must have a summary
    message: "{{description}} - operation is missing a summary"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  # All operations must have an operationId
  sumo-logic-operation-id-required:
    description: All Sumo Logic operations must have an operationId
    message: "{{description}} - operation is missing an operationId"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  # Sumo Logic uses camelCase operationIds
  sumo-logic-operation-id-camel-case:
    description: Sumo Logic operationIds should use camelCase
    message: "{{description}} - '{{value}}' should use camelCase"
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  # Basic authentication is required
  sumo-logic-basic-auth:
    description: Sumo Logic uses Basic authentication (accessId:accessKey)
    message: "{{description}} - security scheme should reference basicAuth"
    severity: warn
    given: "$.components.securitySchemes"
    then:
      field: basicAuth
      function: truthy

  # All operations must have tags
  sumo-logic-operation-tags-required:
    description: All Sumo Logic operations must be tagged
    message: "{{description}} - operation is missing tags"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  # Response error models should have errorCode
  sumo-logic-error-response-code:
    description: Sumo Logic error responses should include errorCode
    message: "{{description}} - error response schema should include errorCode field"
    severity: info
    given: "$.components.schemas[?(@.properties.errorCode)]"
    then:
      field: properties.errorCode
      function: truthy

  # 200 responses for GET should have schema
  sumo-logic-get-response-schema:
    description: Sumo Logic GET operations should have a 200 response schema
    message: "{{description}} - GET operation should return a schema"
    severity: warn
    given: "$.paths[*].get.responses['200']"
    then:
      field: content
      function: truthy

  # Pagination parameters should use standard names
  sumo-logic-pagination-limit:
    description: Sumo Logic uses 'limit' for pagination page size
    message: "{{description}} - use 'limit' for pagination (not 'pageSize' or 'count')"
    severity: info
    given: "$.paths[*][*].parameters[?(@.name == 'pageSize' || @.name == 'count')]"
    then:
      field: name
      function: pattern
      functionOptions:
        notMatch: "pageSize|count"