Tray.io · API Governance Rules

Tray.io API Rules

Spectral linting rules defining API design standards and conventions for Tray.io.

6 Rules error 1 warn 5
View Rules File View on GitHub

Rule Categories

tray

Rules

warn
tray-io-operation-id-camel-case
Operation IDs should use camelCase naming convention consistent with Tray.io API conventions (e.g., listConnectors, callConnector).
$.paths[*][*].operationId
error
tray-io-bearer-auth-required
All Tray.io API endpoints require Bearer token authentication.
$.paths[*][*]
warn
tray-io-response-success-defined
All operations should define a successful response (200 or 204).
$.paths[*][get,post,put,patch,delete].responses
warn
tray-io-401-defined
All Tray.io operations should document the 401 Unauthorized response.
$.paths[*][get,post,put,patch,delete].responses
warn
tray-io-description-required
All operations should include a description.
$.paths[*][*]
warn
tray-io-tags-required
All operations should have at least one tag.
$.paths[*][*].tags

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  tray-io-operation-id-camel-case:
    description: >-
      Operation IDs should use camelCase naming convention consistent with
      Tray.io API conventions (e.g., listConnectors, callConnector).
    message: "Operation ID '{{value}}' should use camelCase"
    severity: warn
    given: "$.paths[*][*].operationId"
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]*$"

  tray-io-bearer-auth-required:
    description: >-
      All Tray.io API endpoints require Bearer token authentication.
    message: "All operations require Bearer token authentication"
    severity: error
    given: "$.paths[*][*]"
    then:
      function: schema
      functionOptions:
        schema:
          oneOf:
            - required: ["security"]
            - not:
                required: ["security"]

  tray-io-response-success-defined:
    description: >-
      All operations should define a successful response (200 or 204).
    message: "Operation should define a 200 or 204 success response"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          oneOf:
            - required: ["200"]
            - required: ["204"]

  tray-io-401-defined:
    description: All Tray.io operations should document the 401 Unauthorized response.
    message: "Operation should define a 401 Unauthorized response"
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          required: ["401"]

  tray-io-description-required:
    description: All operations should include a description.
    message: "Operation should have a description"
    severity: warn
    given: "$.paths[*][*]"
    then:
      field: description
      function: truthy

  tray-io-tags-required:
    description: All operations should have at least one tag.
    message: "Operation should have at least one tag"
    severity: warn
    given: "$.paths[*][*].tags"
    then:
      function: length
      functionOptions:
        min: 1