Circle · API Governance Rules

Circle API Rules

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

9 Rules error 4 warn 4 info 1
View Rules File View on GitHub

Rule Categories

circle

Rules

error
circle-info-contact
API contact information must be present.
$.info
error
circle-server-https
All server URLs must use HTTPS.
$.servers[*].url
warn
circle-server-base-path
api.circle.com servers must include /v1.
$.servers[?(@.url && @.url.indexOf('api.circle.com') > -1)].url
error
circle-bearer-security
A bearer-token security scheme must be defined.
$.components.securitySchemes[*]
error
circle-operation-id
Every operation must declare a unique operationId.
$.paths[*][get,post,put,patch,delete]
warn
circle-operation-tags
Operations must declare at least one tag.
$.paths[*][get,post,put,patch,delete]
warn
circle-idempotency-key
POST operations should accept an X-Idempotency-Key header.
$.paths[*].post
warn
circle-error-responses
Mutating operations should declare 4xx/5xx error responses.
$.paths[*][post,put,patch,delete].responses
info
circle-uuid-identifiers
Path parameters named "id" should be UUIDs.
$.paths[*].*.parameters[?(@.in == 'path' && @.name == 'id')].schema

Spectral Ruleset

Raw ↑
extends:
  - spectral:oas

# Spectral linting rules for Circle Web3 Services and adjacent APIs.
# Tuned to api.circle.com conventions: HTTPS-only, /v1/w3s base path,
# UUID identifiers, idempotency keys on POST, and bearer-token auth.
rules:
  circle-info-contact:
    description: API contact information must be present.
    severity: error
    given: "$.info"
    then:
      field: contact
      function: truthy

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

  circle-server-base-path:
    description: api.circle.com servers must include /v1.
    severity: warn
    given: "$.servers[?(@.url && @.url.indexOf('api.circle.com') > -1)].url"
    then:
      function: pattern
      functionOptions:
        match: "/v1"

  circle-bearer-security:
    description: A bearer-token security scheme must be defined.
    severity: error
    given: "$.components.securitySchemes[*]"
    then:
      function: schema
      functionOptions:
        schema:
          type: object
          properties:
            type:
              enum: ["http", "apiKey", "oauth2"]

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

  circle-operation-tags:
    description: Operations 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

  circle-idempotency-key:
    description: POST operations should accept an X-Idempotency-Key header.
    severity: warn
    given: "$.paths[*].post"
    then:
      field: parameters
      function: schema
      functionOptions:
        schema:
          type: array
          contains:
            type: object
            properties:
              name:
                enum: ["X-Idempotency-Key", "idempotencyKey"]

  circle-error-responses:
    description: Mutating operations should declare 4xx/5xx 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"]

  circle-uuid-identifiers:
    description: Path parameters named "id" should be UUIDs.
    severity: info
    given: "$.paths[*].*.parameters[?(@.in == 'path' && @.name == 'id')].schema"
    then:
      field: format
      function: enumeration
      functionOptions:
        values:
          - uuid