# harvested from https://github.com/Raiffeisen-DGTL/rest-api-guide/blob/b2afc8e0247d5ff43a3cb61b2c343752fd2f6ee6/spectral/base-ruleset.yaml on 2026-10-09 — a Spectral ruleset published in the provider's own GitHub repository (Raiffeisen-DGTL/rest-api-guide); found by GitHub code search, fetched verbatim
x-method: harvested
x-stamped: 2026-10-09
x-source-url: https://github.com/Raiffeisen-DGTL/rest-api-guide/blob/b2afc8e0247d5ff43a3cb61b2c343752fd2f6ee6/spectral/base-ruleset.yaml
# AUTOGENERATED - DO NOT EDIT THIS FILE MANUALLY
documentationUrl: https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi
aliases:
ArrayProperties:
targets:
- formats:
- "oas3_0"
given:
- "$..[?(@ && @.type==\"array\")]"
- formats:
- "oas3_1"
given:
- "$..[?(@ && @.type==\"array\")]"
- "$..[?(@ && @.type && @.type.constructor.name === \"Array\" && @.type.includes(\"array\"))]"
LinkObject:
targets:
- formats:
- "oas3"
given:
- "$.components.links[*]"
- "#ResponseObject.links[*]"
OperationObject:
- "#PathItem[get,put,post,delete,options,head,patch,trace]"
PathItem:
- "$.paths[*]"
ResponseObject:
targets:
- formats:
- "oas3"
given:
- "#OperationObject.responses[*]"
- "$.components.responses[*]"
SecurityRequirementObject:
- "$.security[*]"
- "#OperationObject.security[*]"
extends: [['spectral:oas', off]]
functions:
- "allOffTypesConsistency"
- "arrayItems"
- "methodRequestResponseComponents"
- "refSiblings"
- "oasSecurityDefined"
- "serverVariables"
- "oasUnusedComponent"
- "oasExample"
- "objectRequestResponsePostfix"
- "uniquenessTags"
- "operationMustHaveSecurity"
- "oasOpIdUnique"
- "oasOpParams"
- "oasOpSuccessResponse"
- "oasTagDefined"
- "oasPathParam"
- "provideHeadMethod"
- "responseErrorStructure"
- "typedEnum"
- "validSchemaExample"
rules:
all-off-types-consistency:
description: "Все элементы allOf должны иметь одинаковый тип"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#all-off-types-consistency"
given: "$..[?(@ && @.allOf)]"
severity: "error"
then:
function: "allOffTypesConsistency"
array-items:
description: "Объекты типа Array должны содержать массив элементов"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#array-items"
formats:
- "oas3_0"
- "oas3_1"
given: "#ArrayProperties"
severity: "error"
then:
function: "arrayItems"
blank-strings-forbidden:
description: "Пустые строки запрещены"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#blank-strings-forbidden"
formats:
- "oas3_0"
- "oas3_1"
given:
- "$..[description,title]"
- "$..[required[*]]"
- "$..[summary,example]"
- "$..[x-raif-api-description-en]"
severity: "error"
then:
function: "pattern"
functionOptions:
match: "(.|\\s)*\\S(.|\\s)*"
body-fields-camel-case:
description: "Поля в requestBody и responseBody должны быть в camelCase"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#body-fields-camel-case"
given:
- "$.paths.*.*.requestBody.content.*.schema..properties.*~"
- "$.paths.*.requestBody.content.*.schema..properties.*~"
- "$.paths.*.*.responses.*.content.*.schema..properties.*~"
- "$.paths.*.responses.*.content.*.schema..properties.*~"
- "$.components.schemas.*..properties.*~"
- "$.components.requestBodies.*.content.*.schema..properties.*~"
- "$.components.responses.*.content.*.schema..properties.*~"
severity: "error"
then:
function: "casing"
functionOptions:
type: "camel"
contact-x-team-id-required:
description: "Поле info.contact.x-team-id является обязательным"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#contact-x-team-id-required"
given: "$.info"
message: "Отсутствует поле info.contact.x-team-id"
severity: "error"
then:
field: "contact.x-team-id"
function: "truthy"
description-required-for-schema-fields:
description: "У каждого поля в схеме должен быть description"
given:
- "$..properties.*"
- "$.components.schemas.*.enum[*]"
severity: "error"
then:
- field: "description"
function: "truthy"
duplicated-entry-in-enum:
description: "Значения в ENUM должны быть уникальны."
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#duplicated-entry-in-enum"
given: "$..enum"
message: "Duplicate entry '{{value}}' in enum."
severity: "error"
then:
function: "schema"
functionOptions:
schema:
type: "array"
uniqueItems: true
empty-objects-forbidden:
description: "Запрещены пустые объекты"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#empty-objects-forbidden"
given:
- "$"
- "$..*"
severity: "error"
then:
function: "schema"
functionOptions:
schema:
not:
maxProperties: 0
type: "object"
enum-discriminator-upper-snake-case:
description: "Перечисления и значения маппинга для дискриминаторов именуются UPPER_SNAKE_CASE"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#enum-discriminator-upper-snake-case"
given:
- "$.components.schemas..enum[*]"
- "$.components.schemas..discriminator.mapping.*~"
message: "Enum values and discriminator mappings must be in UPPER_SNAKE_CASE format"
severity: "error"
then:
function: "casing"
functionOptions:
type: "macro"
info-contact:
description: "Блок info должен содержать раздел contact"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#info-contact"
given: "$"
severity: "error"
then:
field: "info.contact"
function: "truthy"
info-description:
description: "Блок info должен содержать раздел description"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#info-description"
given: "$"
severity: "error"
then:
field: "info.description"
function: "truthy"
method-operation-id-camel-case:
description: "OperationId должны быть в camelCase формате"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#method-operation-id-camel-case"
given: "$.paths[*][get,put,post,delete,options,head,patch,trace]"
severity: "error"
then:
field: "operationId"
function: "casing"
functionOptions:
type: "camel"
method-request-response-components:
description: "Тело запроса и ответа должны быть вынесены в блок components как schema"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#method-request-response-components"
given: "$.paths"
resolved: false
severity: "error"
then:
function: "methodRequestResponseComponents"
names-should-be-in-english:
description: "Названия полей, параметров и операций должны быть на английском языке"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#names-should-be-in-english"
given:
- "$..enum[*]"
- "$.paths[*][get,put,post,delete,options,head,patch,trace].operationId"
- "$.paths[*][get,put,post,delete,options,head,patch,trace].parameters[*].name"
- "$.components.parameters[*].name"
- "$.components.schemas.*~"
- "$.components.schemas.*.properties.*~"
- "$.paths[*][get,put,post,delete,options,head,patch,trace].requestBody.content.*.schema.properties.*~"
- "$.paths[*][get,put,post,delete,options,head,patch,trace].responses.*.content.*.schema.properties.*~"
severity: "error"
then:
function: "pattern"
functionOptions:
match: "^[a-zA-Z0-9\\s\\-_.,:;!?()\"\\[\\]{}@#$%^&*+=<>|/~`]+$"
no-eval-in-markdown:
description: "Блок description и title не должен содержать eval()"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#no-eval-in-markdown"
given: "$..[description,title]"
severity: "error"
then:
function: "pattern"
functionOptions:
notMatch: "eval\\("
no-ref-siblings:
description: "Рядом с $ref не должно быть property"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#no-ref-siblings"
formats:
- "oas3_0"
given: "$.paths"
resolved: false
severity: "error"
then:
function: "refSiblings"
no-script-tags-in-markdown:
description: "Блок description и title не должен содержать <script>"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#no-script-tags-in-markdown"
given: "$..[description,title]"
severity: "error"
then:
function: "pattern"
functionOptions:
notMatch: "<script"
not-use-redirection-codes:
description: "Не используйте коды перенаправления в responses"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#not-use-redirection-codes"
given:
- "$.paths.*.*.responses.*~"
- "$.paths.*.responses.*~"
- "$.webhooks.*.*.responses.*~"
severity: "error"
then:
function: "pattern"
functionOptions:
notMatch: "^3(?!04$)(?:\\d{2}|XX)$"
oas3-1-servers-in-webhook:
description: "Webhooks не должны включать в себя servers"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3_1-servers-in-webhook"
formats:
- "oas3_1"
given:
- "$.webhooks.servers"
- "$.webhooks[*][*].servers"
severity: "error"
then:
function: "undefined"
oas3-api-servers:
description: "Servers должны быть заполнены"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3-api-servers"
formats:
- "oas3_0"
given: "$"
severity: "error"
then:
field: "servers"
function: "schema"
functionOptions:
dialect: "draft7"
schema:
items:
type: "object"
minItems: 1
type: "array"
oas3-callbacks-in-callbacks:
description: "Callbacks не должны включать в себя callbacks"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3-callbacks-in-callbacks"
formats:
- "oas3"
given: "$.paths[*][get,put,post,delete,options,head,patch,trace].callbacks[*][*][*].callbacks"
severity: "error"
then:
function: "undefined"
oas3-examples-value-or-externalValue:
description: "Examples должен содержать value или externalValue"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3-examples-value-or-externalValue"
formats:
- "oas3"
given:
- "$.components.examples[*]"
- "$.paths[*][*]..content[*].examples[*]"
- "$.paths[*][*]..parameters[*].examples[*]"
- "$.components.parameters[*].examples[*]"
- "$.paths[*][*]..headers[*].examples[*]"
- "$.components.headers[*].examples[*]"
severity: "warn"
then:
function: "xor"
functionOptions:
properties:
- "externalValue"
- "value"
oas3-operation-security-defined:
description: "Операция \"security\" должна быть определена в объекте \"components.securitySchemes\""
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3-operation-security-defined"
formats:
- "oas3"
given: "#SecurityRequirementObject"
resolved: false
severity: "error"
then:
function: "oasSecurityDefined"
functionOptions:
oasVersion: 3
oas3-parameter-description:
description: "Параметры должны иметь заполненный description"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3-parameter-description"
formats:
- "oas3"
given:
- "#PathItem.parameters[?(@ && @.in)]"
- "#OperationObject.parameters[?(@ && @.in)]"
- "$.components.parameters[?(@ && @.in)]"
severity: "warn"
then:
field: "description"
function: "truthy"
oas3-schema: "error"
oas3-server-trailing-slash:
description: "Servers не должны заканчиваться на символ /"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3-server-trailing-slash"
formats:
- "oas3"
given: "$.servers[*].url"
severity: "info"
then:
function: "pattern"
functionOptions:
notMatch: "./$"
oas3-server-variables:
description: "Переменные из servers должны быть определены в variables и не должно быть неиспользуемые переменных"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3-server-variables"
given:
- "$.servers[*]"
- "#PathItem.servers[*]"
- "#OperationObject.servers[*]"
- "#LinkObject.server"
severity: "error"
then:
function: "serverVariables"
functionOptions:
checkSubstitutions: true
requireDefault: true
oas3-unused-component:
description: "Спецификация не должна содержать неиспользуемые компоненты"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3-unused-component"
formats:
- "oas3_0"
given: "$"
resolved: false
severity: "error"
then:
function: "oasUnusedComponent"
oas3-valid-media-example:
description: "Examples должны соответствовать объявленной схеме"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3-valid-media-example"
formats:
- "oas3_0"
given:
- "$..content..[?(@ && @.schema && (@.example !== void 0 || @.examples))]"
- "$..headers..[?(@ && @.schema && (@.example !== void 0 || @.examples))]"
- "$..parameters..[?(@ && @.schema && (@.example !== void 0 || @.examples))]"
severity: "error"
then:
function: "oasExample"
functionOptions:
oasVersion: 3
schemaField: "schema"
type: "media"
oas3-valid-schema-example:
description: "Examples в описании схемы должны соответствовать объявленным типам"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3-valid-schema-example"
formats:
- "oas3_0"
given:
- "$.components.schemas..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]"
- "$..content..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]"
- "$..headers..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]"
- "$..parameters..[?(@property !== 'properties' && @ && (@ && @.example !== void 0 || @.default !== void 0) && (@.enum || @.type || @.format || @.$ref || @.properties || @.items))]"
severity: "error"
then:
function: "oasExample"
functionOptions:
oasVersion: 3
schemaField: "$"
type: "schema"
oas3_1-callbacks-in-webhook:
description: "Webhooks не должны включать в себя callbacks"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#oas3_1-callbacks-in-webhook"
formats:
- "oas3_1"
given: "$.webhooks[*][*].callbacks"
severity: "error"
then:
function: "undefined"
object-request-response-postfix:
description: "Объекты запросов и ответов должны быть заданы стилем PascalCase с постфиксами Request/Response"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#object-request-response-postfix"
given:
- "$"
resolved: false
severity: "warn"
then:
function: "objectRequestResponsePostfix"
openapi-tags:
description: "Массив tags не должен быть пустым"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#openapi-tags"
given: "$"
severity: "error"
then:
field: "tags"
function: "length"
functionOptions:
min: 1
openapi-tags-alphabetical:
description: "Tags должны быть в алфавитном порядке"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#openapi-tags-alphabetical"
given: "$"
resolved: false
severity: "info"
then:
field: "tags"
function: "alphabetical"
functionOptions:
keyedBy: "name"
openapi-tags-uniqueness:
description: "Названия тегов должны быть уникальными"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#openapi-tags-uniqueness"
given: "$.tags"
resolved: false
severity: "error"
then:
function: "uniquenessTags"
operation-description:
description: "Блок operation.description должен быть заполнен не пустой строкой"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#operation-description"
given: "$.paths[*][get,put,post,delete,options,head,patch,trace]"
severity: "warn"
then:
field: "description"
function: "truthy"
operation-must-have-security:
description: "Каждая операция должна ссылаться минимум на один security scheme"
given:
- "$.paths[*][?(@property.match(/^(get|put|post|delete|patch|options|head|trace)$/))]"
message: "Для AI Ready желательно, чтобы все операции содержали security scheme"
severity: "info"
then:
function: "operationMustHaveSecurity"
operation-must-have-summary:
description: "Каждая операция должна содержать поле summary"
given: "$.paths[*][?(@property.match(/^(get|put|post|delete|patch|options|head|trace)$/))]"
severity: "error"
then:
- field: "summary"
function: "truthy"
operation-must-have-tag:
description: "Каждая операция (endpoint) должна быть снабжена тегом"
given: "$.paths[*][?(@property.match(/^(get|put|post|delete|patch|options|head|trace)$/))]"
severity: "warn"
then:
- field: "tags"
function: "truthy"
- field: "tags"
function: "length"
functionOptions:
min: 1
operation-operationId:
description: "Каждый path должен иметь operationId"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#operation-operationId"
given: "$.paths[*][get,put,post,delete,options,head,patch,trace]"
severity: "error"
then:
field: "operationId"
function: "truthy"
operation-operationId-unique:
description: "OperationId должен быть уникальным"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#operation-operationId-unique"
given: "$.paths"
severity: "error"
then:
function: "oasOpIdUnique"
operation-operationId-valid-in-url:
description: "OperationId не должен содержать запрещенных символов"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#operation-operationId-valid-in-url"
given: "#OperationObject"
severity: "error"
then:
field: "operationId"
function: "pattern"
functionOptions:
match: "^[A-Za-z0-9-._~:/?#\\[\\]@!\\$&'()*+,;=]*$"
operation-parameters:
description: "Параметры в методах должны быть уникальными"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#operation-parameters"
given: "#OperationObject.parameters"
severity: "error"
then:
function: "oasOpParams"
operation-singular-tag:
description: "Метод должен иметь не более одного тега"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#operation-singular-tag"
given: "#OperationObject"
severity: "error"
then:
field: "tags"
function: "length"
functionOptions:
max: 1
operation-success-response:
description: "Метод должен иметь 2хх либо 3хх ответ"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#operation-success-response"
given: "#OperationObject"
severity: "error"
then:
field: "responses"
function: "oasOpSuccessResponse"
operation-tag-defined:
description: "Tags методов должны быть определены в глобальном списке tags"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#operation-tag-defined"
given: "$"
severity: "error"
then:
function: "oasTagDefined"
path-declarations-must-exist:
description: "Параметры пути не должны записываться пустыми элементами, например \"/given/{}\""
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#path-declarations-must-exist"
given: "$.paths"
severity: "error"
then:
field: "@key"
function: "pattern"
functionOptions:
notMatch: "{}"
path-kebab-case:
description: "Path должны быть в kebabCase формате"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#path-kebab-case"
given: "$.paths.*~"
severity: "error"
then:
field: "@key"
function: "pattern"
functionOptions:
match: "^/(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|\\{[A-Za-z0-9_]+\\})(?:/(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|\\{[A-Za-z0-9_]+\\}))*$"
path-keys-no-trailing-slash:
description: "Path не должен заканчиваться на символ /"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#path-keys-no-trailing-slash"
given: "$.paths"
severity: "info"
then:
field: "@key"
function: "pattern"
functionOptions:
notMatch: "./$"
path-no-redundant-prefixes:
description: "В paths запрещено использовать сегменты api, openapi, http, service"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#path-no-redundant-prefixes"
given:
- "$.paths.*~"
severity: "error"
then:
function: "pattern"
functionOptions:
notMatch: "(?:^|/)(?:api|openapi|http|service)(?:/|$)"
path-not-include-query:
description: "Path не должен содержать символов \"?\""
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#path-not-include-query"
given: "$.paths"
severity: "error"
then:
field: "@key"
function: "pattern"
functionOptions:
notMatch: "\\?.+"
path-params:
description: "Параметры пути должны быть описаны и использованы"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#path-params"
given: "$.paths"
resolved: false
severity: "error"
then:
function: "oasPathParam"
provide-head-method:
description: "API для скачивания какого-либо файла должно поддерживать метод **HEAD**"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#provide-head-method"
given:
- "$.paths.*"
severity: "warn"
then:
function: "provideHeadMethod"
query-params-camel-case:
description: "Params должны быть в camelCase формате"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#query-params-camel-case"
given:
- "$.paths.*.*.parameters[?(@.in == \"query\")].name"
- "$.paths.*.parameters[?(@.in == \"query\")].name"
- "$.components.parameters.*[?(@.in == \"query\")].name"
severity: "error"
then:
function: "casing"
functionOptions:
type: "camel"
response-error-structure:
description: "Все ответы с ошибками API должны следовать единой структуре с обязательным полем error и детализированной информацией об ошибках"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#response-error-structure"
given: "$"
message: "{{error}}"
severity: "error"
then:
function: "responseErrorStructure"
supported-schema-version:
description: "Спецификация должна быть версии 3+"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#supported-schema-version"
given: "$"
message: "Схема документа не равна 3+"
severity: "error"
then:
- field: "openapi"
function: "truthy"
- field: "openapi"
function: "pattern"
functionOptions:
match: "^3\\.\\d{1}\\.\\d{1}$"
tag-description:
description: "Блок tags должен содержать description"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#tag-description"
given: "$.tags[*]"
severity: "warn"
then:
field: "description"
function: "truthy"
typed-enum:
description: "Каждый элемент Enum должен соответствовать указанному типу"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#typed-enum"
given: "$..[?(@ && @.enum && @.type)]"
severity: "error"
then:
function: "typedEnum"
url-versioning:
description: "Версия должна быть указана в пути запроса, в начале метода, в формате /beta, /v1, /v2 и т.д."
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#url-versioning"
given:
- "$.paths.*~"
severity: "error"
then:
field: "@key"
function: "pattern"
functionOptions:
match: "^/(beta|v\\d+)(?:/.*)?$"
use-most-common-http-codes:
description: "Используйте только наиболее распространенные коды состояния HTTP"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#use-most-common-http-codes"
given:
- "$.paths.*.*.responses.*~"
- "$.paths.*.responses.*~"
severity: "error"
then:
function: "pattern"
functionOptions:
notMatch: "^(205|206|207|301|302|303|307|308|408|417|418|422|424|431|505|507|511)$"
valid-schema-example:
description: "Все схемы должны иметь example"
documentationUrl: "https://gitlabci.raiffeisen.ru/cib/api-guide/-/tree/master/spectral/rules/openapi?ref_type=heads#valid-schema-example"
given:
- "$..content.application/json.schema"
- "$..headers.*.schema"
- "$..parameters.*.schema"
severity: "error"
then:
function: "validSchemaExample"
Every ruleset here is available over the APIs.io API and to AI agents over MCP.