ClickHouse · API Governance Rules

ClickHouse API Rules

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

9 Rules error 4 warn 5
View Rules File View on GitHub

Rule Categories

clickhouse

Rules

error
clickhouse-info-contact
API contact information must be present.
$.info
warn
clickhouse-info-license
API license must be declared.
$.info
error
clickhouse-server-https
All server URLs must use HTTPS for the Cloud control plane.
$.servers[?(@.url && @.url.indexOf('clickhouse.cloud') > -1)].url
warn
clickhouse-cloud-versioned
ClickHouse Cloud paths must be versioned (/v{N}).
$.paths
error
clickhouse-auth-required
A security scheme (apiKey) must be declared for Cloud APIs.
$.components.securitySchemes
error
clickhouse-operation-id
Every operation must declare a unique operationId.
$.paths[*][get,post,put,patch,delete]
warn
clickhouse-operation-tags
Every operation must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
clickhouse-operation-summary
Every operation must include a short summary.
$.paths[*][get,post,put,patch,delete]
warn
clickhouse-error-responses
Mutating operations should declare 4xx error responses.
$.paths[*][post,put,patch,delete].responses

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

# Spectral linting rules for ClickHouse Cloud and HTTP interface APIs.
rules:
  clickhouse-info-contact:
    description: API contact information must be present.
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

  clickhouse-info-license:
    description: API license must be declared.
    severity: warn
    given: "$.info"
    then:
      field: license
      function: truthy

  clickhouse-server-https:
    description: All server URLs must use HTTPS for the Cloud control plane.
    severity: error
    given: "$.servers[?(@.url && @.url.indexOf('clickhouse.cloud') > -1)].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  clickhouse-cloud-versioned:
    description: ClickHouse Cloud paths must be versioned (/v{N}).
    severity: warn
    given: "$.paths"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          patternProperties:
            "^/v\\d+/.*": {}
          additionalProperties: true

  clickhouse-auth-required:
    description: A security scheme (apiKey) must be declared for Cloud APIs.
    severity: error
    given: "$.components.securitySchemes"
    then:
      function: truthy

  clickhouse-operation-id:
    description: Every operation must declare a unique operationId.
    severity: error
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: operationId
      function: truthy

  clickhouse-operation-tags:
    description: Every operation must declare at least one tag.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: tags
      function: schema
      functionOptions:
        schema:
          type: array
          minItems: 1

  clickhouse-operation-summary:
    description: Every operation must include a short summary.
    severity: warn
    given: "$.paths[*][get,post,put,patch,delete]"
    then:
      field: summary
      function: truthy

  clickhouse-error-responses:
    description: Mutating operations should declare 4xx error responses.
    severity: warn
    given: "$.paths[*][post,put,patch,delete].responses"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          anyOf:
            - required: ["400"]
            - required: ["401"]
            - required: ["403"]
            - required: ["404"]