Trino · API Governance Rules

Trino API Rules

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

8 Rules error 2 warn 6
View Rules File View on GitHub

Rule Categories

trino

Rules

error
trino-path-must-start-with-v1
All Trino API paths must be versioned with /v1/ prefix
$.paths[*]~
warn
trino-operation-summary-title-case
Operation summaries must use Title Case
$.paths[*][*].summary
warn
trino-user-header-documented
Operations should document the X-Trino-User header
$.paths[*].post.parameters[*]
warn
trino-operation-id-camel-case
OperationIds must use camelCase
$.paths[*][*].operationId
warn
trino-operation-must-have-description
All operations must have a description
$.paths[*][*]
error
trino-get-must-have-200
GET operations must have a 200 response defined
$.paths[*].get
warn
trino-path-params-must-have-descriptions
Path parameters must have descriptions
$.paths[*][*].parameters[?(@.in == 'path')].description
warn
trino-schema-names-pascal-case
Schema names must use PascalCase
$.components.schemas[*]~

Spectral Ruleset

Raw ↑
extends: spectral:oas
rules:
  # Trino uses versioned paths: /v1/...
  trino-path-must-start-with-v1:
    description: All Trino API paths must be versioned with /v1/ prefix
    message: "Path '{{property}}' must start with /v1/"
    given: "$.paths[*]~"
    severity: error
    then:
      function: pattern
      functionOptions:
        match: "^/v1/"

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

  # Trino client API requires X-Trino-User header documentation
  trino-user-header-documented:
    description: Operations should document the X-Trino-User header
    message: "Trino operations should include X-Trino-User header parameter"
    given: "$.paths[*].post.parameters[*]"
    severity: warn
    then:
      field: name
      function: enumeration
      functionOptions:
        values:
          - X-Trino-User

  # operationIds must be camelCase
  trino-operation-id-camel-case:
    description: OperationIds must use camelCase
    message: "OperationId '{{value}}' should be camelCase"
    given: "$.paths[*][*].operationId"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[a-z][a-zA-Z0-9]+$"

  # All operations must have descriptions
  trino-operation-must-have-description:
    description: All operations must have a description
    message: "Operation at '{{path}}' is missing a description"
    given: "$.paths[*][*]"
    severity: warn
    then:
      field: description
      function: truthy

  # Responses must include a 200 for GET operations
  trino-get-must-have-200:
    description: GET operations must have a 200 response defined
    message: "GET operation is missing a 200 response"
    given: "$.paths[*].get"
    severity: error
    then:
      field: responses.200
      function: truthy

  # Path parameters must have descriptions
  trino-path-params-must-have-descriptions:
    description: Path parameters must have descriptions
    message: "Path parameter '{{value}}' is missing a description"
    given: "$.paths[*][*].parameters[?(@.in == 'path')].description"
    severity: warn
    then:
      function: truthy

  # Components/schemas must use PascalCase
  trino-schema-names-pascal-case:
    description: Schema names must use PascalCase
    message: "Schema '{{property}}' should use PascalCase"
    given: "$.components.schemas[*]~"
    severity: warn
    then:
      function: pattern
      functionOptions:
        match: "^[A-Z][a-zA-Z0-9]+$"