# Allianz Technology Standards Spectral Rules # Enforces Allianz API design conventions based on the technology standards documentation rules: 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-3: description: Specs must use OpenAPI 3.x (API-first standard) severity: error given: "$.openapi" then: function: pattern functionOptions: match: "^3\\." 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 (Allianz security standard) severity: error given: "$.servers[*].url" then: function: pattern functionOptions: match: "^https://" paths-no-trailing-slash: description: Paths must not have trailing slashes severity: error given: "$.paths" then: function: pattern functionOptions: notMatch: "\\/$" 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-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-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 # ALLIANZ PAGINATION STANDARD list-operations-page-size: description: List operations should support pageSize query parameter (Allianz pagination standard) severity: warn given: "$.paths[*].get.parameters[*].name" then: function: pattern functionOptions: match: "^(pageSize|page_size|limit)$" list-operations-page-param: description: List operations should support page query parameter (Allianz pagination standard) severity: warn given: "$.paths[*].get.parameters[*].name" then: function: pattern functionOptions: match: "^(page|offset)$" # ALLIANZ ASYNC PATTERN async-post-returns-202: description: Async POST operations should return 202 Accepted (Allianz async pattern) severity: info given: "$.paths[*].post.responses" then: function: schema functionOptions: schema: type: object # SECURITY security-schemes-defined: description: Security schemes must be defined (OAuth2 standard) severity: error given: "$.components" then: field: securitySchemes function: truthy oauth2-scheme-required: description: OAuth2 security scheme should be defined (Allianz OAuth2 standard) severity: warn given: "$.components.securitySchemes" then: function: schema functionOptions: schema: type: object required: - OAuth2 global-security-defined: description: Global security should be defined severity: warn given: "$" then: field: security 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 # RESPONSE STANDARDS response-description-required: description: All responses must have descriptions severity: error given: "$.paths[*][get,post,put,patch,delete].responses[*]" then: field: description 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" # TAGS tags-defined: description: Global tags array should be defined severity: warn given: "$" then: field: tags function: truthy # PARAMETER STANDARDS parameter-description-required: description: All parameters must have descriptions severity: error given: "$.paths[*][get,post,put,patch,delete].parameters[*]" then: field: description function: truthy