extends: spectral:oas rules: # INFO / METADATA info-title-prefix: description: API title must start with "Amdocs" severity: warn given: "$.info.title" then: function: pattern functionOptions: match: "^Amdocs" info-description-required: description: API must have a description severity: error given: "$.info" then: field: description function: truthy info-version-required: description: API must have a version severity: error given: "$.info" then: field: version function: truthy # OPENAPI VERSION openapi-version-3: description: Use OpenAPI 3.x severity: warn 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 — NAMING CONVENTIONS paths-kebab-case: description: Path segments should use kebab-case severity: warn given: "$.paths[*]~" then: function: pattern functionOptions: match: "^(\\/([a-z0-9-]+|\\{[a-zA-Z]+\\}))*$" paths-versioned: description: Paths should include API version prefix severity: info given: "$.paths[*]~" then: function: pattern functionOptions: match: "^\\/v[0-9]" # OPERATIONS operation-summary-required: description: Operations must have a summary severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: summary function: truthy operation-description-required: description: Operations must have a description severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: description function: truthy operation-id-required: description: Operations 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: Operations must have at least one tag severity: error given: "$.paths[*][get,post,put,patch,delete]" then: field: tags function: truthy # PARAMETERS parameter-description-required: description: Parameters must have a description severity: warn given: "$.paths[*][get,post,put,patch,delete].parameters[*]" then: field: description function: truthy # RESPONSES response-success-required: description: Operations must have a success 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-401-required: description: Operations should define 401 Unauthorized severity: warn given: "$.paths[*][get,post,put,patch,delete].responses" then: function: schema functionOptions: schema: type: object required: ["401"] response-description-required: description: Response objects must have a description severity: error given: "$.paths[*][get,post,put,patch,delete].responses[*]" then: field: description function: truthy # SCHEMAS schema-description-required: description: Component schemas should have a description severity: warn given: "$.components.schemas[*]" then: field: description function: truthy # SECURITY security-oauth2: description: APIs should use OAuth 2.0 security scheme severity: info given: "$.components.securitySchemes[*]" then: field: type function: pattern functionOptions: match: "^oauth2$" # HTTP METHOD CONVENTIONS get-no-request-body: description: GET operations must not have a request body severity: error given: "$.paths[*].get" then: field: requestBody function: falsy # GENERAL QUALITY no-empty-descriptions: description: Descriptions must not be empty severity: error given: "$..description" then: function: pattern functionOptions: match: ".+"