Losant · API Governance Rules

Losant API Rules

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

5 Rules error 2 warn 3
View Rules File View on GitHub

Rule Categories

losant

Rules

error
losant-id-pattern
Losant resource IDs MUST match the 24-hex-char MongoDB ObjectId pattern.
$.paths.*..parameters[?(@.name && @.name =~ /Id$/)].schema
warn
losant-application-scope
Application-scoped paths MUST include {applicationId} path parameter.
$.paths[?(@property =~ /^\/applications\//)]
warn
losant-title-case-summary
OpenAPI operation summaries SHOULD use Title Case.
$.paths.*.*.summary
error
losant-bearer-auth-required
All Losant Platform operations MUST require BearerAuth.
$.paths.*.*.security[*]
warn
losant-error-schema
Error responses SHOULD reference the shared error schema.
$.paths.*.*.responses[?(@property =~ /^4/ || @property =~ /^5/)].content.application/json.schema

Spectral Ruleset

Raw ↑
extends:
- - spectral:oas
  - recommended
rules:
  losant-id-pattern:
    description: Losant resource IDs MUST match the 24-hex-char MongoDB ObjectId pattern.
    severity: error
    given: $.paths.*..parameters[?(@.name && @.name =~ /Id$/)].schema
    then:
      field: pattern
      function: pattern
      functionOptions:
        match: ^\^\[A-Fa-f\\d\]\{24\}\$$
  losant-application-scope:
    description: Application-scoped paths MUST include {applicationId} path parameter.
    severity: warn
    given: $.paths[?(@property =~ /^\/applications\//)]
    then:
      function: truthy
  losant-title-case-summary:
    description: OpenAPI operation summaries SHOULD use Title Case.
    severity: warn
    given: $.paths.*.*.summary
    then:
      function: pattern
      functionOptions:
        match: ^([A-Z][\w\-/]*)( [A-Z][\w\-/]*| [a-z]{1,3}| [A-Z]+)*$
  losant-bearer-auth-required:
    description: All Losant Platform operations MUST require BearerAuth.
    severity: error
    given: $.paths.*.*.security[*]
    then:
      field: BearerAuth
      function: truthy
  losant-error-schema:
    description: Error responses SHOULD reference the shared error schema.
    severity: warn
    given: $.paths.*.*.responses[?(@property =~ /^4/ || @property =~ /^5/)].content.application/json.schema
    then:
      field: $ref
      function: truthy