rules: # INFO / METADATA info-title-required: description: Info title must be present and start with "Abstract API" severity: error given: '$.info' then: field: title function: pattern functionOptions: match: '^Abstract API' info-description-required: description: Info description must be present severity: error given: '$.info' then: field: description function: truthy info-version-required: description: Info version must be present severity: error given: '$.info' then: field: version function: truthy # OPENAPI VERSION openapi-version-3: description: Must use OpenAPI 3.0.x severity: error given: '$' then: field: openapi function: pattern functionOptions: match: '^3\.0\.' # SERVERS servers-required: description: At least one server must be defined severity: error given: '$' then: field: servers function: truthy servers-https-only: description: All server URLs must use HTTPS severity: error given: '$.servers[*]' then: field: url function: pattern functionOptions: match: '^https://' servers-abstractapi-domain: description: Server URLs should be under abstractapi.com domain severity: warn given: '$.servers[*]' then: field: url function: pattern functionOptions: match: 'abstractapi\.com' # PATHS — NAMING CONVENTIONS paths-kebab-case: description: Path segments must use kebab-case (lowercase with hyphens) severity: warn given: '$.paths' then: field: '@key' function: pattern functionOptions: match: '^(\/[a-z0-9_\-\{\}]*)*$' paths-no-trailing-slash: description: Paths must not have trailing slashes (except root /) severity: warn given: '$.paths' then: field: '@key' 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-title-case: description: Operation summary must start with "Abstract API" severity: warn given: '$.paths[*][get,post,put,patch,delete]' then: field: summary function: pattern functionOptions: match: '^Abstract API' 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]' then: field: operationId 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 operation-microcks-extension: description: Operations should have x-microcks-operation extension for mock server compatibility severity: info given: '$.paths[*][get,post,put,patch,delete]' then: field: x-microcks-operation function: truthy # TAGS tags-title-case: description: Tags should use Title Case severity: warn given: '$.tags[*]' then: field: name function: pattern functionOptions: match: '^[A-Z]' # PARAMETERS parameter-description-required: description: Every parameter must have a description severity: error given: '$.paths[*][get,post,put,patch,delete].parameters[*]' then: field: description function: truthy parameter-api-key-query: description: Abstract API uses api_key as the query parameter name for authentication severity: warn given: '$.paths[*][get,post,put,patch,delete].parameters[?(@.name == "api_key")]' then: field: in function: enumeration functionOptions: values: - query - header parameter-schema-required: description: Every parameter must have a schema with type severity: error given: '$.paths[*][get,post,put,patch,delete].parameters[*]' then: field: schema function: truthy parameter-example-recommended: description: Parameters should have example values severity: info given: '$.paths[*][get,post,put,patch,delete].parameters[*]' then: field: example function: truthy # RESPONSES response-success-required: description: Every operation must have a 2xx success response severity: error given: '$.paths[*][get,post,put,patch,delete].responses' then: function: schema functionOptions: schema: anyOf: - required: ['200'] - required: ['201'] - required: ['204'] response-401-required: description: Operations secured with API key should document 401 response severity: warn given: '$.paths[*][get,post,put,patch,delete].responses' then: field: '401' function: truthy response-429-recommended: description: Rate-limited APIs should document 429 response severity: info given: '$.paths[*][get,post,put,patch,delete].responses' then: field: '429' function: truthy response-description-required: description: Every response must have a description severity: error given: '$.paths[*][get,post,put,patch,delete].responses[*]' then: field: description function: truthy # SCHEMAS — PROPERTY NAMING schema-property-description: description: Schema properties should have descriptions severity: info given: '$.components.schemas[*].properties[*]' then: field: description function: truthy schema-property-example: description: Schema properties should have example values severity: info given: '$.components.schemas[*].properties[*]' then: field: example function: truthy schema-top-level-description: description: Top-level schemas should have descriptions severity: warn given: '$.components.schemas[*]' then: field: description function: truthy # SECURITY security-schemes-defined: description: Security schemes must be defined in components severity: error given: '$' then: field: components.securitySchemes function: truthy security-api-key-scheme: description: Abstract API uses apiKey security scheme severity: warn given: '$.components.securitySchemes[*]' then: field: type function: enumeration functionOptions: values: - apiKey - http # 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 delete-no-request-body: description: DELETE operations should not have a request body severity: warn given: '$.paths[*].delete' then: field: requestBody function: falsy # GENERAL QUALITY no-empty-descriptions: description: Descriptions must not be empty strings severity: error given: '$..description' then: function: pattern functionOptions: match: '.+' generated-from-docs-marked: description: Generated specs should be marked with x-generated-from severity: info given: '$.info' then: field: x-generated-from function: truthy