western-union · API Governance Rules

western-union API Rules

Spectral linting rules defining API design standards and conventions for western-union.

8 Rules error 1 warn 6 info 1
View Rules File View on GitHub

Rule Categories

wu

Rules

warn
wu-operation-id-camel-case
Operation IDs must use camelCase.
$.paths.*.*.operationId
warn
wu-client-id-in-path
All customer-specific paths must include the {clientId} path parameter to scope operations to a specific WU partner account.
$.paths[?(@.startsWith('/customers'))][*]~
warn
wu-response-200-content-type
Successful responses must return application/json.
$.paths.*.*.responses.200.content
warn
wu-tags-defined
Each operation must include at least one tag.
$.paths.*.*.tags
warn
wu-description-required
Each operation must have a description.
$.paths.*.*.description
error
wu-no-trailing-slash
API paths must not have trailing slashes.
$.paths[*]~
info
wu-amount-in-minor-units
Payment amount fields should be described as minor units (e.g., cents) in their schema description.
$.components.schemas.PaymentRequest.properties.amount.description
warn
wu-mtls-security
All operations must use mutualTLS authentication.
$.paths.*.*.security

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  wu-operation-id-camel-case:
    description: Operation IDs must use camelCase.
    message: "Operation ID '{{value}}' should use camelCase."
    severity: warn
    given: "$.paths.*.*.operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  wu-client-id-in-path:
    description: >-
      All customer-specific paths must include the {clientId} path parameter
      to scope operations to a specific WU partner account.
    message: "Path '{{path}}' should include '{clientId}' for scoping to partner account."
    severity: warn
    given: "$.paths[?(@.startsWith('/customers'))][*]~"
    then:
      function: pattern
      functionOptions:
        match: "/\\{clientId\\}/"

  wu-response-200-content-type:
    description: Successful responses must return application/json.
    message: "Response at '{{path}}' should define application/json content."
    severity: warn
    given: "$.paths.*.*.responses.200.content"
    then:
      function: truthy

  wu-tags-defined:
    description: Each operation must include at least one tag.
    message: "Operation at '{{path}}' must include at least one tag."
    severity: warn
    given: "$.paths.*.*.tags"
    then:
      function: truthy

  wu-description-required:
    description: Each operation must have a description.
    message: "Operation at '{{path}}' is missing a description."
    severity: warn
    given: "$.paths.*.*.description"
    then:
      function: truthy

  wu-no-trailing-slash:
    description: API paths must not have trailing slashes.
    message: "Path '{{value}}' must not end with a trailing slash."
    severity: error
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        notMatch: "/$"

  wu-amount-in-minor-units:
    description: >-
      Payment amount fields should be described as minor units (e.g., cents)
      in their schema description.
    message: "Amount field should describe minor unit format."
    severity: info
    given: "$.components.schemas.PaymentRequest.properties.amount.description"
    then:
      function: truthy

  wu-mtls-security:
    description: All operations must use mutualTLS authentication.
    message: "Operation at '{{path}}' must declare mtlsAuth security."
    severity: warn
    given: "$.paths.*.*.security"
    then:
      function: truthy