UNPKG

openapi-modifier

Version:

This package allows you to automate the process of modifying OpenAPI specifications by applying a set of predefined rules

98 lines (97 loc) 5.05 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.messagesFactory = void 0; const refs_1 = require("../../rules/common/utils/refs"); const getGitHubRuleConfigReadMeLink = (ruleName) => { return `https://github.com/itwillwork/openapi-modifier/blob/main/src/rules/${ruleName}/README.md#config`; }; const getGitHubRuleReadMeLink = (ruleName) => { return `https://github.com/itwillwork/openapi-modifier/blob/main/src/rules/${ruleName}/README.md`; }; const getGitHubConfigReadMeLink = () => { return `https://github.com/itwillwork/openapi-modifier/tree/main?tab=readme-ov-file#%D0%BF%D0%B0%D1%80%D0%B0%D0%BC%D0%B5%D1%82%D1%80%D1%8B-%D0%BA%D0%BE%D0%BD%D1%84%D0%B8%D0%B3%D1%83%D1%80%D0%B0%D1%86%D0%B8%D0%B8`; }; const getGitHubDescriptorWithAllOfReadMeLink = () => { return 'TODO'; }; const getGitHubDescriptorWithAnyOfReadMeLink = () => { return 'TODO'; }; const getGitHubDescriptorWithOneOfReadMeLink = () => { return 'TODO'; }; const getGitHubDescriptorWithRefReadMeLink = () => { return 'TODO'; }; exports.messagesFactory = { failedRun: { emptyPipeline: `Empty pipeline! See config docs: ${getGitHubConfigReadMeLink()}`, failedRunPipelineItem: (item) => { return `Failed to process pipeline item "${JSON.stringify(item)}". See the error description above in the current log.`; } }, ruleNotApply: { failedToParseDescriptor: (ruleMeta, field) => { return `The rule "${ruleMeta.ruleName}" does not apply, failed to parse descriptor "${field}". See the error description above in the current log. Or see rule config docs: ${getGitHubRuleConfigReadMeLink(ruleMeta.ruleName)}`; }, withReason: (ruleMeta, reason) => { return `The rule "${ruleMeta.ruleName}" does not apply, for the reason: ${reason}. See rule docs: ${getGitHubRuleReadMeLink(ruleMeta.ruleName)}`; }, requiredConfigField: (ruleMeta, field) => { return `The rule "${ruleMeta.ruleName}" does not apply, you must specify the "${field}" field of the rule configuration. See rule config docs: ${getGitHubRuleConfigReadMeLink(ruleMeta.ruleName)}`; } }, deprecated: { endpoint: (method, path, description) => { return `Description of the deprecated endpoint ${method} - ${path}: "${description || ''}"`; }, endpointParameter: (method, path, parameterName, parameterIn, description) => { return `Description of the deprecated endpoint ${method} - ${path} parameter ${parameterIn} "${parameterName}": "${description || ''}"`; }, fieldByRef: (propertyKey, description) => { return `Description of the deprecated field by ref "${propertyKey}": "${description || ''}"`; }, field: (propertyKey, description) => { return `Description of the deprecated field "${propertyKey}": "${description || ''}"`; }, component: (componentName, description) => { return `Description of the deprecated component "${componentName}": "${description || ''}"`; }, }, configField: { notUsaged: (field, description) => { return `The "${field}" field of the configuration is not used${description ? `: ${description}` : '.'}`; } }, failedToResolvePath: { conflictRef: (sourcePath, currentObject, lostPath) => { return ` Failed to resolve path "${sourcePath}". Conflict with "$ref": "${JSON.stringify(currentObject)}". Try using a direct descriptor: "${typeof currentObject['$ref'] === "string" ? (0, refs_1.tryExtractRefLastPath)(currentObject['$ref']) : ''}, with lost path: ${lostPath}". See docs about usage "$ref" in descriptors: ${getGitHubDescriptorWithRefReadMeLink()} `; }, conflictOneOf: (sourcePath, currentObject, lostPath) => { return ` Failed to resolve path "${sourcePath}". Conflict with "oneOf": "${JSON.stringify(currentObject)}", with lost path: "${lostPath}". See docs about usage "oneOf" in descriptors: ${getGitHubDescriptorWithOneOfReadMeLink()} `; }, conflictAnyOf: (sourcePath, currentObject, lostPath) => { return ` Failed to resolve path "${sourcePath}". Conflict with "anyOf": "${JSON.stringify(currentObject)}", with lost path: "${lostPath}". See docs about usage "anyOf" in descriptors: ${getGitHubDescriptorWithAnyOfReadMeLink()} `; }, conflictAllOf: (sourcePath, currentObject, lostPath) => { return ` Failed to resolve path "${sourcePath}". Conflict with "allOf": "${JSON.stringify(currentObject)}", with lost path: "${lostPath}". See docs about usage "allOf" in descriptors: ${getGitHubDescriptorWithAllOfReadMeLink()} `; }, } };