# Allianz Engagement Survey API Spectral Rules # Enforces API conventions for the Allianz Engagement Survey API rules: # INFO / METADATA info-title-allianz-prefix: description: API title must start with "Allianz" severity: warn given: "$.info.title" then: function: pattern functionOptions: match: "^Allianz" info-description-required: description: API info must have a description severity: error given: "$.info" then: field: description function: truthy info-version-required: description: API info must define a version severity: error given: "$.info" then: field: version function: truthy # OPENAPI VERSION openapi-version-3: description: Specs must use OpenAPI 3.x severity: error given: "$.openapi" then: function: pattern functionOptions: match: "^3\\." # SERVERS servers-defined: description: At least one server must be defined severity: error given: "$" then: field: servers function: truthy servers-https: description: Server URLs must use HTTPS severity: error given: "$.servers[*].url" then: function: pattern functionOptions: match: "^https://" # PATHS paths-kebab-case: description: Path segments must use kebab-case severity: warn given: "$.paths" then: function: pattern functionOptions: match: "^(\\/([a-z0-9][a-z0-9-]*|\\{[a-zA-Z_]+\\}))+$" paths-no-trailing-slash: description: Paths must not have trailing slashes severity: error given: "$.paths" then: function: pattern functionOptions: notMatch: "\\/$" # OPERATIONS operation-summary-required: description: Every operation must have a summary severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: summary function: truthy operation-summary-allianz-prefix: description: Summaries must start with "Allianz Engagement Survey" severity: warn given: "$.paths[*][get,post,put,patch,delete].summary" then: function: pattern functionOptions: match: "^Allianz Engagement Survey" operation-description-required: description: Every operation must have a description severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: description function: truthy operation-id-required: description: Every operation must have an operationId severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: operationId function: truthy operation-id-camel-case: description: operationId must use camelCase severity: warn given: "$.paths[*][get,post,put,patch,delete].operationId" then: function: pattern functionOptions: match: "^[a-z][a-zA-Z0-9]+$" operation-tags-required: description: Every operation must have at least one tag severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: tags function: truthy # TAGS tags-defined: description: Global tags array should be defined severity: warn given: "$" then: field: tags function: truthy # PARAMETERS parameter-description-required: description: All parameters must have descriptions severity: error given: "$.paths[*][get,post,put,patch,delete].parameters[*]" then: field: description function: truthy parameter-snake-case: description: Parameter names should use snake_case severity: warn given: "$.paths[*][get,post,put,patch,delete].parameters[*].name" then: function: pattern functionOptions: match: "^[a-z][a-z0-9_]*$" # PAGINATION list-operations-pagination: description: List operations should support limit and offset parameters severity: info given: "$.paths[*].get.operationId" then: function: pattern functionOptions: match: "^list" # RESPONSES response-success-required: description: Every operation must define a success response severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: responses function: truthy response-401-required: description: Operations should define a 401 response severity: warn given: "$.paths[*][get,post,put,patch,delete].responses" then: function: schema functionOptions: schema: type: object required: - "401" response-description-required: description: All responses must have descriptions severity: error given: "$.paths[*][get,post,put,patch,delete].responses[*]" then: field: description function: truthy # SECURITY security-schemes-defined: description: Security schemes must be defined severity: error given: "$.components" then: field: securitySchemes function: truthy # HTTP METHOD CONVENTIONS get-no-request-body: description: GET operations must not have request bodies severity: error given: "$.paths[*].get" then: field: requestBody function: falsy # PRIVACY responses-anonymized: description: Response descriptions should note anonymization for response endpoints severity: info given: "$.paths[*].get.description" then: function: truthy