"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; const tslib_1 = require("tslib"); const spectral_formats_1 = require("@stoplight/spectral-formats"); const spectral_functions_1 = require("@stoplight/spectral-functions"); const functions_1 = require("./functions"); const functions_2 = require("../shared/functions"); const serverVariables_1 = (0, tslib_1.__importDefault)(require("../shared/functions/serverVariables")); const ruleset = { documentationUrl: 'https://meta.stoplight.io/docs/spectral/docs/reference/openapi-rules.md', formats: [spectral_formats_1.oas2, spectral_formats_1.oas3, spectral_formats_1.oas3_0, spectral_formats_1.oas3_1], aliases: { PathItem: ['$.paths[*]'], OperationObject: ['#PathItem[get,put,post,delete,options,head,patch,trace]'], SecurityRequirementObject: ['$.security[*]', '#OperationObject.security[*]'], ResponseObject: { targets: [ { formats: [spectral_formats_1.oas2], given: ['#OperationObject.responses[*]', '$.responses[*]'], }, { formats: [spectral_formats_1.oas3], given: ['#OperationObject.responses[*]', '$.components.responses[*]'], }, ], }, LinkObject: { targets: [ { formats: [spectral_formats_1.oas3], given: ['$.components.links[*]', '#ResponseObject.links[*]'], }, ], }, ArrayProperties: { targets: [ { formats: [spectral_formats_1.oas2, spectral_formats_1.oas3_0], given: [ '$..[?(@ && @.type=="array")]', ], }, { formats: [spectral_formats_1.oas3_1], given: [ '$..[?(@ && @.type=="array")]', '$..[?(@ && @.type && @.type.constructor.name === "Array" && @.type.includes("array"))]', ], }, ], }, }, rules: { 'operation-success-response': { description: 'Operation must have at least one "2xx" or "3xx" response.', recommended: true, given: '#OperationObject', then: { field: 'responses', function: functions_1.oasOpSuccessResponse, }, }, 'oas2-operation-formData-consume-check': { description: 'Operations with "in: formData" parameter must include "application/x-www-form-urlencoded" or "multipart/form-data" in their "consumes" property.', recommended: true, formats: [spectral_formats_1.oas2], given: '#OperationObject', then: { function: functions_1.oasOpFormDataConsumeCheck, }, }, 'operation-operationId-unique': { description: 'Every operation must have unique "operationId".', recommended: true, severity: 0, given: '$.paths', then: { function: functions_1.oasOpIdUnique, }, }, 'operation-parameters': { description: 'Operation parameters are unique and non-repeating.', message: '{{error}}', recommended: true, given: '#OperationObject.parameters', then: { function: functions_1.oasOpParams, }, }, 'operation-tag-defined': { description: 'Operation tags must be defined in global tags.', recommended: true, given: '$', then: { function: functions_1.oasTagDefined, }, }, 'path-params': { description: 'Path parameters must be defined and valid.', message: '{{error}}', severity: 0, recommended: true, given: '$.paths', then: { function: functions_1.oasPathParam, }, }, 'contact-properties': { description: 'Contact object must have "name", "url" and "email".', recommended: false, given: '$.info.contact', then: [ { field: 'name', function: spectral_functions_1.truthy, }, { field: 'url', function: spectral_functions_1.truthy, }, { field: 'email', function: spectral_functions_1.truthy, }, ], }, 'duplicated-entry-in-enum': { description: 'Enum values must not have duplicate entry.', severity: 'warn', recommended: true, message: '{{error}}', given: ["$..[?(@property !== 'properties' && @ && @.enum)]"], then: { field: 'enum', function: functions_1.oasSchema, functionOptions: { schema: { type: 'array', uniqueItems: true, }, }, }, }, 'info-contact': { description: 'Info object must have "contact" object.', recommended: true, given: '$', then: { field: 'info.contact', function: spectral_functions_1.truthy, }, }, 'info-description': { description: 'Info "description" must be present and non-empty string.', recommended: true, given: '$', then: { field: 'info.description', function: spectral_functions_1.truthy, }, }, 'info-license': { description: 'Info object must have "license" object.', recommended: false, given: '$', then: { field: 'info.license', function: spectral_functions_1.truthy, }, }, 'license-url': { description: 'License object must include "url".', recommended: false, given: '$', then: { field: 'info.license.url', function: spectral_functions_1.truthy, }, }, 'no-eval-in-markdown': { description: 'Markdown descriptions must not have "eval(".', recommended: true, given: '$..[description,title]', then: { function: spectral_functions_1.pattern, functionOptions: { notMatch: 'eval\\(', }, }, }, 'no-script-tags-in-markdown': { description: 'Markdown descriptions must not have "