SAP BRIM (Billing and Revenue Innovation Management) API Rules

Spectral linting rules defining API design standards and conventions for SAP BRIM (Billing and Revenue Innovation Management).

10 Rules warn 8 info 2
View Rules File View on GitHub

Rule Categories

sap

Rules

warn
sap-brim-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
warn
sap-brim-operation-id-camel-case
OperationIds must use camelCase
$.paths[*][*].operationId
warn
sap-brim-tags-title-case
All tags must use Title Case
$.tags[*].name
warn
sap-brim-path-kebab-case
API paths should use kebab-case for segments
$.paths
warn
sap-brim-oauth2-or-apikey-required
BRIM APIs require OAuth 2.0 or API Key authentication
$.components.securitySchemes
warn
sap-brim-error-responses
Operations should define error responses (400, 401, 500)
$.paths[*][*].responses
info
sap-brim-subscription-status-enum
Subscription status fields should use defined enum values
$.components.schemas.Subscription.properties.status.enum
warn
sap-brim-request-body-required
POST and PUT operations must define request bodies
$.paths[*].post.requestBody
info
sap-brim-pagination-parameters
List operations should support offset/limit pagination
$.paths[*].get.parameters
warn
sap-brim-servers-defined
APIs must define production and sandbox server URLs
$.servers

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  sap-brim-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-brim-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-brim-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-brim-path-kebab-case:
    description: API paths should use kebab-case for segments
    message: Path should use kebab-case for all segments
    given: "$.paths"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^(/[a-z][a-z0-9-]*(/[a-z][a-z0-9-]*|/\\{[a-zA-Z][a-zA-Z0-9]*\\})*)*$"

  sap-brim-oauth2-or-apikey-required:
    description: BRIM APIs require OAuth 2.0 or API Key authentication
    message: APIs should define OAuth2 or ApiKey security schemes
    given: "$.components.securitySchemes"
    severity: warn
    then:
      function: truthy

  sap-brim-error-responses:
    description: Operations should define error responses (400, 401, 500)
    message: Operation should define standard error responses
    given: "$.paths[*][*].responses"
    severity: warn
    then:
      function: truthy

  sap-brim-subscription-status-enum:
    description: Subscription status fields should use defined enum values
    message: Subscription status should be ACTIVE, SUSPENDED, CANCELLED, EXPIRED, PENDING, or TRIAL
    given: "$.components.schemas.Subscription.properties.status.enum"
    severity: info
    then:
      function: truthy

  sap-brim-request-body-required:
    description: POST and PUT operations must define request bodies
    message: POST/PUT operations should define a requestBody
    given: "$.paths[*].post.requestBody"
    severity: warn
    then:
      function: truthy

  sap-brim-pagination-parameters:
    description: List operations should support offset/limit pagination
    message: Collection endpoints should define offset and limit pagination parameters
    given: "$.paths[*].get.parameters"
    severity: info
    then:
      function: truthy

  sap-brim-servers-defined:
    description: APIs must define production and sandbox server URLs
    message: API should define both production and sandbox server environments
    given: "$.servers"
    severity: warn
    then:
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 1