Airwallex · API Governance Rules

Airwallex API Rules

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

29 Rules error 11 warn 14 info 4
View Rules File View on GitHub

Rule Categories

airwallex

Rules

error
airwallex-payment-intent-required-fields
Payment intent must include id, amount, currency, and status.
$.components.schemas.PaymentIntent.required
error
airwallex-transfer-required-fields
Transfer object must include id, source_amount, source_currency, and status.
$.components.schemas.Transfer.required
error
airwallex-operation-summary-exists
Every API operation must have a non-empty summary.
$.paths[*][get,post,put,patch,delete]
warn
airwallex-operation-summary-title-case
Operation summaries must be in Title Case.
$.paths[*][get,post,put,patch,delete].summary
warn
airwallex-operation-description-exists
Every API operation should have a description.
$.paths[*][get,post,put,patch,delete]
error
airwallex-operation-tags-exist
Every operation must be tagged for grouping and documentation.
$.paths[*][get,post,put,patch,delete]
error
airwallex-operation-id-exists
Every operation must have a unique operationId.
$.paths[*][get,post,put,patch,delete]
warn
airwallex-operation-id-camel-case
operationId must be in camelCase format.
$.paths[*][get,post,put,patch,delete].operationId
error
airwallex-response-200-exists
Every GET operation must define a 200 success response.
$.paths[*].get
warn
airwallex-response-400-documented
Operations accepting request bodies should document 400 errors.
$.paths[*][post,put]
warn
airwallex-currency-iso4217-format
Currency fields must be ISO 4217 three-letter uppercase codes.
$.components.schemas[*].properties[*currency*]
warn
airwallex-amount-type-number
Amount fields must be typed as number.
$.components.schemas[*].properties[*amount*]
warn
airwallex-status-enum-defined
Status fields must use an enum of allowed values.
$.components.schemas[*].properties.status
warn
airwallex-schema-description-exists
All schema components must include a description.
$.components.schemas[*]
info
airwallex-property-description-exists
All schema properties should include descriptions.
$.components.schemas[*].properties[*]
warn
airwallex-datetime-format
Timestamp fields must use date-time format.
$.components.schemas[*].properties[*_at]
info
airwallex-microcks-operation-extension
All operations should include x-microcks-operation for mock support.
$.paths[*][get,post,put,patch,delete]
error
airwallex-security-defined
API must define security schemes for authentication.
$
warn
airwallex-bearer-auth-scheme
Airwallex APIs must use Bearer token authentication.
$.components.securitySchemes[*]
warn
airwallex-path-lowercase
API paths must be lowercase and use hyphens for word separation.
$.paths[*]~
warn
airwallex-no-trailing-slash
API paths must not end with a trailing slash.
$.paths[*]~
error
airwallex-info-title-exists
API info block must include a title.
$.info
error
airwallex-info-version-exists
API info block must include a version.
$.info
warn
airwallex-info-description-exists
API info block should include a description.
$.info
info
airwallex-contact-info-exists
API info should include contact information.
$.info
error
airwallex-servers-defined
API must define at least one server URL.
$
error
airwallex-server-https
All server URLs must use HTTPS.
$.servers[*].url
info
airwallex-pagination-limit-param
List endpoints should support a limit query parameter.
$.paths[*].get.parameters[*][?(@.in == 'query' && @.name == 'limit')]
warn
airwallex-request-body-content-type
Request bodies must specify application/json content type.
$.paths[*][post,put,patch].requestBody.content

Spectral Ruleset

