extends: [[spectral:oas, recommended]] rules: # INFO / METADATA info-title-format: description: API title should start with "Amazon OpenSearch Service" severity: warn given: "$.info.title" then: function: pattern functionOptions: match: "^Amazon OpenSearch Service" info-description-required: description: Info object must have a description severity: error given: "$.info" then: field: description function: truthy info-version-required: description: Info object must have a version severity: error given: "$.info" then: field: version function: truthy # OPENAPI VERSION openapi-version-3: description: OpenAPI version should be 3.x severity: warn given: "$.openapi" then: function: pattern functionOptions: match: "^3\\." # SERVERS servers-required: description: Servers must be defined severity: error given: "$" then: field: servers function: truthy server-https-required: description: Server URLs must use HTTPS severity: error given: "$.servers[*].url" then: function: pattern functionOptions: match: "^https://" # PATHS paths-kebab-case: description: Path segments should use kebab-case severity: warn given: "$.paths[*]~" then: function: pattern functionOptions: match: "^(/[a-z0-9][a-z0-9-]*|/\\{[a-zA-Z][a-zA-Z0-9_]*\\})*$" paths-no-trailing-slash: description: Paths should not have a trailing slash severity: warn given: "$.paths[*]~" then: function: pattern functionOptions: notMatch: "/$" # OPERATIONS operation-summary-required: description: Operations must have a summary severity: error given: "$.paths[*][get,post,put,patch,delete,head,options]" then: field: summary function: truthy operation-summary-company-prefix: description: Operation summaries should start with "Amazon OpenSearch Service" severity: warn given: "$.paths[*][get,post,put,patch,delete].summary" then: function: pattern functionOptions: match: "^Amazon OpenSearch Service" operation-description-required: description: Operations must have a description severity: warn given: "$.paths[*][get,post,put,patch,delete,head,options]" then: field: description function: truthy operation-id-required: description: Operations must have an operationId severity: error given: "$.paths[*][get,post,put,patch,delete,head,options]" then: field: operationId function: truthy operation-id-camel-case: description: OperationIds should 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: warn given: "$.paths[*][get,post,put,patch,delete,head,options]" 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 (2xx) severity: error given: "$.paths[*][get,post,put,patch,delete].responses" then: function: schema functionOptions: schema: anyOf: - required: ["200"] - required: ["201"] - required: ["202"] - required: ["204"] 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-type-required: description: Schemas should define a type severity: warn given: "$.components.schemas[*]" then: field: type function: truthy # SECURITY security-scheme-defined: description: Security schemes must be defined in components severity: error given: "$.components" then: field: securitySchemes function: truthy # HTTP METHOD CONVENTIONS get-no-request-body: description: GET operations should not have a request body severity: error given: "$.paths[*].get" then: field: requestBody function: falsy # GENERAL QUALITY operation-examples-encouraged: description: Operations should include examples severity: info given: "$.paths[*][get,post,put,patch,delete].responses[*].content[*]" then: function: schema functionOptions: schema: anyOf: - required: ["example"] - required: ["examples"]