Commvault · API Governance Rules

Commvault API Rules

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

10 Rules error 4 warn 5 info 1
View Rules File View on GitHub

Rule Categories

commvault

Rules

error
commvault-info-contact
API contact information must be present.
$.info
warn
commvault-info-terms
API terms of service must be declared.
$.info
error
commvault-server-https
All server URLs must use HTTPS.
$.servers[*].url
warn
commvault-server-webconsole
Server URLs should resolve to a Commvault Web Server endpoint.
$.servers[*].url
error
commvault-authtoken-security
An Authtoken QSDK security scheme must be defined.
$.components.securitySchemes
warn
commvault-operation-tags
Every operation must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
commvault-operation-summary
Every operation must include a short summary.
$.paths[*][get,post,put,patch,delete]
error
commvault-operation-id
Every operation must declare a unique operationId.
$.paths[*][get,post,put,patch,delete]
warn
commvault-error-responses
Mutating operations should declare 4xx error responses.
$.paths[*][post,put,patch,delete].responses
info
commvault-job-resources
Backup, restore, and reporting paths should expose job resources.
$.paths

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

# Spectral linting rules tuned for Commvault REST APIs.
# Enforces conventions described at
# https://documentation.commvault.com/v11/essential/rest_api_overview.html
# Authentication is via QSDK token sent in the Authtoken header,
# JSON request and response bodies, and resource-oriented paths.
rules:
  commvault-info-contact:
    description: API contact information must be present.
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

  commvault-info-terms:
    description: API terms of service must be declared.
    severity: warn
    given: "$.info"
    then:
      field: termsOfService
      function: truthy

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

  commvault-server-webconsole:
    description: Server URLs should resolve to a Commvault Web Server endpoint.
    severity: warn
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "/(webconsole|commandcenter)/api"

  commvault-authtoken-security:
    description: An Authtoken QSDK security scheme must be defined.
    severity: error
    given: "$.components.securitySchemes"
    then:
      function: truthy

  commvault-operation-tags:
    description: Every operation must declare at least one tag.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 1

  commvault-operation-summary:
    description: Every operation must include a short summary.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  commvault-operation-id:
    description: Every operation must declare a unique operationId.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  commvault-error-responses:
    description: Mutating operations should declare 4xx error responses.
    severity: warn
    given: "$.paths[*][post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ["400"]
            - required: ["401"]
            - required: ["403"]
            - required: ["404"]

  commvault-job-resources:
    description: Backup, restore, and reporting paths should expose job resources.
    severity: info
    given: "$.paths"
    then:
      function: truthy