airwallex-spectral-rules.yml Raw ↑
rules:
  airwallex-payment-intent-required-fields:
    description: Payment intent must include id, amount, currency, and status.
    message: "Payment intent object is missing required field: {{property}}"
    severity: error
    given: "$.components.schemas.PaymentIntent.required"
    then:
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            type: string
            enum: [id, amount, currency, status]

  airwallex-transfer-required-fields:
    description: Transfer object must include id, source_amount, source_currency, and status.
    message: "Transfer object is missing required field: {{property}}"
    severity: error
    given: "$.components.schemas.Transfer.required"
    then:
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            type: string
            enum: [id, source_amount, source_currency, status]

  airwallex-operation-summary-exists:
    description: Every API operation must have a non-empty summary.
    message: "Operation is missing a summary: {{path}}"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  airwallex-operation-summary-title-case:
    description: Operation summaries must be in Title Case.
    message: "Operation summary should be in Title Case: {{value}}"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]*([ ][A-Z][a-zA-Z0-9]*)*$"

  airwallex-operation-description-exists:
    description: Every API operation should have a description.
    message: "Operation is missing a description: {{path}}"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: description
      function: truthy

  airwallex-operation-tags-exist:
    description: Every operation must be tagged for grouping and documentation.
    message: "Operation must have at least one tag: {{path}}"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: truthy

  airwallex-operation-id-exists:
    description: Every operation must have a unique operationId.
    message: "Operation is missing an operationId: {{path}}"
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  airwallex-operation-id-camel-case:
    description: operationId must be in camelCase format.
    message: "operationId should be camelCase: {{value}}"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  airwallex-response-200-exists:
    description: Every GET operation must define a 200 success response.
    message: "GET operation must define a 200 response: {{path}}"
    severity: error
    given: "$.paths[*].get"
    then:
      field: responses.200
      function: truthy

  airwallex-response-400-documented:
    description: Operations accepting request bodies should document 400 errors.
    message: "POST/PUT operation should document 400 error response: {{path}}"
    severity: warn
    given: "$.paths[*][post,put]"
    then:
      field: responses.400
      function: truthy

  airwallex-currency-iso4217-format:
    description: Currency fields must be ISO 4217 three-letter uppercase codes.
    message: "Currency field should match ISO 4217 format (e.g., USD, GBP): {{path}}"
    severity: warn
    given: "$.components.schemas[*].properties[*currency*]"
    then:
      field: pattern
      function: truthy

  airwallex-amount-type-number:
    description: Amount fields must be typed as number.
    message: "Amount field should be of type 'number': {{path}}"
    severity: warn
    given: "$.components.schemas[*].properties[*amount*]"
    then:
      field: type
      function: enumeration
      functionOptions:
        values: [number]

  airwallex-status-enum-defined:
    description: Status fields must use an enum of allowed values.
    message: "Status field should define allowed enum values: {{path}}"
    severity: warn
    given: "$.components.schemas[*].properties.status"
    then:
      field: enum
      function: truthy

  airwallex-schema-description-exists:
    description: All schema components must include a description.
    message: "Schema is missing a description: {{path}}"
    severity: warn
    given: "$.components.schemas[*]"
    then:
      field: description
      function: truthy

  airwallex-property-description-exists:
    description: All schema properties should include descriptions.
    message: "Property is missing a description: {{path}}"
    severity: info
    given: "$.components.schemas[*].properties[*]"
    then:
      field: description
      function: truthy

  airwallex-datetime-format:
    description: Timestamp fields must use date-time format.
    message: "Timestamp field should specify format: date-time: {{path}}"
    severity: warn
    given: "$.components.schemas[*].properties[*_at]"
    then:
      field: format
      function: enumeration
      functionOptions:
        values: [date-time]

  airwallex-microcks-operation-extension:
    description: All operations should include x-microcks-operation for mock support.
    message: "Operation is missing x-microcks-operation extension: {{path}}"
    severity: info
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: x-microcks-operation
      function: truthy

  airwallex-security-defined:
    description: API must define security schemes for authentication.
    message: "API is missing security scheme definitions."
    severity: error
    given: "$"
    then:
      field: components.securitySchemes
      function: truthy

  airwallex-bearer-auth-scheme:
    description: Airwallex APIs must use Bearer token authentication.
    message: "API should define a Bearer authentication scheme."
    severity: warn
    given: "$.components.securitySchemes[*]"
    then:
      field: scheme
      function: enumeration
      functionOptions:
        values: [bearer]

  airwallex-path-lowercase:
    description: API paths must be lowercase and use hyphens for word separation.
    message: "Path should be lowercase with hyphens: {{path}}"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z0-9{}_-]+)+$"

  airwallex-no-trailing-slash:
    description: API paths must not end with a trailing slash.
    message: "Path must not end with a trailing slash: {{path}}"
    severity: warn
    given: "$.paths[*]~"
    then:
      function: pattern
      functionOptions:
        notMatch: "/$"

  airwallex-info-title-exists:
    description: API info block must include a title.
    message: "API info is missing a title."
    severity: error
    given: "$.info"
    then:
      field: title
      function: truthy

  airwallex-info-version-exists:
    description: API info block must include a version.
    message: "API info is missing a version."
    severity: error
    given: "$.info"
    then:
      field: version
      function: truthy

  airwallex-info-description-exists:
    description: API info block should include a description.
    message: "API info is missing a description."
    severity: warn
    given: "$.info"
    then:
      field: description
      function: truthy

  airwallex-contact-info-exists:
    description: API info should include contact information.
    message: "API info is missing contact details."
    severity: info
    given: "$.info"
    then:
      field: contact
      function: truthy

  airwallex-servers-defined:
    description: API must define at least one server URL.
    message: "API is missing server definitions."
    severity: error
    given: "$"
    then:
      field: servers
      function: truthy

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

  airwallex-pagination-limit-param:
    description: List endpoints should support a limit query parameter.
    message: "List endpoint should accept a limit query parameter: {{path}}"
    severity: info
    given: "$.paths[*].get.parameters[*][?(@.in == 'query' && @.name == 'limit')]"
    then:
      field: name
      function: truthy

  airwallex-request-body-content-type:
    description: Request bodies must specify application/json content type.
    message: "Request body should specify application/json content type: {{path}}"
    severity: warn
    given: "$.paths[*][post,put,patch].requestBody.content"
    then:
      field: application/json
      function: truthy