Remitian · API Governance Rules

Remitian API Rules

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

11 Rules error 6 warn 4 info 1
View Rules File View on GitHub

Rule Categories

remitian

Rules

error
remitian-operation-ids-camel-case
Operation IDs must use camelCase
$.paths[*][*].operationId
warn
remitian-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
error
remitian-tags-required
Every operation must have at least one tag
$.paths[*][*]
error
remitian-bearer-auth
API must define Bearer JWT authentication
$.components.securitySchemes
error
remitian-v1-path-prefix
All paths must begin with /v1/
$.paths
warn
remitian-path-kebab-case
Path segments must use kebab-case
$.paths
warn
remitian-payment-status-enum
Payment status fields should use the canonical enum values
$.components.schemas.*.properties.status.enum
error
remitian-401-on-protected-operations
All protected operations must define a 401 response
$.paths[*][*].responses
error
remitian-post-request-body-required
POST operations must define a requestBody
$.paths[*].post
warn
remitian-pagination-on-list-endpoints
List endpoints should support pagination parameters
$.paths[?(!/@id)].get
info
remitian-component-refs-used
Schemas should use $ref to components where available
$.paths[*][*].responses[*].content.application/json

Spectral Ruleset

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

  remitian-summary-title-case:
    description: Operation summaries must use Title Case
    message: "Summary '{{value}}' must use Title Case"
    severity: warn
    given: "$.paths[*][*].summary"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 -]*$"

  remitian-tags-required:
    description: Every operation must have at least one tag
    message: Operation must include at least one tag
    severity: error
    given: "$.paths[*][*]"
    then:
      field: tags
      function: truthy

  remitian-bearer-auth:
    description: API must define Bearer JWT authentication
    message: API must define bearerAuth security scheme
    severity: error
    given: "$.components.securitySchemes"
    then:
      field: bearerAuth
      function: truthy

  remitian-v1-path-prefix:
    description: All paths must begin with /v1/
    message: "Path '{{property}}' must start with /v1/"
    severity: error
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^/v1/"

  remitian-path-kebab-case:
    description: Path segments must use kebab-case
    message: "Path '{{property}}' must use kebab-case segments"
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^(/v1/[a-z0-9{}-]+)+(/[a-z0-9{}-]+)*$"

  remitian-payment-status-enum:
    description: Payment status fields should use the canonical enum values
    message: Payment status must be one of the canonical lifecycle values
    severity: warn
    given: "$.components.schemas.*.properties.status.enum"
    then:
      function: schema
      functionOptions:
        schema:
          type: array

  remitian-401-on-protected-operations:
    description: All protected operations must define a 401 response
    message: Operation must define a 401 Unauthorized response
    severity: error
    given: "$.paths[*][*].responses"
    then:
      field: "401"
      function: truthy

  remitian-post-request-body-required:
    description: POST operations must define a requestBody
    message: POST operations must include a request body schema
    severity: error
    given: "$.paths[*].post"
    then:
      field: requestBody
      function: truthy

  remitian-pagination-on-list-endpoints:
    description: List endpoints should support pagination parameters
    message: Collection GET endpoints should include limit and offset parameters
    severity: warn
    given: "$.paths[?(!/@id)].get"
    then:
      function: schema
      functionOptions:
        schema:
          type: object

  remitian-component-refs-used:
    description: Schemas should use $ref to components where available
    message: Prefer $ref to shared components over inline schema definitions
    severity: info
    given: "$.paths[*][*].responses[*].content.application/json"
    then:
      field: schema
      function: truthy