# Spectral ruleset for the Deliveroo Developer Portal APIs. # Derived from the Order, Menu, Site, Catalogue, Picking, and Signature # OpenAPI specifications in openapi/. Enforces the conventions observed # across the Deliveroo Partner Platform, Retail Platform, and Signature suites. rules: # ── INFO / METADATA ─────────────────────────────────────────────── info-title-deliveroo-prefix: description: API title should start with "Deliveroo". severity: warn given: $.info.title then: function: pattern functionOptions: match: '^Deliveroo' info-description-required: description: API must have a non-trivial description. severity: warn given: $.info then: field: description function: truthy info-version-required: description: API must declare a version. severity: error given: $.info then: field: version function: truthy info-contact-required: description: API should declare a contact. severity: warn given: $.info then: field: contact function: truthy # ── OPENAPI VERSION ─────────────────────────────────────────────── openapi-version-303: description: Specs should target OpenAPI 3.0.3. severity: warn given: $.openapi then: function: pattern functionOptions: match: '^3\.0\.3$' # ── SERVERS ─────────────────────────────────────────────────────── servers-defined: description: Servers must be defined. severity: error given: $ then: field: servers function: truthy servers-https-only: description: Server URLs must use HTTPS. severity: error given: $.servers[*].url then: function: pattern functionOptions: match: '^https://' server-description-required: description: Each server should have a description. severity: warn given: $.servers[*] then: field: description function: truthy # ── PATHS — NAMING CONVENTIONS ──────────────────────────────────── path-no-trailing-slash: description: Paths must not end with a trailing slash. severity: warn given: $.paths then: field: '@key' function: pattern functionOptions: notMatch: '.+/$' path-kebab-case-segments: description: Static path segments should be lowercase (kebab/snake), not camelCase. severity: warn given: $.paths then: field: '@key' function: pattern functionOptions: notMatch: '[A-Z]' path-versioned: description: Paths should carry a version segment (e.g. /v1/ or /v2/). severity: info given: $.paths then: field: '@key' function: pattern functionOptions: match: '/v[0-9]+/' # ── OPERATIONS ──────────────────────────────────────────────────── operation-operationid-required: description: Every operation must have an operationId. severity: error given: $.paths[*][get,post,put,patch,delete] then: field: operationId function: truthy operation-operationid-camel-case: description: operationId should be camelCase. severity: warn given: $.paths[*][get,post,put,patch,delete].operationId then: function: pattern functionOptions: match: '^[a-z][a-zA-Z0-9]*$' operation-summary-required: description: Every operation must have a summary. severity: warn given: $.paths[*][get,post,put,patch,delete] then: field: summary function: truthy operation-summary-deliveroo-prefix: description: Operation summaries should begin with "Deliveroo". severity: warn given: $.paths[*][get,post,put,patch,delete].summary then: function: pattern functionOptions: match: '^Deliveroo ' operation-description-required: description: Every operation should have a description. severity: warn given: $.paths[*][get,post,put,patch,delete] then: field: description function: truthy operation-tags-required: description: Every operation must have at least one tag. severity: warn given: $.paths[*][get,post,put,patch,delete] then: field: tags function: truthy operation-microcks-extension: description: Operations should declare x-microcks-operation for mock compatibility. severity: info given: $.paths[*][get,post,put,patch,delete] then: field: x-microcks-operation function: truthy # ── PARAMETERS ──────────────────────────────────────────────────── parameter-description-required: description: Every parameter must have a description. severity: warn given: $.paths[*][*].parameters[*] then: field: description function: truthy parameter-snake-case: description: Parameter names should be snake_case. severity: warn given: $.paths[*][*].parameters[*].name then: function: pattern functionOptions: match: '^[a-z][a-z0-9_]*$' parameter-schema-typed: description: Every parameter must declare a schema with a type. severity: warn given: $.paths[*][*].parameters[*].schema then: field: type function: truthy # ── REQUEST BODIES ──────────────────────────────────────────────── request-body-json: description: Request bodies should offer application/json content. severity: warn given: $.paths[*][post,put,patch].requestBody.content then: field: application/json function: truthy # ── RESPONSES ───────────────────────────────────────────────────── response-success-defined: description: Each operation must define at least one 2xx response. severity: error given: $.paths[*][get,post,put,patch,delete].responses then: function: schema functionOptions: schema: type: object anyOf: - required: ['200'] - required: ['201'] - required: ['204'] response-description-required: description: Each response must have a description. severity: warn given: $.paths[*][*].responses[*] then: field: description function: truthy response-auth-error-defined: description: Authenticated operations should document a 401 response. severity: info given: $.paths[*][get,post,put,patch,delete].responses then: field: '401' function: truthy # ── SCHEMAS — PROPERTY NAMING ───────────────────────────────────── schema-property-snake-case: description: Schema property names should be snake_case. severity: warn given: $.components.schemas[*].properties then: field: '@key' function: pattern functionOptions: match: '^[a-z][a-z0-9_]*$' schema-property-typed: description: Schema properties should declare a type. severity: info given: $.components.schemas[*].properties[*] then: function: truthy # ── SECURITY ────────────────────────────────────────────────────── global-security-defined: description: A global security requirement must be defined. severity: warn given: $ then: field: security function: truthy security-scheme-bearer: description: A bearer security scheme should be defined for OAuth tokens. severity: warn given: $.components.securitySchemes then: field: bearerAuth function: truthy # ── TAGS ────────────────────────────────────────────────────────── tag-title-case: description: Tag names should be Title Case. severity: warn given: $.tags[*].name then: function: pattern functionOptions: match: '^[A-Z]' # ── HTTP METHOD CONVENTIONS ─────────────────────────────────────── get-no-request-body: description: GET operations must not declare a request body. severity: error given: $.paths[*].get then: field: requestBody function: falsy