Waste Management · API Governance Rules

Waste Management API Rules

Spectral linting rules defining API design standards and conventions for Waste Management.

8 Rules error 4 info 1
View Rules File View on GitHub

Rule Categories

wm

Rules

error
wm-required-request-tracking-header
All operations must accept a Request-Tracking-Id header parameter.
$.paths[*][get,post,put,patch,delete]
error
wm-required-client-id-header
All operations must accept a ClientId header parameter.
$.paths[*][get,post,put,patch,delete]
error
wm-bearer-auth-required
All WM API operations must declare bearerAuth security.
$.paths[*][get,post,put,patch,delete]
warning
wm-customer-id-path-param-name
Path parameters for customer identifiers must be named customerId.
$.paths['/customers/{customerId}*'][*].parameters[?(@.in == 'path')]
warning
wm-401-response-required
All authenticated operations must document a 401 Unauthorized response.
$.paths[*][get,post,put,patch,delete].responses
warning
wm-operation-id-camel-case
Operation IDs must use camelCase naming convention.
$.paths[*][*].operationId
info
wm-summary-title-case
Operation summaries must use Title Case.
$.paths[*][*].summary
error
wm-https-servers
All server URLs must use HTTPS.
$.servers[*].url

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  # WM API requires Request-Tracking-Id and ClientId headers on all operations
  wm-required-request-tracking-header:
    description: All operations must accept a Request-Tracking-Id header parameter.
    message: "Operation '{{title}}' is missing the required Request-Tracking-Id header parameter."
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: parameters
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            type: object
            properties:
              name:
                const: Request-Tracking-Id
              in:
                const: header

  wm-required-client-id-header:
    description: All operations must accept a ClientId header parameter.
    message: "Operation '{{title}}' is missing the required ClientId header parameter."
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: parameters
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            type: object
            properties:
              name:
                const: ClientId
              in:
                const: header

  # WM API uses JWT bearer auth — all operations must declare security
  wm-bearer-auth-required:
    description: All WM API operations must declare bearerAuth security.
    message: "Operation '{{title}}' must declare bearerAuth security requirement."
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: security
      function: defined

  # Customer ID path parameter must be named customerId
  wm-customer-id-path-param-name:
    description: Path parameters for customer identifiers must be named customerId.
    message: "Customer path parameters should be named 'customerId'."
    severity: warning
    given: "$.paths['/customers/{customerId}*'][*].parameters[?(@.in == 'path')]"
    then:
      field: name
      function: enumeration
      functionOptions:
        values:
          - customerId
          - serviceId
          - invoiceId

  # All responses must include 401 Unauthorized
  wm-401-response-required:
    description: All authenticated operations must document a 401 Unauthorized response.
    message: "Operation '{{title}}' is missing a 401 Unauthorized response."
    severity: warning
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      field: "401"
      function: defined

  # Operation IDs must use camelCase
  wm-operation-id-camel-case:
    description: Operation IDs must use camelCase naming convention.
    message: "OperationId '{{value}}' must use camelCase."
    severity: warning
    given: "$.paths[*][*].operationId"
    then:
      function: casing
      functionOptions:
        type: camel

  # Summaries must use Title Case
  wm-summary-title-case:
    description: Operation summaries must use Title Case.
    message: "Summary '{{value}}' should use Title Case."
    severity: info
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*([ ][A-Z][a-zA-Z0-9]*)*$"

  # API servers must use HTTPS
  wm-https-servers:
    description: All server URLs must use HTTPS.
    message: "Server URL '{{value}}' must use HTTPS."
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"