Rollbar · API Governance Rules

Rollbar API Rules

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

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

Rule Categories

rollbar

Rules

error
rollbar-has-access-token-security
All Rollbar API operations must reference the accessToken security scheme
$.paths[*][get,post,put,patch,delete]
warn
rollbar-operation-id-camel-case
Rollbar operationIds use camelCase naming
$.paths[*][get,post,put,patch,delete].operationId
error
rollbar-operation-summary-required
All Rollbar API operations must have a summary
$.paths[*][get,post,put,patch,delete]
warn
rollbar-summary-title-case
Operation summaries must use Title Case
$.paths[*][get,post,put,patch,delete].summary
warn
rollbar-consistent-path-structure
Rollbar path segments must use lowercase kebab-case
$.paths[*]~
warn
rollbar-tags-defined
All operations should reference defined tags
$.paths[*][get,post,put,patch,delete]
warn
rollbar-success-response-schema
Successful responses should include a schema
$.paths[*][get,post,put,patch,delete].responses[?(@property >= '200' && @property < '300')]
info
rollbar-error-responses-defined
Operations should document standard error responses
$.paths[*][get,post,put,patch,delete]
error
rollbar-request-body-content-type
Request bodies must specify application/json content type
$.paths[*][post,put,patch].requestBody.content
warn
rollbar-info-complete
API info section must include contact and terms
$.info

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:

  # Rollbar API uses X-Rollbar-Access-Token header authentication
  rollbar-has-access-token-security:
    description: All Rollbar API operations must reference the accessToken security scheme
    message: "Operation must include the accessToken security scheme (X-Rollbar-Access-Token header)"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      - function: schema
        functionOptions:
          schema:
            type: object
            anyOf:
              - required: [security]

  # Operation IDs must be camelCase
  rollbar-operation-id-camel-case:
    description: Rollbar operationIds use camelCase naming
    message: "OperationId '{{value}}' should be in camelCase format"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  # All operations must have summaries
  rollbar-operation-summary-required:
    description: All Rollbar API operations must have a summary
    message: "Operation is missing a summary"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  # Summaries must use Title Case
  rollbar-summary-title-case:
    description: Operation summaries must use Title Case
    message: "Summary '{{value}}' should use Title Case"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z]"

  # Rollbar paths use trailing slashes on collection endpoints
  rollbar-consistent-path-structure:
    description: Rollbar path segments must use lowercase kebab-case
    message: "Path segment should be lowercase"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9_/{}:.-]+)$"

  # Tags must be defined
  rollbar-tags-defined:
    description: All operations should reference defined tags
    message: "Operation should reference at least one tag"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  # Response schemas should be defined
  rollbar-success-response-schema:
    description: Successful responses should include a schema
    message: "2xx response should include a content schema"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses[?(@property >= '200' && @property < '300')]"
    then:
      field: content
      function: truthy

  # Error responses should use standard codes
  rollbar-error-responses-defined:
    description: Operations should document standard error responses
    message: "Consider documenting 401 and 429 error responses for Rollbar API compliance"
    severity: info
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: responses
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ["401"]
            - required: ["403"]
            - required: ["429"]

  # Request bodies must have content type
  rollbar-request-body-content-type:
    description: Request bodies must specify application/json content type
    message: "Request body should use application/json content type"
    severity: error
    given: "$.paths[*][post,put,patch].requestBody.content"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required: ["application/json"]

  # Info section must be complete
  rollbar-info-complete:
    description: API info section must include contact and terms
    message: "API info should include contact URL and termsOfService"
    severity: warn
    given: "$.info"
    then:
      - field: contact
        function: truthy
      - field: termsOfService
        function: truthy