Wallarm · API Governance Rules

Wallarm API Rules

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

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

Rule Categories

wallarm

Rules

error
wallarm-operation-ids-required
All operations must have an operationId
$.paths[*][*]
warn
wallarm-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
error
wallarm-operation-tags-required
All operations must have at least one tag
$.paths[*][*]
error
wallarm-security-scheme-apikey
Operations must use the Wallarm API token security scheme
$.components.securitySchemes
warn
wallarm-responses-defined
Operations must define at least a 200 and 401 response
$.paths[*][*].responses
error
wallarm-request-body-content-type
POST/PUT request bodies must specify application/json content type
$.paths[*][post,put].requestBody.content
warn
wallarm-v4-endpoints-paginated
v4 list endpoints should support pagination parameters
$.paths['/v4/ip_rules'].get.parameters
warn
wallarm-info-contact
Info object must have contact information
$.info
error
wallarm-info-description
Info object must have a description
$.info
warn
wallarm-servers-defined
Both US and EU cloud servers must be defined
$.servers
warn
wallarm-schemas-defined
Components must define reusable schemas
$.components
warn
wallarm-response-schema-reference
Successful responses should reference a schema
$.paths[*][*].responses['200'].content['application/json']

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  wallarm-operation-ids-required:
    description: All operations must have an operationId
    severity: error
    given: "$.paths[*][*]"
    then:
      field: operationId
      function: truthy

  wallarm-operation-summary-title-case:
    description: Operation summaries must use Title Case
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*(\\s[A-Z][a-zA-Z0-9]*)*$"

  wallarm-operation-tags-required:
    description: All operations must have at least one tag
    severity: error
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  wallarm-security-scheme-apikey:
    description: Operations must use the Wallarm API token security scheme
    severity: error
    given: "$.components.securitySchemes"
    then:
      field: ApiTokenAuth
      function: truthy

  wallarm-responses-defined:
    description: Operations must define at least a 200 and 401 response
    severity: warn
    given: "$.paths[*][*].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          required:
            - "200"

  wallarm-request-body-content-type:
    description: POST/PUT request bodies must specify application/json content type
    severity: error
    given: "$.paths[*][post,put].requestBody.content"
    then:
      field: application/json
      function: truthy

  wallarm-v4-endpoints-paginated:
    description: v4 list endpoints should support pagination parameters
    severity: warn
    given: "$.paths['/v4/ip_rules'].get.parameters"
    then:
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            type: object
            properties:
              name:
                enum:
                  - limit
                  - offset

  wallarm-info-contact:
    description: Info object must have contact information
    severity: warn
    given: "$.info"
    then:
      field: contact
      function: truthy

  wallarm-info-description:
    description: Info object must have a description
    severity: error
    given: "$.info"
    then:
      field: description
      function: truthy

  wallarm-servers-defined:
    description: Both US and EU cloud servers must be defined
    severity: warn
    given: "$.servers"
    then:
      function: length
      functionOptions:
        min: 2

  wallarm-schemas-defined:
    description: Components must define reusable schemas
    severity: warn
    given: "$.components"
    then:
      field: schemas
      function: truthy

  wallarm-response-schema-reference:
    description: Successful responses should reference a schema
    severity: warn
    given: "$.paths[*][*].responses['200'].content['application/json']"
    then:
      field: schema
      function: truthy