Total System Services · API Governance Rules

Total System Services API Rules

Spectral linting rules defining API design standards and conventions for Total System Services.

10 Rules error 4 warn 6
View Rules File View on GitHub

Rule Categories

tsys

Rules

warn
tsys-operation-id-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
tsys-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
warn
tsys-paths-kebab-case
API paths must use kebab-case
$.paths[*]~
error
tsys-must-have-tags
All operations must have at least one tag
$.paths[*][get,post,put,patch,delete]
error
tsys-must-have-200-or-201
All operations must define a success response
$.paths[*][get,post,put,patch,delete].responses
error
tsys-payment-security
Payment endpoints must use security schemes
$.paths[/transactions/authorize,/transactions/sale][post]
warn
tsys-financial-amount-format
Financial amount fields must use float format
$.components.schemas[*].properties.amount
error
tsys-pci-card-data
Card number fields must be described as tokenized or masked
$.components.schemas[*].properties.cardNumber
warn
tsys-pagination-required
List operations should support pagination
$.paths[*][get][?(@.operationId =~ /^list/)]
warn
tsys-error-response-required
All operations must define error responses
$.paths[*][post,put,delete].responses

Spectral Ruleset

Raw ↑
rules:
  tsys-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]*$"

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

  tsys-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]+\\})*$"

  tsys-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

  tsys-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"]

  tsys-payment-security:
    description: Payment endpoints must use security schemes
    severity: error
    given: "$.paths[/transactions/authorize,/transactions/sale][post]"
    then:
      field: security
      function: truthy

  tsys-financial-amount-format:
    description: Financial amount fields must use float format
    severity: warn
    given: "$.components.schemas[*].properties.amount"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            format:
              enum: ["float", "double"]

  tsys-pci-card-data:
    description: Card number fields must be described as tokenized or masked
    severity: error
    given: "$.components.schemas[*].properties.cardNumber"
    then:
      field: description
      function: truthy

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

  tsys-error-response-required:
    description: All operations must define error responses
    severity: warn
    given: "$.paths[*][post,put,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          anyOf:
            - required: ["400"]
            - required: ["401"]
            - required: ["404"]