# Spectral ruleset for PAR Punchh OpenAPI specifications. # Derived from the conventions observed across the Mobile, Online Ordering & SSO, # POS/Kiosk, and Platform Functions APIs at developers.partech.com. # Patterns: snake_case schema properties and parameters; camelCase operationIds with # verb prefixes; Title Case tags; HMAC x-pch-digest signing plus bearer/token auth. extends: - spectral:oas rules: # ── INFO / METADATA ────────────────────────────────────────────── info-title-prefix: description: API title should be prefixed with "PAR Punchh". severity: warn given: $.info.title then: function: pattern functionOptions: match: '^PAR Punchh' info-description-required: description: Info object must have a meaningful description. severity: warn given: $.info then: field: description function: truthy info-version-required: description: Info object must declare a version. severity: error given: $.info then: field: version function: truthy info-contact-required: description: Info object should include contact details. severity: info given: $.info then: field: contact function: truthy # ── OPENAPI VERSION ────────────────────────────────────────────── openapi-version-3: description: Specs must target OpenAPI 3.0.x. severity: warn given: $.openapi then: function: pattern functionOptions: match: '^3\.0\.' # ── SERVERS ────────────────────────────────────────────────────── servers-defined: description: Servers must be defined. severity: error given: $ then: field: servers function: truthy server-https: description: Server URLs must use HTTPS. severity: warn given: $.servers[*].url then: function: pattern functionOptions: match: '^https://' server-description: description: Each server should have a description. severity: info given: $.servers[*] then: field: description function: truthy # ── PATHS ──────────────────────────────────────────────────────── path-no-trailing-slash: description: Paths must not end with a trailing slash. severity: warn given: $.paths[*]~ then: function: pattern functionOptions: notMatch: '.+/$' path-snake-case-segments: description: Static path segments use snake_case (matching Punchh path style). severity: info given: $.paths[*]~ then: function: pattern functionOptions: match: '^(/[a-z0-9_{}]+)+$' # ── OPERATIONS ─────────────────────────────────────────────────── operation-operationId-required: description: Every operation must have an operationId. severity: error given: $.paths[*][get,post,put,delete,patch] then: field: operationId function: truthy operation-operationId-camel-case: description: operationId should be camelCase. severity: warn given: $.paths[*][get,post,put,delete,patch].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,delete,patch] then: field: summary function: truthy operation-summary-title-case: description: Operation summaries should be Title Case. severity: info given: $.paths[*][get,post,put,delete,patch].summary then: function: pattern functionOptions: match: '^[A-Z]' operation-description-required: description: Every operation must have a description. severity: warn given: $.paths[*][get,post,put,delete,patch] then: field: description function: truthy operation-tags-required: description: Every operation must be tagged. severity: warn given: $.paths[*][get,post,put,delete,patch] then: field: tags function: truthy operation-microcks-extension: description: Each operation should carry an x-microcks-operation extension for mocking. severity: info given: $.paths[*][get,post,put,delete,patch] then: field: x-microcks-operation function: truthy # ── TAGS ───────────────────────────────────────────────────────── tags-global-defined: description: A global tags array should be defined. severity: info given: $ then: field: tags function: truthy tag-description: description: Each global tag should have a description. severity: info given: $.tags[*] then: field: description function: truthy tag-title-case: description: Tag names should be Title Case. severity: info given: $.tags[*].name then: function: pattern functionOptions: match: '^[A-Z]' # ── 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-type: description: Every parameter must declare a schema 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: info given: $.paths[*][post,put,patch].requestBody.content then: field: application/json function: truthy # ── RESPONSES ──────────────────────────────────────────────────── response-success-defined: description: Each operation must define a 2xx success response. severity: warn given: $.paths[*][get,post,put,delete,patch].responses then: field: '200' function: truthy response-unauthorized: description: Authenticated operations should document a 401 response. severity: info given: $.paths[*][get,post,put,delete,patch].responses then: field: '401' function: truthy response-description-required: description: Every response must have a description. severity: warn given: $.paths[*][*].responses[*] then: field: description function: truthy # ── SCHEMAS ────────────────────────────────────────────────────── schema-property-snake-case: description: Schema property names should be snake_case. severity: warn given: $.components.schemas[*].properties[*]~ then: function: pattern functionOptions: match: '^[a-z][a-z0-9_]*$' schema-type-defined: description: Component schemas should declare a type. severity: warn given: $.components.schemas[*] then: field: type function: truthy # ── SECURITY ───────────────────────────────────────────────────── security-schemes-defined: description: Security schemes must be defined in components. severity: warn given: $.components then: field: securitySchemes function: truthy security-scheme-description: description: Each security scheme should be described. severity: info given: $.components.securitySchemes[*] then: field: description function: truthy