Towers Watson · API Governance Rules

Towers Watson API Rules

Spectral linting rules defining API design standards and conventions for Towers Watson.

8 Rules error 4 warn 4
View Rules File View on GitHub

Rule Categories

wtw

Rules

warn
wtw-operation-id-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
wtw-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
warn
wtw-paths-kebab-case
API paths must use kebab-case
$.paths[*]~
error
wtw-must-have-tags
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
error
wtw-must-have-200-or-201
All operations must define a success response
$.paths[*][get,post,put,patch,delete].responses
error
wtw-employee-data-protection
Employee data endpoints must use authentication
$.paths[/employees*][get,post,put,patch,delete]
warn
wtw-pagination-required
List operations should support pagination
$.paths[*][get][?(@.operationId =~ /^list/)]
error
wtw-responses-must-have-description
All responses must have a description
$.paths[*][*].responses[*]

Spectral Ruleset

Raw ↑
rules:
  wtw-operation-id-camel-case:
    description: Operation IDs must use camelCase
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  wtw-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 ]*$"

  wtw-paths-kebab-case:
    description: API paths must use kebab-case
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9-]+|/\\{[a-zA-Z0-9]+\\})*$"

  wtw-must-have-tags:
    description: All operations must have at least one tag
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  wtw-must-have-200-or-201:
    description: All operations must define a success response
    severity: error
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ["200"]
            - required: ["201"]

  wtw-employee-data-protection:
    description: Employee data endpoints must use authentication
    severity: error
    given: "$.paths[/employees*][get,post,put,patch,delete]"
    then:
      field: security
      function: truthy

  wtw-pagination-required:
    description: List operations should support pagination
    severity: warn
    given: "$.paths[*][get][?(@.operationId =~ /^list/)]"
    then:
      field: parameters
      function: truthy

  wtw-responses-must-have-description:
    description: All responses must have a description
    severity: error
    given: "$.paths[*][*].responses[*]"
    then:
      field: description
      function: truthy