Revert · API Governance Rules

Revert API Rules

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

10 Rules error 2 warn 6 info 2
View Rules File View on GitHub

Rule Categories

revert

Rules

warn
revert-operation-id-camel-case
All operationIds must use camelCase format consistent with Revert SDK generation
$.paths.*.*
warn
revert-tags-title-case
All tags must use Title Case
$.tags[*].name
error
revert-tenant-id-header-required
All endpoints except /connection must include x-revert-t-id header
$.paths[?([email protected](/^\/connection$/))].*
error
revert-api-token-auth
All endpoints must declare x-revert-api-token security
$.paths.*.*
warn
revert-response-status-field
All 200 responses should include a status field in the schema
$.paths.*.*.responses.200.content.application/json.schema.properties
warn
revert-pagination-cursor-consistency
List endpoints returning paginated results must include next and previous cursor fields
$.paths[?(@property.match(/^(?!.*\{id\}).*$/))].get.responses.200.content.application/json.schema.properties
info
revert-version-prefix
All API paths should follow the established /crm/, /ticket/, /chat/, /accounting/ namespace pattern
$.paths
warn
revert-no-trailing-slash
API paths must not end with a trailing slash
$.paths
warn
revert-kebab-case-paths
Path segments must use kebab-case
$.paths
info
revert-additional-fields-support
Request bodies for create/update operations should include an additional field for non-unified data
$.paths.*.post.requestBody.content.application/json.schema.properties

Spectral Ruleset

Raw ↑
rules:
  revert-operation-id-camel-case:
    description: All operationIds must use camelCase format consistent with Revert SDK generation
    severity: warn
    given: "$.paths.*.*"
    then:
      field: operationId
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  revert-tags-title-case:
    description: All tags must use Title Case
    severity: warn
    given: "$.tags[*].name"
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9 ]*$"

  revert-tenant-id-header-required:
    description: All endpoints except /connection must include x-revert-t-id header
    severity: error
    given: "$.paths[?([email protected](/^\\/connection$/))].*"
    then:
      field: parameters
      function: truthy

  revert-api-token-auth:
    description: All endpoints must declare x-revert-api-token security
    severity: error
    given: "$.paths.*.*"
    then:
      field: security
      function: defined

  revert-response-status-field:
    description: All 200 responses should include a status field in the schema
    severity: warn
    given: "$.paths.*.*.responses.200.content.application/json.schema.properties"
    then:
      field: status
      function: defined

  revert-pagination-cursor-consistency:
    description: List endpoints returning paginated results must include next and previous cursor fields
    severity: warn
    given: "$.paths[?(@property.match(/^(?!.*\\{id\\}).*$/))].get.responses.200.content.application/json.schema.properties"
    then:
      function: schema
      functionOptions:
        schema:
          properties:
            next:
              type: object
            previous:
              type: object

  revert-version-prefix:
    description: All API paths should follow the established /crm/, /ticket/, /chat/, /accounting/ namespace pattern
    severity: info
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^(\\/connection|\\/crm\\/|\\/ticket\\/|\\/chat\\/|\\/accounting\\/)"

  revert-no-trailing-slash:
    description: API paths must not end with a trailing slash
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        notMatch: "\\/$"

  revert-kebab-case-paths:
    description: Path segments must use kebab-case
    severity: warn
    given: "$.paths"
    then:
      function: pattern
      functionOptions:
        match: "^(\\/[a-z][a-z0-9-]*)(\\/{[^}]+})?(\\/[a-z][a-z0-9-]*)*(\\/\\{[^}]+\\})?$"

  revert-additional-fields-support:
    description: Request bodies for create/update operations should include an additional field for non-unified data
    severity: info
    given: "$.paths.*.post.requestBody.content.application/json.schema.properties"
    then:
      field: additional
      function: defined