SAP Commerce Cloud · API Governance Rules

SAP Commerce Cloud API Rules

Spectral linting rules defining API design standards and conventions for SAP Commerce Cloud.

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

Rule Categories

sap

Rules

warn
sap-commerce-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
warn
sap-commerce-operation-id-camel-case
OperationIds must use camelCase
$.paths[*][*].operationId
warn
sap-commerce-tags-title-case
All tags must use Title Case
$.tags[*].name
warn
sap-commerce-oauth2-required
Commerce Cloud APIs require OAuth 2.0 authentication
$.components.securitySchemes
warn
sap-commerce-response-200-schema
GET operations should define a response schema
$.paths[*].get.responses.200.content
info
sap-commerce-fields-parameter
Commerce Cloud APIs support a fields parameter for response shaping
$.paths[*].get.parameters
info
sap-commerce-pagination-parameters
Collection endpoints should support currentPage and pageSize
$.paths[*].get.parameters
warn
sap-commerce-servers-with-variables
Commerce Cloud server URLs must include tenant, region, and baseSiteId variables
$.servers[*].variables
info
sap-commerce-b2b-b2c-support
Commerce APIs should support both B2B and B2C scenarios
$.info.description
info
sap-commerce-occ-versioning
Commerce APIs should use OCC v2 versioning
$.servers[*].url

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  sap-commerce-operation-summary-title-case:
    description: Operation summaries must use Title Case
    message: Summary "{{value}}" should be in Title Case
    given: "$.paths[*][*].summary"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z]"

  sap-commerce-operation-id-camel-case:
    description: OperationIds must use camelCase
    message: OperationId "{{value}}" should use camelCase
    given: "$.paths[*][*].operationId"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  sap-commerce-tags-title-case:
    description: All tags must use Title Case
    message: Tag "{{value}}" should be in Title Case
    given: "$.tags[*].name"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z]"

  sap-commerce-oauth2-required:
    description: Commerce Cloud APIs require OAuth 2.0 authentication
    message: APIs should specify OAuth 2.0 security
    given: "$.components.securitySchemes"
    severity: warn
    then:
      function: truthy

  sap-commerce-response-200-schema:
    description: GET operations should define a response schema
    message: GET operations should return typed schemas
    given: "$.paths[*].get.responses.200.content"
    severity: warn
    then:
      function: truthy

  sap-commerce-fields-parameter:
    description: Commerce Cloud APIs support a fields parameter for response shaping
    message: List/Get operations should support the 'fields' query parameter
    given: "$.paths[*].get.parameters"
    severity: info
    then:
      function: truthy

  sap-commerce-pagination-parameters:
    description: Collection endpoints should support currentPage and pageSize
    message: Paginated list operations should define currentPage and pageSize parameters
    given: "$.paths[*].get.parameters"
    severity: info
    then:
      function: truthy

  sap-commerce-servers-with-variables:
    description: Commerce Cloud server URLs must include tenant, region, and baseSiteId variables
    message: Server URL should use variable substitution for tenant, region, and baseSiteId
    given: "$.servers[*].variables"
    severity: warn
    then:
      function: truthy

  sap-commerce-b2b-b2c-support:
    description: Commerce APIs should support both B2B and B2C scenarios
    message: API description should mention B2B and B2C commerce support
    given: "$.info.description"
    severity: info
    then:
      function: pattern
      functionOptions:
        match: "(B2B|B2C|commerce)"

  sap-commerce-occ-versioning:
    description: Commerce APIs should use OCC v2 versioning
    message: Commerce Web Services should reference OCC v2 in server URL
    given: "$.servers[*].url"
    severity: info
    then:
      function: pattern
      functionOptions:
        match: "/occ/v2"