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