extends: - spectral:oas # Spectral linting rules tuned for the Cloudability v3 REST API. # Validates conventions described at # https://www.ibm.com/docs/en/cloudability-commercial/cloudability-premium/saas # — HTTPS only, HTTP basic auth with an API token, JSON responses, # limit/offset pagination, and resource-oriented v3 paths. rules: cloudability-info-contact: description: API contact information must be present. severity: error given: "$.info" then: field: contact function: truthy cloudability-info-license: description: API license must be declared. severity: warn given: "$.info" then: field: license function: truthy cloudability-server-https: description: All server URLs must use HTTPS. severity: error given: "$.servers[*].url" then: function: pattern functionOptions: match: "^https://" cloudability-server-versioned: description: API server URLs must include /v3. severity: warn given: "$.servers[?(@.url && @.url.indexOf('cloudability.com') > -1)].url" then: function: pattern functionOptions: match: "/v3(/|$)" cloudability-basic-auth: description: A basic-auth security scheme (API token) must be defined. severity: error given: "$.components.securitySchemes" then: function: truthy cloudability-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 cloudability-operation-summary: description: Every operation must include a short summary. severity: warn given: "$.paths[*][get,post,put,patch,delete]" then: field: summary function: truthy cloudability-operation-id: description: Every operation must declare a unique operationId. severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: operationId function: truthy cloudability-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"] cloudability-pagination-limit-offset: description: List endpoints should accept limit and offset query params. severity: info given: "$.paths[?(@property.match(/list$|reports$|recommendations$|anomalies$|business-mappings$/))].get.parameters[*].name" then: function: enumeration functionOptions: values: - limit - offset - sort - filters - dimensions - metrics - start_date - end_date cloudability-currency-iso: description: Currency parameters and properties should use ISO 4217 codes. severity: warn given: "$..[?(@property === 'currency')].schema" then: function: schema functionOptions: schema: type: object properties: pattern: type: string enum: - "^[A-Z]{3}$"