Clio · API Governance Rules

Clio API Rules

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

10 Rules error 4 warn 5 info 1
View Rules File View on GitHub

Rule Categories

clio

Rules

error
clio-info-contact
API contact information must be present.
$.info
warn
clio-info-license
API license must be declared.
$.info
error
clio-server-https
All server URLs must use HTTPS.
$.servers[*].url
warn
clio-server-versioned
Manage API server URLs must include /api/v4.
$.servers[?(@.url && @.url.indexOf('clio.com') > -1)].url
error
clio-oauth-security
OAuth 2.0 must be the declared security scheme.
$.components.securitySchemes[*].type
warn
clio-operation-tags
Every operation must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
clio-operation-summary
Every operation must include a short summary.
$.paths[*][get,post,put,patch,delete]
error
clio-operation-id
Every operation must declare a unique operationId.
$.paths[*][get,post,put,patch,delete]
warn
clio-error-responses
Mutating operations should declare 4xx error responses.
$.paths[*][post,put,patch,delete].responses
info
clio-pagination-fields
List endpoints should support page, limit, fields, and order parameters.
$.paths[?(@property.match(/matters$|contacts$|activities$|tasks$|bills$/))].get.parameters[*].name

Spectral Ruleset

clio-rules.yml Raw ↑
extends:
  - spectral:oas

# Spectral linting rules for the Clio Manage API v4.
# https://docs.developers.clio.com/ — OAuth 2.0 secured REST API at
# https://app.clio.com/api/v4 with regional variants for CA/EU/AU.
rules:
  clio-info-contact:
    description: API contact information must be present.
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

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

  clio-server-https:
    description: All server URLs must use HTTPS.
    severity: error
    given: "$.servers[*].url"
    then:
      function: pattern
      functionOptions:
        match: "^https://"

  clio-server-versioned:
    description: Manage API server URLs must include /api/v4.
    severity: warn
    given: "$.servers[?(@.url && @.url.indexOf('clio.com') > -1)].url"
    then:
      function: pattern
      functionOptions:
        match: "/api/v4$"

  clio-oauth-security:
    description: OAuth 2.0 must be the declared security scheme.
    severity: error
    given: "$.components.securitySchemes[*].type"
    then:
      function: enumeration
      functionOptions:
        values:
          - oauth2

  clio-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

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

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

  clio-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"]
            - required: ["422"]

  clio-pagination-fields:
    description: List endpoints should support page, limit, fields, and order parameters.
    severity: info
    given: "$.paths[?(@property.match(/matters$|contacts$|activities$|tasks$|bills$/))].get.parameters[*].name"
    then:
      function: enumeration
      functionOptions:
        values:
          - page
          - limit
          - fields
          - order
          - query
          - created_since
          - updated_since
          - ids