@redocly/openapi-core
Advanced tools
Comparing version
export declare const name = "Validate with 50 top-level rules"; | ||
export declare const count = 10; | ||
export declare function setupAsync(): Promise<void>; | ||
export declare function measureAsync(): Promise<import("../..").NormalizedProblem[]>; | ||
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>; | ||
//# sourceMappingURL=lint-with-many-rules.bench.d.ts.map |
@@ -1,15 +0,12 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.count = exports.name = void 0; | ||
exports.setupAsync = setupAsync; | ||
exports.measureAsync = measureAsync; | ||
const fs_1 = require("fs"); | ||
const path_1 = require("path"); | ||
const lint_1 = require("../../lint"); | ||
const resolve_1 = require("../../resolve"); | ||
const utils_1 = require("../utils"); | ||
exports.name = 'Validate with 50 top-level rules'; | ||
exports.count = 10; | ||
const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
import * as fs from 'node:fs'; | ||
import * as path from 'node:path'; | ||
import { lintDocument } from '../../lint.js'; | ||
import { BaseResolver } from '../../resolve.js'; | ||
import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js'; | ||
import url from 'node:url'; | ||
const __internalDirname = path.dirname(url.fileURLToPath(import.meta.url ?? __dirname)); | ||
export const name = 'Validate with 50 top-level rules'; | ||
export const count = 10; | ||
const rebillyDefinitionRef = path.resolve(path.join(__internalDirname, 'rebilly.yaml')); | ||
const rebillyDocument = parseYamlToDocument(fs.readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
const ruleset = {}; | ||
@@ -29,8 +26,8 @@ for (let i = 0; i < 50; i++) { | ||
let config; | ||
async function setupAsync() { | ||
config = await (0, utils_1.makeConfigForRuleset)(ruleset); | ||
export async function setupAsync() { | ||
config = await makeConfigForRuleset(ruleset); | ||
} | ||
function measureAsync() { | ||
return (0, lint_1.lintDocument)({ | ||
externalRefResolver: new resolve_1.BaseResolver(), | ||
export function measureAsync() { | ||
return lintDocument({ | ||
externalRefResolver: new BaseResolver(), | ||
document: rebillyDocument, | ||
@@ -40,1 +37,2 @@ config, | ||
} | ||
//# sourceMappingURL=lint-with-many-rules.bench.js.map |
export declare const name = "Validate with single nested rule"; | ||
export declare const count = 10; | ||
export declare function setupAsync(): Promise<void>; | ||
export declare function measureAsync(): Promise<import("../..").NormalizedProblem[]>; | ||
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>; | ||
//# sourceMappingURL=lint-with-nested-rule.bench.d.ts.map |
@@ -1,15 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.count = exports.name = void 0; | ||
exports.setupAsync = setupAsync; | ||
exports.measureAsync = measureAsync; | ||
const fs_1 = require("fs"); | ||
const path_1 = require("path"); | ||
const lint_1 = require("../../lint"); | ||
const resolve_1 = require("../../resolve"); | ||
const utils_1 = require("../utils"); | ||
exports.name = 'Validate with single nested rule'; | ||
exports.count = 10; | ||
const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
import { readFileSync } from 'fs'; | ||
import { join as pathJoin, resolve as pathResolve } from 'path'; | ||
import { lintDocument } from '../../lint.js'; | ||
import { BaseResolver } from '../../resolve.js'; | ||
import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js'; | ||
export const name = 'Validate with single nested rule'; | ||
export const count = 10; | ||
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
const visitor = { | ||
@@ -35,8 +30,8 @@ test: () => { | ||
let config; | ||
async function setupAsync() { | ||
config = await (0, utils_1.makeConfigForRuleset)(visitor); | ||
export async function setupAsync() { | ||
config = await makeConfigForRuleset(visitor); | ||
} | ||
function measureAsync() { | ||
return (0, lint_1.lintDocument)({ | ||
externalRefResolver: new resolve_1.BaseResolver(), | ||
export function measureAsync() { | ||
return lintDocument({ | ||
externalRefResolver: new BaseResolver(), | ||
document: rebillyDocument, | ||
@@ -46,1 +41,2 @@ config, | ||
} | ||
//# sourceMappingURL=lint-with-nested-rule.bench.js.map |
export declare const name = "Validate with no rules"; | ||
export declare const count = 10; | ||
export declare function setupAsync(): Promise<void>; | ||
export declare function measureAsync(): Promise<import("../..").NormalizedProblem[]>; | ||
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>; | ||
//# sourceMappingURL=lint-with-no-rules.bench.d.ts.map |
@@ -1,22 +0,17 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.count = exports.name = void 0; | ||
exports.setupAsync = setupAsync; | ||
exports.measureAsync = measureAsync; | ||
const fs_1 = require("fs"); | ||
const path_1 = require("path"); | ||
const lint_1 = require("../../lint"); | ||
const resolve_1 = require("../../resolve"); | ||
const utils_1 = require("../utils"); | ||
exports.name = 'Validate with no rules'; | ||
exports.count = 10; | ||
const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
import { readFileSync } from 'fs'; | ||
import { join as pathJoin, resolve as pathResolve } from 'path'; | ||
import { lintDocument } from '../../lint.js'; | ||
import { BaseResolver } from '../../resolve.js'; | ||
import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js'; | ||
export const name = 'Validate with no rules'; | ||
export const count = 10; | ||
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
let config; | ||
async function setupAsync() { | ||
config = await (0, utils_1.makeConfigForRuleset)({}); | ||
export async function setupAsync() { | ||
config = await makeConfigForRuleset({}); | ||
} | ||
function measureAsync() { | ||
return (0, lint_1.lintDocument)({ | ||
externalRefResolver: new resolve_1.BaseResolver(), | ||
export function measureAsync() { | ||
return lintDocument({ | ||
externalRefResolver: new BaseResolver(), | ||
document: rebillyDocument, | ||
@@ -26,1 +21,2 @@ config, | ||
} | ||
//# sourceMappingURL=lint-with-no-rules.bench.js.map |
export declare const name = "Validate with single top-level rule and report"; | ||
export declare const count = 10; | ||
export declare function setupAsync(): Promise<void>; | ||
export declare function measureAsync(): Promise<import("../..").NormalizedProblem[]>; | ||
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>; | ||
//# sourceMappingURL=lint-with-top-level-rule-report.bench.d.ts.map |
@@ -1,18 +0,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.count = exports.name = void 0; | ||
exports.setupAsync = setupAsync; | ||
exports.measureAsync = measureAsync; | ||
const fs_1 = require("fs"); | ||
const path_1 = require("path"); | ||
const lint_1 = require("../../lint"); | ||
const resolve_1 = require("../../resolve"); | ||
const utils_1 = require("../utils"); | ||
exports.name = 'Validate with single top-level rule and report'; | ||
exports.count = 10; | ||
const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
import { readFileSync } from 'fs'; | ||
import { join as pathJoin, resolve as pathResolve } from 'path'; | ||
import { lintDocument } from '../../lint.js'; | ||
import { BaseResolver } from '../../resolve.js'; | ||
import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js'; | ||
export const name = 'Validate with single top-level rule and report'; | ||
export const count = 10; | ||
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
let config; | ||
async function setupAsync() { | ||
config = await (0, utils_1.makeConfigForRuleset)({ | ||
export async function setupAsync() { | ||
config = await makeConfigForRuleset({ | ||
test: () => { | ||
@@ -31,5 +26,5 @@ return { | ||
} | ||
function measureAsync() { | ||
return (0, lint_1.lintDocument)({ | ||
externalRefResolver: new resolve_1.BaseResolver(), | ||
export function measureAsync() { | ||
return lintDocument({ | ||
externalRefResolver: new BaseResolver(), | ||
document: rebillyDocument, | ||
@@ -39,1 +34,2 @@ config, | ||
} | ||
//# sourceMappingURL=lint-with-top-level-rule-report.bench.js.map |
export declare const name = "Validate with single top-level rule"; | ||
export declare const count = 10; | ||
export declare function setupAsync(): Promise<void>; | ||
export declare function measureAsync(): Promise<import("../..").NormalizedProblem[]>; | ||
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>; | ||
//# sourceMappingURL=lint-with-top-level-rule.bench.d.ts.map |
@@ -1,18 +0,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.count = exports.name = void 0; | ||
exports.setupAsync = setupAsync; | ||
exports.measureAsync = measureAsync; | ||
const fs_1 = require("fs"); | ||
const path_1 = require("path"); | ||
const lint_1 = require("../../lint"); | ||
const resolve_1 = require("../../resolve"); | ||
const utils_1 = require("../utils"); | ||
exports.name = 'Validate with single top-level rule'; | ||
exports.count = 10; | ||
const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
import { readFileSync } from 'fs'; | ||
import { join as pathJoin, resolve as pathResolve } from 'path'; | ||
import { lintDocument } from '../../lint.js'; | ||
import { BaseResolver } from '../../resolve.js'; | ||
import { parseYamlToDocument, makeConfigForRuleset } from '../utils.js'; | ||
export const name = 'Validate with single top-level rule'; | ||
export const count = 10; | ||
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
let config; | ||
async function setupAsync() { | ||
config = await (0, utils_1.makeConfigForRuleset)({ | ||
export async function setupAsync() { | ||
config = await makeConfigForRuleset({ | ||
test: () => { | ||
@@ -30,5 +25,5 @@ let count = 0; | ||
} | ||
function measureAsync() { | ||
return (0, lint_1.lintDocument)({ | ||
externalRefResolver: new resolve_1.BaseResolver(), | ||
export function measureAsync() { | ||
return lintDocument({ | ||
externalRefResolver: new BaseResolver(), | ||
document: rebillyDocument, | ||
@@ -38,1 +33,2 @@ config, | ||
} | ||
//# sourceMappingURL=lint-with-top-level-rule.bench.js.map |
export declare const name = "Validate with recommended rules"; | ||
export declare const count = 10; | ||
export declare function measureAsync(): Promise<import("../..").NormalizedProblem[]>; | ||
export declare function measureAsync(): Promise<import("../../walk.js").NormalizedProblem[]>; | ||
//# sourceMappingURL=recommended-oas3.bench.d.ts.map |
@@ -1,21 +0,18 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.count = exports.name = void 0; | ||
exports.measureAsync = measureAsync; | ||
const fs_1 = require("fs"); | ||
const path_1 = require("path"); | ||
const lint_1 = require("../../lint"); | ||
const config_1 = require("../../config"); | ||
const resolve_1 = require("../../resolve"); | ||
const utils_1 = require("../utils"); | ||
exports.name = 'Validate with recommended rules'; | ||
exports.count = 10; | ||
const rebillyDefinitionRef = (0, path_1.resolve)((0, path_1.join)(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
function measureAsync() { | ||
return (0, lint_1.lintDocument)({ | ||
externalRefResolver: new resolve_1.BaseResolver(), | ||
import { readFileSync } from 'fs'; | ||
import { join as pathJoin, resolve as pathResolve } from 'path'; | ||
import { lintDocument } from '../../lint.js'; | ||
import { StyleguideConfig, defaultPlugin, resolvePreset } from '../../config/index.js'; | ||
import { BaseResolver } from '../../resolve.js'; | ||
import { parseYamlToDocument } from '../utils.js'; | ||
export const name = 'Validate with recommended rules'; | ||
export const count = 10; | ||
const rebillyDefinitionRef = pathResolve(pathJoin(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
export function measureAsync() { | ||
return lintDocument({ | ||
externalRefResolver: new BaseResolver(), | ||
document: rebillyDocument, | ||
config: new config_1.StyleguideConfig((0, config_1.resolvePreset)('recommended', [config_1.defaultPlugin])), | ||
config: new StyleguideConfig(resolvePreset('recommended', [defaultPlugin])), | ||
}); | ||
} | ||
//# sourceMappingURL=recommended-oas3.bench.js.map |
export declare const name = "Resolve with no external refs"; | ||
export declare const count = 10; | ||
export declare function measureAsync(): Promise<import("../../resolve").ResolvedRefMap>; | ||
export declare function measureAsync(): Promise<import("../../resolve.js").ResolvedRefMap>; | ||
//# sourceMappingURL=resolve-with-no-external.bench.d.ts.map |
@@ -1,22 +0,19 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.count = exports.name = void 0; | ||
exports.measureAsync = measureAsync; | ||
const path = require("path"); | ||
const fs_1 = require("fs"); | ||
const resolve_1 = require("../../resolve"); | ||
const utils_1 = require("../utils"); | ||
const oas3_1 = require("../../types/oas3"); | ||
const types_1 = require("../../types"); | ||
exports.name = 'Resolve with no external refs'; | ||
exports.count = 10; | ||
import * as path from 'path'; | ||
import { readFileSync } from 'fs'; | ||
import { resolveDocument, BaseResolver } from '../../resolve.js'; | ||
import { parseYamlToDocument } from '../utils.js'; | ||
import { Oas3Types } from '../../types/oas3.js'; | ||
import { normalizeTypes } from '../../types/index.js'; | ||
export const name = 'Resolve with no external refs'; | ||
export const count = 10; | ||
const rebillyDefinitionRef = path.resolve(path.join(__dirname, 'rebilly.yaml')); | ||
const rebillyDocument = (0, utils_1.parseYamlToDocument)((0, fs_1.readFileSync)(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
const externalRefResolver = new resolve_1.BaseResolver(); | ||
function measureAsync() { | ||
return (0, resolve_1.resolveDocument)({ | ||
const rebillyDocument = parseYamlToDocument(readFileSync(rebillyDefinitionRef, 'utf-8'), rebillyDefinitionRef); | ||
const externalRefResolver = new BaseResolver(); | ||
export function measureAsync() { | ||
return resolveDocument({ | ||
rootDocument: rebillyDocument, | ||
externalRefResolver, | ||
rootType: (0, types_1.normalizeTypes)(oas3_1.Oas3Types).Root, | ||
rootType: normalizeTypes(Oas3Types).Root, | ||
}); | ||
} | ||
//# sourceMappingURL=resolve-with-no-external.bench.js.map |
@@ -1,6 +0,7 @@ | ||
import { StyleguideConfig } from '../config'; | ||
import type { Document } from '../resolve'; | ||
import type { Oas3RuleSet } from '../oas-types'; | ||
import type { Plugin } from '../config/types'; | ||
import { StyleguideConfig } from '../config/index.js'; | ||
import type { Document } from '../resolve.js'; | ||
import type { Oas3RuleSet } from '../oas-types.js'; | ||
import type { Plugin } from '../config/types.js'; | ||
export declare function parseYamlToDocument(body: string, absoluteRef?: string): Document; | ||
export declare function makeConfigForRuleset(rules: Oas3RuleSet, plugin?: Partial<Plugin>): Promise<StyleguideConfig>; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -1,15 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseYamlToDocument = parseYamlToDocument; | ||
exports.makeConfigForRuleset = makeConfigForRuleset; | ||
const js_yaml_1 = require("../js-yaml"); | ||
const resolve_1 = require("../resolve"); | ||
const config_1 = require("../config"); | ||
function parseYamlToDocument(body, absoluteRef = '') { | ||
import { parseYaml } from '../js-yaml/index.js'; | ||
import { Source } from '../resolve.js'; | ||
import { StyleguideConfig, mergeExtends, resolvePlugins } from '../config/index.js'; | ||
export function parseYamlToDocument(body, absoluteRef = '') { | ||
return { | ||
source: new resolve_1.Source(absoluteRef, body), | ||
parsed: (0, js_yaml_1.parseYaml)(body, { filename: absoluteRef }), | ||
source: new Source(absoluteRef, body), | ||
parsed: parseYaml(body, { filename: absoluteRef }), | ||
}; | ||
} | ||
async function makeConfigForRuleset(rules, plugin) { | ||
export async function makeConfigForRuleset(rules, plugin) { | ||
const rulesConf = {}; | ||
@@ -21,3 +17,3 @@ const ruleId = 'test'; | ||
const extendConfigs = [ | ||
(await (0, config_1.resolvePlugins)([ | ||
(await resolvePlugins([ | ||
{ | ||
@@ -33,4 +29,5 @@ ...plugin, | ||
} | ||
const styleguide = (0, config_1.mergeExtends)(extendConfigs); | ||
return new config_1.StyleguideConfig(styleguide); | ||
const styleguide = mergeExtends(extendConfigs); | ||
return new StyleguideConfig(styleguide); | ||
} | ||
//# sourceMappingURL=utils.js.map |
@@ -1,8 +0,8 @@ | ||
import { BaseResolver } from './resolve'; | ||
import { SpecMajorVersion } from './oas-types'; | ||
import type { NormalizedNodeType, NodeType } from './types'; | ||
import type { NormalizedProblem } from './walk'; | ||
import type { Config, StyleguideConfig } from './config'; | ||
import type { Document, ResolvedRefMap } from './resolve'; | ||
import type { CollectFn } from './utils'; | ||
import { BaseResolver } from './resolve.js'; | ||
import { SpecMajorVersion } from './oas-types.js'; | ||
import type { NormalizedNodeType, NodeType } from './types/index.js'; | ||
import type { NormalizedProblem } from './walk.js'; | ||
import type { Config, StyleguideConfig } from './config/index.js'; | ||
import type { Document, ResolvedRefMap } from './resolve.js'; | ||
import type { CollectFn } from './utils.js'; | ||
export declare enum OasVersion { | ||
@@ -18,3 +18,2 @@ Version2 = "oas2", | ||
base?: string | null; | ||
skipRedoclyRegistryRefs?: boolean; | ||
removeUnusedComponents?: boolean; | ||
@@ -47,3 +46,2 @@ keepUrlRefs?: boolean; | ||
dereference?: boolean; | ||
skipRedoclyRegistryRefs?: boolean; | ||
removeUnusedComponents?: boolean; | ||
@@ -53,1 +51,2 @@ keepUrlRefs?: boolean; | ||
export declare function mapTypeToComponent(typeName: string, version: SpecMajorVersion): "definitions" | "links" | "responses" | "parameters" | "examples" | "headers" | "schemas" | "requestBodies" | "securitySchemes" | "callbacks" | null; | ||
//# sourceMappingURL=bundle.d.ts.map |
@@ -1,23 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OasVersion = void 0; | ||
exports.bundleConfig = bundleConfig; | ||
exports.bundle = bundle; | ||
exports.bundleFromString = bundleFromString; | ||
exports.bundleDocument = bundleDocument; | ||
exports.mapTypeToComponent = mapTypeToComponent; | ||
const resolve_1 = require("./resolve"); | ||
const visitors_1 = require("./visitors"); | ||
const types_1 = require("./types"); | ||
const walk_1 = require("./walk"); | ||
const oas_types_1 = require("./oas-types"); | ||
const ref_utils_1 = require("./ref-utils"); | ||
const rules_1 = require("./config/rules"); | ||
const no_unresolved_refs_1 = require("./rules/no-unresolved-refs"); | ||
const utils_1 = require("./utils"); | ||
const domains_1 = require("./redocly/domains"); | ||
const remove_unused_components_1 = require("./decorators/oas2/remove-unused-components"); | ||
const remove_unused_components_2 = require("./decorators/oas3/remove-unused-components"); | ||
const redocly_yaml_1 = require("./types/redocly-yaml"); | ||
var OasVersion; | ||
import { BaseResolver, resolveDocument, makeRefId, makeDocumentFromString } from './resolve.js'; | ||
import { normalizeVisitors } from './visitors.js'; | ||
import { normalizeTypes } from './types/index.js'; | ||
import { walkDocument } from './walk.js'; | ||
import { detectSpec, getTypes, getMajorSpecVersion, SpecMajorVersion, SpecVersion, } from './oas-types.js'; | ||
import { isAbsoluteUrl, isExternalValue, isRef, refBaseName } from './ref-utils.js'; | ||
import { initRules } from './config/rules.js'; | ||
import { reportUnresolvedRef } from './rules/no-unresolved-refs.js'; | ||
import { dequal, isPlainObject, isTruthy } from './utils.js'; | ||
import { RemoveUnusedComponents as RemoveUnusedComponentsOas2 } from './decorators/oas2/remove-unused-components.js'; | ||
import { RemoveUnusedComponents as RemoveUnusedComponentsOas3 } from './decorators/oas3/remove-unused-components.js'; | ||
import { NormalizedConfigTypes } from './types/redocly-yaml.js'; | ||
export var OasVersion; | ||
(function (OasVersion) { | ||
@@ -27,4 +18,4 @@ OasVersion["Version2"] = "oas2"; | ||
OasVersion["Version3_1"] = "oas3_1"; | ||
})(OasVersion || (exports.OasVersion = OasVersion = {})); | ||
const bundleVisitor = (0, visitors_1.normalizeVisitors)([ | ||
})(OasVersion || (OasVersion = {})); | ||
const bundleVisitor = normalizeVisitors([ | ||
{ | ||
@@ -41,13 +32,13 @@ severity: 'error', | ||
}, | ||
], redocly_yaml_1.NormalizedConfigTypes); | ||
async function bundleConfig(document, resolvedRefMap) { | ||
], NormalizedConfigTypes); | ||
export async function bundleConfig(document, resolvedRefMap) { | ||
const ctx = { | ||
problems: [], | ||
oasVersion: oas_types_1.SpecVersion.OAS3_0, | ||
oasVersion: SpecVersion.OAS3_0, | ||
refTypes: new Map(), | ||
visitorsData: {}, | ||
}; | ||
(0, walk_1.walkDocument)({ | ||
walkDocument({ | ||
document, | ||
rootType: redocly_yaml_1.NormalizedConfigTypes.ConfigRoot, | ||
rootType: NormalizedConfigTypes.ConfigRoot, | ||
normalizedVisitors: bundleVisitor, | ||
@@ -59,4 +50,4 @@ resolvedRefMap, | ||
} | ||
async function bundle(opts) { | ||
const { ref, doc, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve), base = null, } = opts; | ||
export async function bundle(opts) { | ||
const { ref, doc, externalRefResolver = new BaseResolver(opts.config.resolve), base = null, } = opts; | ||
if (!(ref || doc)) { | ||
@@ -77,5 +68,5 @@ throw new Error('Document or reference is required.\n'); | ||
} | ||
async function bundleFromString(opts) { | ||
const { source, absoluteRef, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts; | ||
const document = (0, resolve_1.makeDocumentFromString)(source, absoluteRef || '/'); | ||
export async function bundleFromString(opts) { | ||
const { source, absoluteRef, externalRefResolver = new BaseResolver(opts.config.resolve) } = opts; | ||
const document = makeDocumentFromString(source, absoluteRef || '/'); | ||
return bundleDocument({ | ||
@@ -88,10 +79,10 @@ document, | ||
} | ||
async function bundleDocument(opts) { | ||
const { document, config, customTypes, externalRefResolver, dereference = false, skipRedoclyRegistryRefs = false, removeUnusedComponents = false, keepUrlRefs = false, } = opts; | ||
const specVersion = (0, oas_types_1.detectSpec)(document.parsed); | ||
const specMajorVersion = (0, oas_types_1.getMajorSpecVersion)(specVersion); | ||
export async function bundleDocument(opts) { | ||
const { document, config, customTypes, externalRefResolver, dereference = false, removeUnusedComponents = false, keepUrlRefs = false, } = opts; | ||
const specVersion = detectSpec(document.parsed); | ||
const specMajorVersion = getMajorSpecVersion(specVersion); | ||
const rules = config.getRulesForSpecVersion(specMajorVersion); | ||
const types = (0, types_1.normalizeTypes)(config.extendTypes(customTypes ?? (0, oas_types_1.getTypes)(specVersion), specVersion), config); | ||
const preprocessors = (0, rules_1.initRules)(rules, config, 'preprocessors', specVersion); | ||
const decorators = (0, rules_1.initRules)(rules, config, 'decorators', specVersion); | ||
const types = normalizeTypes(config.extendTypes(customTypes ?? getTypes(specVersion), specVersion), config); | ||
const preprocessors = initRules(rules, config, 'preprocessors', specVersion); | ||
const decorators = initRules(rules, config, 'decorators', specVersion); | ||
const ctx = { | ||
@@ -107,8 +98,8 @@ problems: [], | ||
ruleId: 'remove-unused-components', | ||
visitor: specMajorVersion === oas_types_1.SpecMajorVersion.OAS2 | ||
? (0, remove_unused_components_1.RemoveUnusedComponents)({}) | ||
: (0, remove_unused_components_2.RemoveUnusedComponents)({}), | ||
visitor: specMajorVersion === SpecMajorVersion.OAS2 | ||
? RemoveUnusedComponentsOas2({}) | ||
: RemoveUnusedComponentsOas3({}), | ||
}); | ||
} | ||
let resolvedRefMap = await (0, resolve_1.resolveDocument)({ | ||
let resolvedRefMap = await resolveDocument({ | ||
rootDocument: document, | ||
@@ -120,10 +111,10 @@ rootType: types.Root, | ||
// Make additional pass to resolve refs defined in preprocessors. | ||
(0, walk_1.walkDocument)({ | ||
walkDocument({ | ||
document, | ||
rootType: types.Root, | ||
normalizedVisitors: (0, visitors_1.normalizeVisitors)(preprocessors, types), | ||
normalizedVisitors: normalizeVisitors(preprocessors, types), | ||
resolvedRefMap, | ||
ctx, | ||
}); | ||
resolvedRefMap = await (0, resolve_1.resolveDocument)({ | ||
resolvedRefMap = await resolveDocument({ | ||
rootDocument: document, | ||
@@ -134,11 +125,11 @@ rootType: types.Root, | ||
} | ||
const bundleVisitor = (0, visitors_1.normalizeVisitors)([ | ||
const bundleVisitor = normalizeVisitors([ | ||
{ | ||
severity: 'error', | ||
ruleId: 'bundler', | ||
visitor: makeBundleVisitor(specMajorVersion, dereference, skipRedoclyRegistryRefs, document, resolvedRefMap, keepUrlRefs), | ||
visitor: makeBundleVisitor(specMajorVersion, dereference, document, resolvedRefMap, keepUrlRefs), | ||
}, | ||
...decorators, | ||
], types); | ||
(0, walk_1.walkDocument)({ | ||
walkDocument({ | ||
document, | ||
@@ -159,5 +150,5 @@ rootType: types.Root, | ||
} | ||
function mapTypeToComponent(typeName, version) { | ||
export function mapTypeToComponent(typeName, version) { | ||
switch (version) { | ||
case oas_types_1.SpecMajorVersion.OAS3: | ||
case SpecMajorVersion.OAS3: | ||
switch (typeName) { | ||
@@ -185,3 +176,3 @@ case 'Schema': | ||
} | ||
case oas_types_1.SpecMajorVersion.OAS2: | ||
case SpecMajorVersion.OAS2: | ||
switch (typeName) { | ||
@@ -197,3 +188,3 @@ case 'Schema': | ||
} | ||
case oas_types_1.SpecMajorVersion.Async2: | ||
case SpecMajorVersion.Async2: | ||
switch (typeName) { | ||
@@ -207,3 +198,3 @@ case 'Schema': | ||
} | ||
case oas_types_1.SpecMajorVersion.Async3: | ||
case SpecMajorVersion.Async3: | ||
switch (typeName) { | ||
@@ -217,3 +208,3 @@ case 'Schema': | ||
} | ||
case oas_types_1.SpecMajorVersion.Arazzo1: | ||
case SpecMajorVersion.Arazzo1: | ||
switch (typeName) { | ||
@@ -226,3 +217,3 @@ case 'Root.workflows_items.parameters_items': | ||
} | ||
case oas_types_1.SpecMajorVersion.Overlay1: | ||
case SpecMajorVersion.Overlay1: | ||
switch (typeName) { | ||
@@ -235,3 +226,3 @@ default: | ||
function replaceRef(ref, resolved, ctx) { | ||
if (!(0, utils_1.isPlainObject)(resolved.node)) { | ||
if (!isPlainObject(resolved.node)) { | ||
ctx.parent[ctx.key] = resolved.node; | ||
@@ -248,3 +239,3 @@ } | ||
// function oas3Move | ||
function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDocument, resolvedRefMap, keepUrlRefs) { | ||
function makeBundleVisitor(version, dereference, rootDocument, resolvedRefMap, keepUrlRefs) { | ||
let components; | ||
@@ -256,3 +247,3 @@ let rootLocation; | ||
if (!resolved.location || resolved.node === undefined) { | ||
(0, no_unresolved_refs_1.reportUnresolvedRef)(resolved, ctx.report, ctx.location); | ||
reportUnresolvedRef(resolved, ctx.report, ctx.location); | ||
return; | ||
@@ -266,9 +257,5 @@ } | ||
} | ||
// do not bundle registry URL before push, otherwise we can't record dependencies | ||
if (skipRedoclyRegistryRefs && (0, domains_1.isRedoclyRegistryURL)(node.$ref)) { | ||
if (keepUrlRefs && isAbsoluteUrl(node.$ref)) { | ||
return; | ||
} | ||
if (keepUrlRefs && (0, ref_utils_1.isAbsoluteUrl)(node.$ref)) { | ||
return; | ||
} | ||
const componentType = mapTypeToComponent(ctx.type.name, version); | ||
@@ -292,9 +279,9 @@ if (!componentType) { | ||
leave(node, ctx) { | ||
if ((0, ref_utils_1.isExternalValue)(node) && node.value === undefined) { | ||
if (isExternalValue(node) && node.value === undefined) { | ||
const resolved = ctx.resolve({ $ref: node.externalValue }); | ||
if (!resolved.location || resolved.node === undefined) { | ||
(0, no_unresolved_refs_1.reportUnresolvedRef)(resolved, ctx.report, ctx.location); | ||
reportUnresolvedRef(resolved, ctx.report, ctx.location); | ||
return; | ||
} | ||
if (keepUrlRefs && (0, ref_utils_1.isAbsoluteUrl)(node.externalValue)) { | ||
if (keepUrlRefs && isAbsoluteUrl(node.externalValue)) { | ||
return; | ||
@@ -310,15 +297,15 @@ } | ||
rootLocation = ctx.location; | ||
if (version === oas_types_1.SpecMajorVersion.OAS3) { | ||
if (version === SpecMajorVersion.OAS3) { | ||
components = root.components = root.components || {}; | ||
} | ||
else if (version === oas_types_1.SpecMajorVersion.OAS2) { | ||
else if (version === SpecMajorVersion.OAS2) { | ||
components = root; | ||
} | ||
else if (version === oas_types_1.SpecMajorVersion.Async2) { | ||
else if (version === SpecMajorVersion.Async2) { | ||
components = root.components = root.components || {}; | ||
} | ||
else if (version === oas_types_1.SpecMajorVersion.Async3) { | ||
else if (version === SpecMajorVersion.Async3) { | ||
components = root.components = root.components || {}; | ||
} | ||
else if (version === oas_types_1.SpecMajorVersion.Arazzo1) { | ||
else if (version === SpecMajorVersion.Arazzo1) { | ||
components = root.components = root.components || {}; | ||
@@ -329,3 +316,3 @@ } | ||
}; | ||
if (version === oas_types_1.SpecMajorVersion.OAS3) { | ||
if (version === SpecMajorVersion.OAS3) { | ||
visitor.DiscriminatorMapping = { | ||
@@ -337,3 +324,3 @@ leave(mapping, ctx) { | ||
if (!resolved.location || resolved.node === undefined) { | ||
(0, no_unresolved_refs_1.reportUnresolvedRef)(resolved, ctx.report, ctx.location.child(name)); | ||
reportUnresolvedRef(resolved, ctx.report, ctx.location.child(name)); | ||
return; | ||
@@ -348,3 +335,3 @@ } | ||
function resolveBundledComponent(node, resolved, ctx) { | ||
const newRefId = (0, resolve_1.makeRefId)(ctx.location.source.absoluteRef, node.$ref); | ||
const newRefId = makeRefId(ctx.location.source.absoluteRef, node.$ref); | ||
resolvedRefMap.set(newRefId, { | ||
@@ -362,5 +349,5 @@ document: rootDocument, | ||
components[componentType][name] = target.node; | ||
if (version === oas_types_1.SpecMajorVersion.OAS3 || | ||
version === oas_types_1.SpecMajorVersion.Async2 || | ||
version === oas_types_1.SpecMajorVersion.Async3) { | ||
if (version === SpecMajorVersion.OAS3 || | ||
version === SpecMajorVersion.Async2 || | ||
version === SpecMajorVersion.Async3) { | ||
return `#/components/${componentType}/${name}`; | ||
@@ -373,3 +360,3 @@ } | ||
function isEqualOrEqualRef(node, target, ctx) { | ||
if ((0, ref_utils_1.isRef)(node) && | ||
if (isRef(node) && | ||
ctx.resolve(node, rootLocation.absolutePointer).location?.absolutePointer === | ||
@@ -379,3 +366,3 @@ target.location.absolutePointer) { | ||
} | ||
return (0, utils_1.dequal)(node, target.node); | ||
return dequal(node, target.node); | ||
} | ||
@@ -386,3 +373,3 @@ function getComponentName(target, componentType, ctx) { | ||
let name = ''; | ||
const refParts = pointer.slice(2).split('/').filter(utils_1.isTruthy); // slice(2) removes "#/" | ||
const refParts = pointer.slice(2).split('/').filter(isTruthy); // slice(2) removes "#/" | ||
while (refParts.length > 0) { | ||
@@ -396,3 +383,3 @@ name = refParts.pop() + (name ? `-${name}` : ''); | ||
} | ||
name = (0, ref_utils_1.refBaseName)(fileRef) + (name ? `_${name}` : ''); | ||
name = refBaseName(fileRef) + (name ? `_${name}` : ''); | ||
if (!componentsGroup[name] || isEqualOrEqualRef(componentsGroup[name], target, ctx)) { | ||
@@ -418,1 +405,2 @@ return name; | ||
} | ||
//# sourceMappingURL=bundle.js.map |
@@ -1,3 +0,4 @@ | ||
import type { PluginStyleguideConfig } from './types'; | ||
import type { PluginStyleguideConfig } from './types.js'; | ||
declare const all: PluginStyleguideConfig<'built-in'>; | ||
export default all; | ||
//# sourceMappingURL=all.d.ts.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const all = { | ||
@@ -233,2 +231,3 @@ rules: { | ||
}; | ||
exports.default = all; | ||
export default all; | ||
//# sourceMappingURL=all.js.map |
@@ -1,3 +0,4 @@ | ||
import type { StyleguideRawConfig, Plugin } from './types'; | ||
import type { StyleguideRawConfig, Plugin } from './types.js'; | ||
export declare const builtInConfigs: Record<string, StyleguideRawConfig>; | ||
export declare const defaultPlugin: Plugin<'built-in'>; | ||
//# sourceMappingURL=builtIn.d.ts.map |
@@ -1,58 +0,53 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.defaultPlugin = exports.builtInConfigs = void 0; | ||
const recommended_1 = require("./recommended"); | ||
const recommended_strict_1 = require("./recommended-strict"); | ||
const all_1 = require("./all"); | ||
const minimal_1 = require("./minimal"); | ||
const spec_1 = require("./spec"); | ||
const oas3_1 = require("../rules/oas3"); | ||
const oas2_1 = require("../rules/oas2"); | ||
const async2_1 = require("../rules/async2"); | ||
const async3_1 = require("../rules/async3"); | ||
const arazzo_1 = require("../rules/arazzo"); | ||
const overlay1_1 = require("../rules/overlay1"); | ||
const oas3_2 = require("../decorators/oas3"); | ||
const oas2_2 = require("../decorators/oas2"); | ||
const async2_2 = require("../decorators/async2"); | ||
const async3_2 = require("../decorators/async3"); | ||
const arazzo_2 = require("../decorators/arazzo"); | ||
const overlay1_2 = require("../decorators/overlay1"); | ||
exports.builtInConfigs = { | ||
recommended: recommended_1.default, | ||
'recommended-strict': recommended_strict_1.default, | ||
minimal: minimal_1.default, | ||
all: all_1.default, | ||
spec: spec_1.default, | ||
'redocly-registry': { | ||
decorators: { 'registry-dependencies': 'on' }, | ||
}, | ||
import recommended from './recommended.js'; | ||
import recommendedStrict from './recommended-strict.js'; | ||
import all from './all.js'; | ||
import minimal from './minimal.js'; | ||
import spec from './spec.js'; | ||
import { rules as oas3Rules, preprocessors as oas3Preprocessors } from '../rules/oas3/index.js'; | ||
import { rules as oas2Rules, preprocessors as oas2Preprocessors } from '../rules/oas2/index.js'; | ||
import { rules as async2Rules, preprocessors as async2Preprocessors, } from '../rules/async2/index.js'; | ||
import { rules as async3Rules, preprocessors as async3Preprocessors, } from '../rules/async3/index.js'; | ||
import { rules as arazzo1Rules, preprocessors as arazzoPreprocessors, } from '../rules/arazzo/index.js'; | ||
import { rules as overlay1Rules, preprocessors as overlay1Preprocessors, } from '../rules/overlay1/index.js'; | ||
import { decorators as oas3Decorators } from '../decorators/oas3/index.js'; | ||
import { decorators as oas2Decorators } from '../decorators/oas2/index.js'; | ||
import { decorators as async2Decorators } from '../decorators/async2/index.js'; | ||
import { decorators as async3Decorators } from '../decorators/async3/index.js'; | ||
import { decorators as arazzo1Decorators } from '../decorators/arazzo/index.js'; | ||
import { decorators as overlay1Decorators } from '../decorators/overlay1/index.js'; | ||
export const builtInConfigs = { | ||
recommended, | ||
'recommended-strict': recommendedStrict, | ||
minimal, | ||
all, | ||
spec, | ||
}; | ||
exports.defaultPlugin = { | ||
export const defaultPlugin = { | ||
id: '', // default plugin doesn't have id | ||
rules: { | ||
oas3: oas3_1.rules, | ||
oas2: oas2_1.rules, | ||
async2: async2_1.rules, | ||
async3: async3_1.rules, | ||
arazzo1: arazzo_1.rules, | ||
overlay1: overlay1_1.rules, | ||
oas3: oas3Rules, | ||
oas2: oas2Rules, | ||
async2: async2Rules, | ||
async3: async3Rules, | ||
arazzo1: arazzo1Rules, | ||
overlay1: overlay1Rules, | ||
}, | ||
preprocessors: { | ||
oas3: oas3_1.preprocessors, | ||
oas2: oas2_1.preprocessors, | ||
async2: async2_1.preprocessors, | ||
async3: async3_1.preprocessors, | ||
arazzo1: arazzo_1.preprocessors, | ||
overlay1: overlay1_1.preprocessors, | ||
oas3: oas3Preprocessors, | ||
oas2: oas2Preprocessors, | ||
async2: async2Preprocessors, | ||
async3: async3Preprocessors, | ||
arazzo1: arazzoPreprocessors, | ||
overlay1: overlay1Preprocessors, | ||
}, | ||
decorators: { | ||
oas3: oas3_2.decorators, | ||
oas2: oas2_2.decorators, | ||
async2: async2_2.decorators, | ||
async3: async3_2.decorators, | ||
arazzo1: arazzo_2.decorators, | ||
overlay1: overlay1_2.decorators, | ||
oas3: oas3Decorators, | ||
oas2: oas2Decorators, | ||
async2: async2Decorators, | ||
async3: async3Decorators, | ||
arazzo1: arazzo1Decorators, | ||
overlay1: overlay1Decorators, | ||
}, | ||
configs: exports.builtInConfigs, | ||
configs: builtInConfigs, | ||
}; | ||
//# sourceMappingURL=builtIn.js.map |
@@ -1,6 +0,6 @@ | ||
import { BaseResolver } from '../resolve'; | ||
import { Config } from './config'; | ||
import type { StyleguideRawConfig, Plugin, RawConfig, ResolvedApi, ResolvedStyleguideConfig } from './types'; | ||
import type { BundleOptions } from '../bundle'; | ||
import type { Document, ResolvedRefMap } from '../resolve'; | ||
import { BaseResolver } from '../resolve.js'; | ||
import { Config } from './config.js'; | ||
import type { StyleguideRawConfig, Plugin, RawConfig, ResolvedApi, ResolvedStyleguideConfig } from './types.js'; | ||
import type { BundleOptions } from '../bundle.js'; | ||
import type { Document, ResolvedRefMap } from '../resolve.js'; | ||
export declare function resolveConfigFileAndRefs({ configPath, externalRefResolver, base, }: Omit<BundleOptions, 'config'> & { | ||
@@ -31,1 +31,2 @@ configPath?: string; | ||
export declare function resolvePreset(presetName: string, plugins: Plugin[]): ResolvedStyleguideConfig; | ||
//# sourceMappingURL=config-resolvers.d.ts.map |
@@ -1,26 +0,19 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.resolveConfigFileAndRefs = resolveConfigFileAndRefs; | ||
exports.resolveConfig = resolveConfig; | ||
exports.resolvePlugins = resolvePlugins; | ||
exports.resolveApis = resolveApis; | ||
exports.resolveStyleguideConfig = resolveStyleguideConfig; | ||
exports.resolvePreset = resolvePreset; | ||
const path = require("path"); | ||
const url_1 = require("url"); | ||
const fs_1 = require("fs"); | ||
const ref_utils_1 = require("../ref-utils"); | ||
const utils_1 = require("../utils"); | ||
const resolve_1 = require("../resolve"); | ||
const builtIn_1 = require("./builtIn"); | ||
const utils_2 = require("./utils"); | ||
const env_1 = require("../env"); | ||
const config_1 = require("./config"); | ||
const logger_1 = require("../logger"); | ||
const asserts_1 = require("../rules/common/assertions/asserts"); | ||
const redocly_yaml_1 = require("../types/redocly-yaml"); | ||
import * as path from 'node:path'; | ||
import * as url from 'node:url'; | ||
import * as fs from 'node:fs'; | ||
import module from 'node:module'; | ||
import { isAbsoluteUrl } from '../ref-utils.js'; | ||
import { pickDefined, isNotString, isString, isDefined, keysOf } from '../utils.js'; | ||
import { resolveDocument, BaseResolver } from '../resolve.js'; | ||
import { defaultPlugin } from './builtIn.js'; | ||
import { getResolveConfig, getUniquePlugins, isCommonJsPlugin, isDeprecatedPluginFormat, mergeExtends, parsePresetName, prefixRules, transformConfig, } from './utils.js'; | ||
import { isBrowser } from '../env.js'; | ||
import { Config } from './config.js'; | ||
import { colorize, logger } from '../logger.js'; | ||
import { asserts, buildAssertCustomFunction } from '../rules/common/assertions/asserts.js'; | ||
import { NormalizedConfigTypes } from '../types/redocly-yaml.js'; | ||
const DEFAULT_PROJECT_PLUGIN_PATHS = ['@theme/plugin.js', '@theme/plugin.cjs', '@theme/plugin.mjs']; | ||
// Cache instantiated plugins during a single execution | ||
const pluginsCache = new Map(); | ||
async function resolveConfigFileAndRefs({ configPath, externalRefResolver = new resolve_1.BaseResolver(), base = null, }) { | ||
export async function resolveConfigFileAndRefs({ configPath, externalRefResolver = new BaseResolver(), base = null, }) { | ||
if (!configPath) { | ||
@@ -33,5 +26,5 @@ throw new Error('Reference to a config is required.\n'); | ||
} | ||
const resolvedRefMap = await (0, resolve_1.resolveDocument)({ | ||
const resolvedRefMap = await resolveDocument({ | ||
rootDocument: document, | ||
rootType: redocly_yaml_1.NormalizedConfigTypes.ConfigRoot, | ||
rootType: NormalizedConfigTypes.ConfigRoot, | ||
externalRefResolver, | ||
@@ -41,7 +34,7 @@ }); | ||
} | ||
async function resolveConfig({ rawConfig, configPath, externalRefResolver, }) { | ||
if (rawConfig.styleguide?.extends?.some(utils_1.isNotString)) { | ||
export async function resolveConfig({ rawConfig, configPath, externalRefResolver, }) { | ||
if (rawConfig.styleguide?.extends?.some(isNotString)) { | ||
throw new Error(`Error configuration format not detected in extends value must contain strings`); | ||
} | ||
const resolver = externalRefResolver ?? new resolve_1.BaseResolver((0, utils_2.getResolveConfig)(rawConfig.resolve)); | ||
const resolver = externalRefResolver ?? new BaseResolver(getResolveConfig(rawConfig.resolve)); | ||
const apis = await resolveApis({ | ||
@@ -57,3 +50,3 @@ rawConfig, | ||
}); | ||
return new config_1.Config({ | ||
return new Config({ | ||
...rawConfig, | ||
@@ -67,3 +60,3 @@ apis, | ||
const absolutePluginPath = path.resolve(configDir, pluginPath); | ||
if ((0, fs_1.existsSync)(absolutePluginPath)) { | ||
if (fs.existsSync(absolutePluginPath)) { | ||
return pluginPath; | ||
@@ -74,3 +67,3 @@ } | ||
} | ||
async function resolvePlugins(plugins, configDir = '') { | ||
export async function resolvePlugins(plugins, configDir = '') { | ||
if (!plugins) | ||
@@ -80,9 +73,9 @@ return []; | ||
const requireFunc = async (plugin) => { | ||
if ((0, utils_1.isString)(plugin)) { | ||
if (isString(plugin)) { | ||
try { | ||
const maybeAbsolutePluginPath = path.resolve(configDir, plugin); | ||
const absolutePluginPath = (0, fs_1.existsSync)(maybeAbsolutePluginPath) | ||
const absolutePluginPath = fs.existsSync(maybeAbsolutePluginPath) | ||
? maybeAbsolutePluginPath | ||
: // For plugins imported from packages specifically | ||
require.resolve(plugin, { | ||
module.createRequire(import.meta.url ?? __dirname).resolve(plugin, { | ||
paths: [ | ||
@@ -92,3 +85,3 @@ // Plugins imported from the node_modules in the project directory | ||
// Plugins imported from the node_modules in the package install directory (for example, npx cache directory) | ||
__dirname, | ||
import.meta.url ? path.dirname(url.fileURLToPath(import.meta.url)) : __dirname, | ||
], | ||
@@ -99,23 +92,20 @@ }); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// @ts-ignore FIXME: investigate if we still need this (2.0) | ||
if (typeof __webpack_require__ === 'function') { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
// @ts-ignore FIXME: investigate if we still need this (2.0) | ||
requiredPlugin = __non_webpack_require__(absolutePluginPath); | ||
} | ||
else { | ||
// Workaround for dynamic imports being transpiled to require by Typescript: https://github.com/microsoft/TypeScript/issues/43329#issuecomment-811606238 | ||
const _importDynamic = new Function('modulePath', 'return import(modulePath)'); | ||
// you can import both cjs and mjs | ||
const mod = await _importDynamic((0, url_1.pathToFileURL)(absolutePluginPath).href); | ||
const mod = await import(url.pathToFileURL(absolutePluginPath).pathname); | ||
requiredPlugin = mod.default || mod; | ||
} | ||
const pluginCreatorOptions = { contentDir: configDir }; | ||
const pluginModule = (0, utils_2.isDeprecatedPluginFormat)(requiredPlugin) | ||
const pluginModule = isDeprecatedPluginFormat(requiredPlugin) | ||
? requiredPlugin | ||
: (0, utils_2.isCommonJsPlugin)(requiredPlugin) | ||
: isCommonJsPlugin(requiredPlugin) | ||
? await requiredPlugin(pluginCreatorOptions) | ||
: await requiredPlugin?.default?.(pluginCreatorOptions); | ||
if (pluginModule?.id && (0, utils_2.isDeprecatedPluginFormat)(requiredPlugin)) { | ||
logger_1.logger.info(`Deprecated plugin format detected: ${pluginModule.id}\n`); | ||
if (pluginModule?.id && isDeprecatedPluginFormat(requiredPlugin)) { | ||
logger.info(`Deprecated plugin format detected: ${pluginModule.id}\n`); | ||
} | ||
@@ -148,5 +138,5 @@ if (pluginModule) { | ||
const instances = await Promise.all(plugins.map(async (p) => { | ||
if ((0, utils_1.isString)(p)) { | ||
if ((0, ref_utils_1.isAbsoluteUrl)(p)) { | ||
throw new Error(logger_1.colorize.red(`We don't support remote plugins yet.`)); | ||
if (isString(p)) { | ||
if (isAbsoluteUrl(p)) { | ||
throw new Error(colorize.red(`We don't support remote plugins yet.`)); | ||
} | ||
@@ -164,7 +154,7 @@ if (resolvedPlugins.has(p)) { | ||
if (typeof id !== 'string') { | ||
throw new Error(logger_1.colorize.red(`Plugin must define \`id\` property in ${logger_1.colorize.blue(p.toString())}.`)); | ||
throw new Error(colorize.red(`Plugin must define \`id\` property in ${colorize.blue(p.toString())}.`)); | ||
} | ||
if (seenPluginIds.has(id)) { | ||
const pluginPath = seenPluginIds.get(id); | ||
throw new Error(logger_1.colorize.red(`Plugin "id" must be unique. Plugin ${logger_1.colorize.blue(p.toString())} uses id "${logger_1.colorize.blue(id)}" already seen in ${logger_1.colorize.blue(pluginPath)}`)); | ||
throw new Error(colorize.red(`Plugin "id" must be unique. Plugin ${colorize.blue(p.toString())} uses id "${colorize.blue(id)}" already seen in ${colorize.blue(pluginPath)}`)); | ||
} | ||
@@ -188,18 +178,18 @@ seenPluginIds.set(id, p.toString()); | ||
if (pluginModule.rules.oas3) { | ||
plugin.rules.oas3 = (0, utils_2.prefixRules)(pluginModule.rules.oas3, id); | ||
plugin.rules.oas3 = prefixRules(pluginModule.rules.oas3, id); | ||
} | ||
if (pluginModule.rules.oas2) { | ||
plugin.rules.oas2 = (0, utils_2.prefixRules)(pluginModule.rules.oas2, id); | ||
plugin.rules.oas2 = prefixRules(pluginModule.rules.oas2, id); | ||
} | ||
if (pluginModule.rules.async2) { | ||
plugin.rules.async2 = (0, utils_2.prefixRules)(pluginModule.rules.async2, id); | ||
plugin.rules.async2 = prefixRules(pluginModule.rules.async2, id); | ||
} | ||
if (pluginModule.rules.async3) { | ||
plugin.rules.async3 = (0, utils_2.prefixRules)(pluginModule.rules.async3, id); | ||
plugin.rules.async3 = prefixRules(pluginModule.rules.async3, id); | ||
} | ||
if (pluginModule.rules.arazzo1) { | ||
plugin.rules.arazzo1 = (0, utils_2.prefixRules)(pluginModule.rules.arazzo1, id); | ||
plugin.rules.arazzo1 = prefixRules(pluginModule.rules.arazzo1, id); | ||
} | ||
if (pluginModule.rules.overlay1) { | ||
plugin.rules.overlay1 = (0, utils_2.prefixRules)(pluginModule.rules.overlay1, id); | ||
plugin.rules.overlay1 = prefixRules(pluginModule.rules.overlay1, id); | ||
} | ||
@@ -218,18 +208,18 @@ } | ||
if (pluginModule.preprocessors.oas3) { | ||
plugin.preprocessors.oas3 = (0, utils_2.prefixRules)(pluginModule.preprocessors.oas3, id); | ||
plugin.preprocessors.oas3 = prefixRules(pluginModule.preprocessors.oas3, id); | ||
} | ||
if (pluginModule.preprocessors.oas2) { | ||
plugin.preprocessors.oas2 = (0, utils_2.prefixRules)(pluginModule.preprocessors.oas2, id); | ||
plugin.preprocessors.oas2 = prefixRules(pluginModule.preprocessors.oas2, id); | ||
} | ||
if (pluginModule.preprocessors.async2) { | ||
plugin.preprocessors.async2 = (0, utils_2.prefixRules)(pluginModule.preprocessors.async2, id); | ||
plugin.preprocessors.async2 = prefixRules(pluginModule.preprocessors.async2, id); | ||
} | ||
if (pluginModule.preprocessors.async3) { | ||
plugin.preprocessors.async3 = (0, utils_2.prefixRules)(pluginModule.preprocessors.async3, id); | ||
plugin.preprocessors.async3 = prefixRules(pluginModule.preprocessors.async3, id); | ||
} | ||
if (pluginModule.preprocessors.arazzo1) { | ||
plugin.preprocessors.arazzo1 = (0, utils_2.prefixRules)(pluginModule.preprocessors.arazzo1, id); | ||
plugin.preprocessors.arazzo1 = prefixRules(pluginModule.preprocessors.arazzo1, id); | ||
} | ||
if (pluginModule.preprocessors.overlay1) { | ||
plugin.preprocessors.overlay1 = (0, utils_2.prefixRules)(pluginModule.preprocessors.overlay1, id); | ||
plugin.preprocessors.overlay1 = prefixRules(pluginModule.preprocessors.overlay1, id); | ||
} | ||
@@ -248,18 +238,18 @@ } | ||
if (pluginModule.decorators.oas3) { | ||
plugin.decorators.oas3 = (0, utils_2.prefixRules)(pluginModule.decorators.oas3, id); | ||
plugin.decorators.oas3 = prefixRules(pluginModule.decorators.oas3, id); | ||
} | ||
if (pluginModule.decorators.oas2) { | ||
plugin.decorators.oas2 = (0, utils_2.prefixRules)(pluginModule.decorators.oas2, id); | ||
plugin.decorators.oas2 = prefixRules(pluginModule.decorators.oas2, id); | ||
} | ||
if (pluginModule.decorators.async2) { | ||
plugin.decorators.async2 = (0, utils_2.prefixRules)(pluginModule.decorators.async2, id); | ||
plugin.decorators.async2 = prefixRules(pluginModule.decorators.async2, id); | ||
} | ||
if (pluginModule.decorators.async3) { | ||
plugin.decorators.async3 = (0, utils_2.prefixRules)(pluginModule.decorators.async3, id); | ||
plugin.decorators.async3 = prefixRules(pluginModule.decorators.async3, id); | ||
} | ||
if (pluginModule.decorators.arazzo1) { | ||
plugin.decorators.arazzo1 = (0, utils_2.prefixRules)(pluginModule.decorators.arazzo1, id); | ||
plugin.decorators.arazzo1 = prefixRules(pluginModule.decorators.arazzo1, id); | ||
} | ||
if (pluginModule.decorators.overlay1) { | ||
plugin.decorators.overlay1 = (0, utils_2.prefixRules)(pluginModule.decorators.overlay1, id); | ||
plugin.decorators.overlay1 = prefixRules(pluginModule.decorators.overlay1, id); | ||
} | ||
@@ -275,9 +265,9 @@ } | ||
})); | ||
return instances.filter(utils_1.isDefined); | ||
return instances.filter(isDefined); | ||
} | ||
async function resolveApis({ rawConfig, configPath = '', resolver, }) { | ||
export async function resolveApis({ rawConfig, configPath = '', resolver, }) { | ||
const { apis = {}, styleguide: styleguideConfig = {} } = rawConfig; | ||
const resolvedApis = {}; | ||
for (const [apiName, apiContent] of Object.entries(apis || {})) { | ||
if (apiContent.styleguide?.extends?.some(utils_1.isNotString)) { | ||
if (apiContent.styleguide?.extends?.some(isNotString)) { | ||
throw new Error(`Error configuration format not detected in extends value must contain strings`); | ||
@@ -295,23 +285,23 @@ } | ||
} | ||
async function resolveAndMergeNestedStyleguideConfig({ styleguideConfig, configPath = '', resolver = new resolve_1.BaseResolver(), parentConfigPaths = [], extendPaths = [], }) { | ||
async function resolveAndMergeNestedStyleguideConfig({ styleguideConfig, configPath = '', resolver = new BaseResolver(), parentConfigPaths = [], extendPaths = [], }) { | ||
if (parentConfigPaths.includes(configPath)) { | ||
throw new Error(`Circular dependency in config file: "${configPath}"`); | ||
} | ||
const plugins = env_1.isBrowser | ||
const plugins = isBrowser | ||
? // In browser, we don't support plugins from config file yet | ||
[builtIn_1.defaultPlugin] | ||
: (0, utils_2.getUniquePlugins)(await resolvePlugins([...(styleguideConfig?.plugins || []), builtIn_1.defaultPlugin], path.dirname(configPath))); | ||
[defaultPlugin] | ||
: getUniquePlugins(await resolvePlugins([...(styleguideConfig?.plugins || []), defaultPlugin], path.dirname(configPath))); | ||
const pluginPaths = styleguideConfig?.plugins | ||
?.filter(utils_1.isString) | ||
?.filter(isString) | ||
.map((p) => path.resolve(path.dirname(configPath), p)); | ||
const resolvedConfigPath = (0, ref_utils_1.isAbsoluteUrl)(configPath) | ||
const resolvedConfigPath = isAbsoluteUrl(configPath) | ||
? configPath | ||
: configPath && path.resolve(configPath); | ||
const extendConfigs = await Promise.all(styleguideConfig?.extends?.map(async (presetItem) => { | ||
if (!(0, ref_utils_1.isAbsoluteUrl)(presetItem) && !path.extname(presetItem)) { | ||
if (!isAbsoluteUrl(presetItem) && !path.extname(presetItem)) { | ||
return resolvePreset(presetItem, plugins); | ||
} | ||
const pathItem = (0, ref_utils_1.isAbsoluteUrl)(presetItem) | ||
const pathItem = isAbsoluteUrl(presetItem) | ||
? presetItem | ||
: (0, ref_utils_1.isAbsoluteUrl)(configPath) | ||
: isAbsoluteUrl(configPath) | ||
? new URL(presetItem, configPath).href | ||
@@ -328,3 +318,3 @@ : path.resolve(path.dirname(configPath), presetItem); | ||
}) || []); | ||
const { plugins: mergedPlugins = [], ...styleguide } = (0, utils_2.mergeExtends)([ | ||
const { plugins: mergedPlugins = [], ...styleguide } = mergeExtends([ | ||
...extendConfigs, | ||
@@ -341,4 +331,4 @@ { | ||
...styleguide, | ||
extendPaths: styleguide.extendPaths?.filter((path) => path && !(0, ref_utils_1.isAbsoluteUrl)(path)), | ||
plugins: (0, utils_2.getUniquePlugins)(mergedPlugins), | ||
extendPaths: styleguide.extendPaths?.filter((path) => path && !isAbsoluteUrl(path)), | ||
plugins: getUniquePlugins(mergedPlugins), | ||
recommendedFallback: styleguideConfig?.recommendedFallback, | ||
@@ -348,3 +338,3 @@ doNotResolveExamples: styleguideConfig?.doNotResolveExamples, | ||
} | ||
async function resolveStyleguideConfig(opts) { | ||
export async function resolveStyleguideConfig(opts) { | ||
const resolvedStyleguideConfig = await resolveAndMergeNestedStyleguideConfig(opts); | ||
@@ -356,7 +346,7 @@ return { | ||
} | ||
function resolvePreset(presetName, plugins) { | ||
const { pluginId, configName } = (0, utils_2.parsePresetName)(presetName); | ||
export function resolvePreset(presetName, plugins) { | ||
const { pluginId, configName } = parsePresetName(presetName); | ||
const plugin = plugins.find((p) => p.id === pluginId); | ||
if (!plugin) { | ||
throw new Error(`Invalid config ${logger_1.colorize.red(presetName)}: plugin ${pluginId} is not included.`); | ||
throw new Error(`Invalid config ${colorize.red(presetName)}: plugin ${pluginId} is not included.`); | ||
} | ||
@@ -366,4 +356,4 @@ const preset = plugin.configs?.[configName]; | ||
throw new Error(pluginId | ||
? `Invalid config ${logger_1.colorize.red(presetName)}: plugin ${pluginId} doesn't export config with name ${configName}.` | ||
: `Invalid config ${logger_1.colorize.red(presetName)}: there is no such built-in config.`); | ||
? `Invalid config ${colorize.red(presetName)}: plugin ${pluginId} doesn't export config with name ${configName}.` | ||
: `Invalid config ${colorize.red(presetName)}: there is no such built-in config.`); | ||
} | ||
@@ -375,3 +365,3 @@ return preset; | ||
const { parsed } = (await resolver.resolveDocument(null, filePath)); | ||
const rawConfig = (0, utils_2.transformConfig)(parsed); | ||
const rawConfig = transformConfig(parsed); | ||
if (!rawConfig.styleguide) { | ||
@@ -389,3 +379,3 @@ throw new Error(`Styleguide configuration format not detected: "${filePath}"`); | ||
...rootStyleguideConfig, | ||
...(0, utils_1.pickDefined)(apiStyleguideConfig), | ||
...pickDefined(apiStyleguideConfig), | ||
rules: { ...rootStyleguideConfig?.rules, ...apiStyleguideConfig?.rules }, | ||
@@ -454,6 +444,3 @@ oas2Rules: { ...rootStyleguideConfig?.oas2Rules, ...apiStyleguideConfig?.oas2Rules }, | ||
for (const [ruleKey, rule] of Object.entries(rules)) { | ||
// keep the old assert/ syntax as an alias | ||
if ((ruleKey.startsWith('rule/') || ruleKey.startsWith('assert/')) && | ||
typeof rule === 'object' && | ||
rule !== null) { | ||
if (ruleKey.startsWith('rule/') && typeof rule === 'object' && rule !== null) { | ||
const assertion = rule; | ||
@@ -483,3 +470,3 @@ if (plugins) { | ||
function registerCustomAssertions(plugins, assertion) { | ||
for (const field of (0, utils_1.keysOf)(assertion.assertions)) { | ||
for (const field of keysOf(assertion.assertions)) { | ||
const [pluginId, fn] = field.split('/'); | ||
@@ -490,9 +477,10 @@ if (!pluginId || !fn) | ||
if (!plugin) { | ||
throw Error(logger_1.colorize.red(`Plugin ${logger_1.colorize.blue(pluginId)} isn't found.`)); | ||
throw Error(colorize.red(`Plugin ${colorize.blue(pluginId)} isn't found.`)); | ||
} | ||
if (!plugin.assertions || !plugin.assertions[fn]) { | ||
throw Error(`Plugin ${logger_1.colorize.red(pluginId)} doesn't export assertions function with name ${logger_1.colorize.red(fn)}.`); | ||
throw Error(`Plugin ${colorize.red(pluginId)} doesn't export assertions function with name ${colorize.red(fn)}.`); | ||
} | ||
asserts_1.asserts[field] = (0, asserts_1.buildAssertCustomFunction)(plugin.assertions[fn]); | ||
asserts[field] = buildAssertCustomFunction(plugin.assertions[fn]); | ||
} | ||
} | ||
//# sourceMappingURL=config-resolvers.js.map |
@@ -1,6 +0,6 @@ | ||
import { SpecVersion, SpecMajorVersion } from '../oas-types'; | ||
import type { NormalizedProblem } from '../walk'; | ||
import type { Oas2RuleSet, Oas3RuleSet, Async3RuleSet, Arazzo1RuleSet, Overlay1RuleSet } from '../oas-types'; | ||
import type { NodeType } from '../types'; | ||
import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedStyleguideConfig, RuleConfig, RuleSettings, Telemetry, ThemeRawConfig } from './types'; | ||
import { SpecVersion, SpecMajorVersion } from '../oas-types.js'; | ||
import type { NormalizedProblem } from '../walk.js'; | ||
import type { Oas2RuleSet, Oas3RuleSet, Async3RuleSet, Arazzo1RuleSet, Overlay1RuleSet } from '../oas-types.js'; | ||
import type { NodeType } from '../types/index.js'; | ||
import type { DecoratorConfig, Plugin, PreprocessorConfig, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedStyleguideConfig, RuleConfig, RuleSettings, Telemetry, ThemeRawConfig } from './types.js'; | ||
export declare const IGNORE_FILE = ".redocly.lint-ignore.yaml"; | ||
@@ -47,8 +47,6 @@ export declare class StyleguideConfig { | ||
licenseKey?: string; | ||
region?: Region; | ||
theme: ThemeRawConfig; | ||
organization?: string; | ||
files: string[]; | ||
telemetry?: Telemetry; | ||
constructor(rawConfig: ResolvedConfig, configFile?: string | undefined); | ||
} | ||
//# sourceMappingURL=config.d.ts.map |
@@ -1,13 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Config = exports.StyleguideConfig = exports.IGNORE_FILE = void 0; | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const js_yaml_1 = require("../js-yaml"); | ||
const utils_1 = require("../utils"); | ||
const oas_types_1 = require("../oas-types"); | ||
const env_1 = require("../env"); | ||
const utils_2 = require("./utils"); | ||
const ref_utils_1 = require("../ref-utils"); | ||
exports.IGNORE_FILE = '.redocly.lint-ignore.yaml'; | ||
import * as fs from 'node:fs'; | ||
import * as path from 'node:path'; | ||
import { parseYaml, stringifyYaml } from '../js-yaml/index.js'; | ||
import { slash, doesYamlFileExist } from '../utils.js'; | ||
import { SpecVersion, SpecMajorVersion } from '../oas-types.js'; | ||
import { isBrowser } from '../env.js'; | ||
import { getResolveConfig } from './utils.js'; | ||
import { isAbsoluteUrl } from '../ref-utils.js'; | ||
export const IGNORE_FILE = '.redocly.lint-ignore.yaml'; | ||
const IGNORE_BANNER = `# This file instructs Redocly's linter to ignore the rules contained for specific parts of your API.\n` + | ||
@@ -17,11 +14,11 @@ `# See https://redocly.com/docs/cli/ for more information.\n`; | ||
if (configFile) { | ||
return (0, utils_1.doesYamlFileExist)(configFile) | ||
? path.join(path.dirname(configFile), exports.IGNORE_FILE) | ||
: path.join(configFile, exports.IGNORE_FILE); | ||
return doesYamlFileExist(configFile) | ||
? path.join(path.dirname(configFile), IGNORE_FILE) | ||
: path.join(configFile, IGNORE_FILE); | ||
} | ||
else { | ||
return env_1.isBrowser ? undefined : path.join(process.cwd(), exports.IGNORE_FILE); | ||
return isBrowser ? undefined : path.join(process.cwd(), IGNORE_FILE); | ||
} | ||
} | ||
class StyleguideConfig { | ||
export class StyleguideConfig { | ||
constructor(rawConfig, configFile) { | ||
@@ -36,39 +33,28 @@ this.rawConfig = rawConfig; | ||
this.recommendedFallback = rawConfig.recommendedFallback || false; | ||
const ruleGroups = [ | ||
'rules', | ||
'oas2Rules', | ||
'oas3_0Rules', | ||
'oas3_1Rules', | ||
'async2Rules', | ||
'async3Rules', | ||
'arazzo1Rules', | ||
'overlay1Rules', | ||
]; | ||
replaceSpecWithStruct(ruleGroups, rawConfig); | ||
this.rules = { | ||
[oas_types_1.SpecVersion.OAS2]: { ...rawConfig.rules, ...rawConfig.oas2Rules }, | ||
[oas_types_1.SpecVersion.OAS3_0]: { ...rawConfig.rules, ...rawConfig.oas3_0Rules }, | ||
[oas_types_1.SpecVersion.OAS3_1]: { ...rawConfig.rules, ...rawConfig.oas3_1Rules }, | ||
[oas_types_1.SpecVersion.Async2]: { ...rawConfig.rules, ...rawConfig.async2Rules }, | ||
[oas_types_1.SpecVersion.Async3]: { ...rawConfig.rules, ...rawConfig.async3Rules }, | ||
[oas_types_1.SpecVersion.Arazzo1]: { ...rawConfig.rules, ...rawConfig.arazzo1Rules }, | ||
[oas_types_1.SpecVersion.Overlay1]: { ...rawConfig.rules, ...rawConfig.overlay1Rules }, | ||
[SpecVersion.OAS2]: { ...rawConfig.rules, ...rawConfig.oas2Rules }, | ||
[SpecVersion.OAS3_0]: { ...rawConfig.rules, ...rawConfig.oas3_0Rules }, | ||
[SpecVersion.OAS3_1]: { ...rawConfig.rules, ...rawConfig.oas3_1Rules }, | ||
[SpecVersion.Async2]: { ...rawConfig.rules, ...rawConfig.async2Rules }, | ||
[SpecVersion.Async3]: { ...rawConfig.rules, ...rawConfig.async3Rules }, | ||
[SpecVersion.Arazzo1]: { ...rawConfig.rules, ...rawConfig.arazzo1Rules }, | ||
[SpecVersion.Overlay1]: { ...rawConfig.rules, ...rawConfig.overlay1Rules }, | ||
}; | ||
this.preprocessors = { | ||
[oas_types_1.SpecVersion.OAS2]: { ...rawConfig.preprocessors, ...rawConfig.oas2Preprocessors }, | ||
[oas_types_1.SpecVersion.OAS3_0]: { ...rawConfig.preprocessors, ...rawConfig.oas3_0Preprocessors }, | ||
[oas_types_1.SpecVersion.OAS3_1]: { ...rawConfig.preprocessors, ...rawConfig.oas3_1Preprocessors }, | ||
[oas_types_1.SpecVersion.Async2]: { ...rawConfig.preprocessors, ...rawConfig.async2Preprocessors }, | ||
[oas_types_1.SpecVersion.Async3]: { ...rawConfig.preprocessors, ...rawConfig.async3Preprocessors }, | ||
[oas_types_1.SpecVersion.Arazzo1]: { ...rawConfig.arazzo1Preprocessors }, | ||
[oas_types_1.SpecVersion.Overlay1]: { ...rawConfig.preprocessors, ...rawConfig.overlay1Preprocessors }, | ||
[SpecVersion.OAS2]: { ...rawConfig.preprocessors, ...rawConfig.oas2Preprocessors }, | ||
[SpecVersion.OAS3_0]: { ...rawConfig.preprocessors, ...rawConfig.oas3_0Preprocessors }, | ||
[SpecVersion.OAS3_1]: { ...rawConfig.preprocessors, ...rawConfig.oas3_1Preprocessors }, | ||
[SpecVersion.Async2]: { ...rawConfig.preprocessors, ...rawConfig.async2Preprocessors }, | ||
[SpecVersion.Async3]: { ...rawConfig.preprocessors, ...rawConfig.async3Preprocessors }, | ||
[SpecVersion.Arazzo1]: { ...rawConfig.arazzo1Preprocessors }, | ||
[SpecVersion.Overlay1]: { ...rawConfig.preprocessors, ...rawConfig.overlay1Preprocessors }, | ||
}; | ||
this.decorators = { | ||
[oas_types_1.SpecVersion.OAS2]: { ...rawConfig.decorators, ...rawConfig.oas2Decorators }, | ||
[oas_types_1.SpecVersion.OAS3_0]: { ...rawConfig.decorators, ...rawConfig.oas3_0Decorators }, | ||
[oas_types_1.SpecVersion.OAS3_1]: { ...rawConfig.decorators, ...rawConfig.oas3_1Decorators }, | ||
[oas_types_1.SpecVersion.Async2]: { ...rawConfig.decorators, ...rawConfig.async2Decorators }, | ||
[oas_types_1.SpecVersion.Async3]: { ...rawConfig.decorators, ...rawConfig.async3Decorators }, | ||
[oas_types_1.SpecVersion.Arazzo1]: { ...rawConfig.arazzo1Decorators }, | ||
[oas_types_1.SpecVersion.Overlay1]: { ...rawConfig.decorators, ...rawConfig.overlay1Decorators }, | ||
[SpecVersion.OAS2]: { ...rawConfig.decorators, ...rawConfig.oas2Decorators }, | ||
[SpecVersion.OAS3_0]: { ...rawConfig.decorators, ...rawConfig.oas3_0Decorators }, | ||
[SpecVersion.OAS3_1]: { ...rawConfig.decorators, ...rawConfig.oas3_1Decorators }, | ||
[SpecVersion.Async2]: { ...rawConfig.decorators, ...rawConfig.async2Decorators }, | ||
[SpecVersion.Async3]: { ...rawConfig.decorators, ...rawConfig.async3Decorators }, | ||
[SpecVersion.Arazzo1]: { ...rawConfig.arazzo1Decorators }, | ||
[SpecVersion.Overlay1]: { ...rawConfig.decorators, ...rawConfig.overlay1Decorators }, | ||
}; | ||
@@ -80,14 +66,13 @@ this.extendPaths = rawConfig.extendPaths || []; | ||
resolveIgnore(ignoreFile) { | ||
if (!ignoreFile || !(0, utils_1.doesYamlFileExist)(ignoreFile)) | ||
if (!ignoreFile || !doesYamlFileExist(ignoreFile)) | ||
return; | ||
this.ignore = | ||
(0, js_yaml_1.parseYaml)(fs.readFileSync(ignoreFile, 'utf-8')) || {}; | ||
replaceSpecWithStruct(Object.keys(this.ignore), this.ignore); | ||
parseYaml(fs.readFileSync(ignoreFile, 'utf-8')) || {}; | ||
// resolve ignore paths | ||
for (const fileName of Object.keys(this.ignore)) { | ||
this.ignore[(0, ref_utils_1.isAbsoluteUrl)(fileName) ? fileName : path.resolve(path.dirname(ignoreFile), fileName)] = this.ignore[fileName]; | ||
this.ignore[isAbsoluteUrl(fileName) ? fileName : path.resolve(path.dirname(ignoreFile), fileName)] = this.ignore[fileName]; | ||
for (const ruleId of Object.keys(this.ignore[fileName])) { | ||
this.ignore[fileName][ruleId] = new Set(this.ignore[fileName][ruleId]); | ||
} | ||
if (!(0, ref_utils_1.isAbsoluteUrl)(fileName)) { | ||
if (!isAbsoluteUrl(fileName)) { | ||
delete this.ignore[fileName]; | ||
@@ -99,8 +84,8 @@ } | ||
const dir = this.configFile ? path.dirname(this.configFile) : process.cwd(); | ||
const ignoreFile = path.join(dir, exports.IGNORE_FILE); | ||
const ignoreFile = path.join(dir, IGNORE_FILE); | ||
const mapped = {}; | ||
for (const absFileName of Object.keys(this.ignore)) { | ||
const mappedDefinitionName = (0, ref_utils_1.isAbsoluteUrl)(absFileName) | ||
const mappedDefinitionName = isAbsoluteUrl(absFileName) | ||
? absFileName | ||
: (0, utils_1.slash)(path.relative(dir, absFileName)); | ||
: slash(path.relative(dir, absFileName)); | ||
const ignoredRules = (mapped[mappedDefinitionName] = this.ignore[absFileName]); | ||
@@ -111,3 +96,3 @@ for (const ruleId of Object.keys(ignoredRules)) { | ||
} | ||
fs.writeFileSync(ignoreFile, IGNORE_BANNER + (0, js_yaml_1.stringifyYaml)(mapped)); | ||
fs.writeFileSync(ignoreFile, IGNORE_BANNER + stringifyYaml(mapped)); | ||
} | ||
@@ -142,4 +127,4 @@ addIgnore(problem) { | ||
switch (version) { | ||
case oas_types_1.SpecVersion.OAS3_0: | ||
case oas_types_1.SpecVersion.OAS3_1: | ||
case SpecVersion.OAS3_0: | ||
case SpecVersion.OAS3_1: | ||
if (!plugin.typeExtension.oas3) | ||
@@ -149,3 +134,3 @@ continue; | ||
break; | ||
case oas_types_1.SpecVersion.OAS2: | ||
case SpecVersion.OAS2: | ||
if (!plugin.typeExtension.oas2) | ||
@@ -155,3 +140,3 @@ continue; | ||
break; | ||
case oas_types_1.SpecVersion.Async2: | ||
case SpecVersion.Async2: | ||
if (!plugin.typeExtension.async2) | ||
@@ -161,3 +146,3 @@ continue; | ||
break; | ||
case oas_types_1.SpecVersion.Async3: | ||
case SpecVersion.Async3: | ||
if (!plugin.typeExtension.async3) | ||
@@ -167,3 +152,3 @@ continue; | ||
break; | ||
case oas_types_1.SpecVersion.Arazzo1: | ||
case SpecVersion.Arazzo1: | ||
if (!plugin.typeExtension.arazzo1) | ||
@@ -173,3 +158,3 @@ continue; | ||
break; | ||
case oas_types_1.SpecVersion.Overlay1: | ||
case SpecVersion.Overlay1: | ||
if (!plugin.typeExtension.overlay1) | ||
@@ -242,3 +227,3 @@ continue; | ||
switch (version) { | ||
case oas_types_1.SpecMajorVersion.OAS3: | ||
case SpecMajorVersion.OAS3: | ||
// eslint-disable-next-line no-case-declarations | ||
@@ -250,3 +235,3 @@ const oas3Rules = []; | ||
return oas3Rules; | ||
case oas_types_1.SpecMajorVersion.OAS2: | ||
case SpecMajorVersion.OAS2: | ||
// eslint-disable-next-line no-case-declarations | ||
@@ -258,3 +243,3 @@ const oas2Rules = []; | ||
return oas2Rules; | ||
case oas_types_1.SpecMajorVersion.Async2: | ||
case SpecMajorVersion.Async2: | ||
// eslint-disable-next-line no-case-declarations | ||
@@ -266,3 +251,3 @@ const asyncApi2Rules = []; | ||
return asyncApi2Rules; | ||
case oas_types_1.SpecMajorVersion.Async3: | ||
case SpecMajorVersion.Async3: | ||
// eslint-disable-next-line no-case-declarations | ||
@@ -274,3 +259,3 @@ const asyncApi3Rules = []; | ||
return asyncApi3Rules; | ||
case oas_types_1.SpecMajorVersion.Arazzo1: | ||
case SpecMajorVersion.Arazzo1: | ||
// eslint-disable-next-line no-case-declarations | ||
@@ -282,3 +267,3 @@ const arazzo1Rules = []; | ||
return arazzo1Rules; | ||
case oas_types_1.SpecMajorVersion.Overlay1: | ||
case SpecMajorVersion.Overlay1: | ||
// eslint-disable-next-line no-case-declarations | ||
@@ -294,3 +279,3 @@ const overlay1Rules = []; | ||
for (const ruleId of rules || []) { | ||
for (const version of Object.values(oas_types_1.SpecVersion)) { | ||
for (const version of Object.values(SpecVersion)) { | ||
if (this.rules[version][ruleId]) { | ||
@@ -312,3 +297,3 @@ this.rules[version][ruleId] = 'off'; | ||
for (const preprocessorId of preprocessors || []) { | ||
for (const version of Object.values(oas_types_1.SpecVersion)) { | ||
for (const version of Object.values(SpecVersion)) { | ||
if (this.preprocessors[version][preprocessorId]) { | ||
@@ -322,3 +307,3 @@ this.preprocessors[version][preprocessorId] = 'off'; | ||
for (const decoratorId of decorators || []) { | ||
for (const version of Object.values(oas_types_1.SpecVersion)) { | ||
for (const version of Object.values(SpecVersion)) { | ||
if (this.decorators[version][decoratorId]) { | ||
@@ -331,14 +316,3 @@ this.decorators[version][decoratorId] = 'off'; | ||
} | ||
exports.StyleguideConfig = StyleguideConfig; | ||
// To support backwards compatibility with the old `spec` key we rename it to `struct`. | ||
function replaceSpecWithStruct(ruleGroups, config) { | ||
for (const ruleGroup of ruleGroups) { | ||
if (config[ruleGroup] && (0, utils_1.isPlainObject)(config[ruleGroup]) && 'spec' in config[ruleGroup]) { | ||
(0, utils_1.showWarningForDeprecatedField)('spec', 'struct'); | ||
config[ruleGroup].struct = config[ruleGroup].spec; | ||
delete config[ruleGroup].spec; | ||
} | ||
} | ||
} | ||
class Config { | ||
export class Config { | ||
constructor(rawConfig, configFile) { | ||
@@ -349,10 +323,7 @@ this.rawConfig = rawConfig; | ||
this.styleguide = new StyleguideConfig(rawConfig.styleguide || {}, configFile); | ||
this.theme = rawConfig.theme || {}; | ||
this.resolve = (0, utils_2.getResolveConfig)(rawConfig?.resolve); | ||
this.region = rawConfig.region; | ||
this.organization = rawConfig.organization; | ||
this.files = rawConfig.files || []; | ||
this.theme = rawConfig.theme || {}; // FIXME: theme is deprecated (2.0) | ||
this.resolve = getResolveConfig(rawConfig?.resolve); | ||
this.telemetry = rawConfig.telemetry; | ||
} | ||
} | ||
exports.Config = Config; | ||
//# sourceMappingURL=config.js.map |
@@ -1,7 +0,8 @@ | ||
export * from './config'; | ||
export * from './types'; | ||
export * from './rules'; | ||
export * from './builtIn'; | ||
export * from './load'; | ||
export * from './utils'; | ||
export * from './config-resolvers'; | ||
export * from './config.js'; | ||
export * from './types.js'; | ||
export * from './rules.js'; | ||
export * from './builtIn.js'; | ||
export * from './load.js'; | ||
export * from './utils.js'; | ||
export * from './config-resolvers.js'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,23 +0,8 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./config"), exports); | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./rules"), exports); | ||
__exportStar(require("./builtIn"), exports); | ||
__exportStar(require("./load"), exports); | ||
__exportStar(require("./utils"), exports); | ||
__exportStar(require("./config-resolvers"), exports); | ||
export * from './config.js'; | ||
export * from './types.js'; | ||
export * from './rules.js'; | ||
export * from './builtIn.js'; | ||
export * from './load.js'; | ||
export * from './utils.js'; | ||
export * from './config-resolvers.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -1,6 +0,5 @@ | ||
import { BaseResolver } from '../resolve'; | ||
import type { Config } from './config'; | ||
import type { Document, ResolvedRefMap } from '../resolve'; | ||
import type { RegionalTokenWithValidity } from '../redocly/redocly-client-types'; | ||
import type { RawConfig, RawUniversalConfig, Region } from './types'; | ||
import { BaseResolver } from '../resolve.js'; | ||
import type { Config } from './config.js'; | ||
import type { Document, ResolvedRefMap } from '../resolve.js'; | ||
import type { RawConfig, RawUniversalConfig } from './types.js'; | ||
export type RawConfigProcessor = (params: { | ||
@@ -17,4 +16,2 @@ document: Document; | ||
externalRefResolver?: BaseResolver; | ||
files?: string[]; | ||
region?: Region; | ||
}): Promise<Config>; | ||
@@ -34,3 +31,2 @@ export declare const CONFIG_FILE_NAMES: string[]; | ||
extends?: string[]; | ||
tokens?: RegionalTokenWithValidity[]; | ||
configPath?: string; | ||
@@ -41,1 +37,2 @@ externalRefResolver?: BaseResolver; | ||
export {}; | ||
//# sourceMappingURL=load.d.ts.map |
@@ -1,20 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CONFIG_FILE_NAMES = void 0; | ||
exports.loadConfig = loadConfig; | ||
exports.findConfig = findConfig; | ||
exports.getConfig = getConfig; | ||
exports.createConfig = createConfig; | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const redocly_1 = require("../redocly"); | ||
const utils_1 = require("../utils"); | ||
const js_yaml_1 = require("../js-yaml"); | ||
const utils_2 = require("./utils"); | ||
const config_resolvers_1 = require("./config-resolvers"); | ||
const bundle_1 = require("../bundle"); | ||
const resolve_1 = require("../resolve"); | ||
const env_1 = require("../env"); | ||
const domains_1 = require("../redocly/domains"); | ||
async function addConfigMetadata({ rawConfig, customExtends, configPath, tokens, files, region, externalRefResolver, }) { | ||
import * as fs from 'node:fs'; | ||
import * as path from 'node:path'; | ||
import { isEmptyObject } from '../utils.js'; | ||
import { parseYaml } from '../js-yaml/index.js'; | ||
import { ConfigValidationError, transformConfig, deepCloneMapWithJSON } from './utils.js'; | ||
import { resolveConfig, resolveConfigFileAndRefs } from './config-resolvers.js'; | ||
import { bundleConfig } from '../bundle.js'; | ||
import { BaseResolver } from '../resolve.js'; | ||
async function addConfigMetadata({ rawConfig, customExtends, configPath, externalRefResolver, }) { | ||
if (customExtends !== undefined) { | ||
@@ -24,38 +14,7 @@ rawConfig.styleguide = rawConfig.styleguide || {}; | ||
} | ||
else if ((0, utils_1.isEmptyObject)(rawConfig)) { | ||
else if (isEmptyObject(rawConfig)) { | ||
rawConfig.styleguide = { extends: ['recommended'], recommendedFallback: true }; | ||
} | ||
if (tokens?.length) { | ||
if (!rawConfig.resolve) | ||
rawConfig.resolve = {}; | ||
if (!rawConfig.resolve.http) | ||
rawConfig.resolve.http = {}; | ||
rawConfig.resolve.http.headers = [...(rawConfig.resolve.http.headers ?? [])]; | ||
for (const item of tokens) { | ||
const domain = domains_1.DOMAINS[item.region]; | ||
rawConfig.resolve.http.headers.push({ | ||
matches: `https://api.${domain}/registry/**`, | ||
name: 'Authorization', | ||
envVariable: undefined, | ||
value: item.token, | ||
}, | ||
//support redocly.com domain for future compatibility | ||
...(item.region === 'us' | ||
? [ | ||
{ | ||
matches: `https://api.redoc.ly/registry/**`, | ||
name: 'Authorization', | ||
envVariable: undefined, | ||
value: item.token, | ||
}, | ||
] | ||
: [])); | ||
} | ||
} | ||
return (0, config_resolvers_1.resolveConfig)({ | ||
rawConfig: { | ||
...rawConfig, | ||
files: files ?? rawConfig.files, | ||
region: region ?? rawConfig.region, | ||
}, | ||
return resolveConfig({ | ||
rawConfig, | ||
configPath, | ||
@@ -65,4 +24,4 @@ externalRefResolver, | ||
} | ||
async function loadConfig(options = {}) { | ||
const { configPath = findConfig(), customExtends, processRawConfig, files, region, externalRefResolver, } = options; | ||
export async function loadConfig(options = {}) { | ||
const { configPath = findConfig(), customExtends, processRawConfig, externalRefResolver, } = options; | ||
const { rawConfig, document, parsed, resolvedRefMap } = await getConfig({ | ||
@@ -72,4 +31,2 @@ configPath, | ||
}); | ||
const redoclyClient = env_1.isBrowser ? undefined : new redocly_1.RedoclyClient(); | ||
const tokens = redoclyClient && redoclyClient.hasTokens() ? redoclyClient.getAllTokens() : []; | ||
const config = await addConfigMetadata({ | ||
@@ -79,5 +36,2 @@ rawConfig, | ||
configPath, | ||
tokens, | ||
files, | ||
region, | ||
externalRefResolver, | ||
@@ -95,3 +49,3 @@ }); | ||
catch (e) { | ||
if (e instanceof utils_2.ConfigValidationError) { | ||
if (e instanceof ConfigValidationError) { | ||
throw e; | ||
@@ -104,7 +58,7 @@ } | ||
} | ||
exports.CONFIG_FILE_NAMES = ['redocly.yaml', 'redocly.yml', '.redocly.yaml', '.redocly.yml']; | ||
function findConfig(dir) { | ||
if (!fs?.hasOwnProperty?.('existsSync')) | ||
export const CONFIG_FILE_NAMES = ['redocly.yaml', 'redocly.yml', '.redocly.yaml', '.redocly.yml']; | ||
export function findConfig(dir) { | ||
if (!fs?.existsSync) | ||
return; | ||
const existingConfigFiles = exports.CONFIG_FILE_NAMES.map((name) => dir ? path.resolve(dir, name) : name).filter(fs.existsSync); | ||
const existingConfigFiles = CONFIG_FILE_NAMES.map((name) => dir ? path.resolve(dir, name) : name).filter(fs.existsSync); | ||
if (existingConfigFiles.length > 1) { | ||
@@ -119,15 +73,15 @@ throw new Error(` | ||
} | ||
async function getConfig(options = {}) { | ||
const { configPath = findConfig(), externalRefResolver = new resolve_1.BaseResolver() } = options; | ||
export async function getConfig(options = {}) { | ||
const { configPath = findConfig(), externalRefResolver = new BaseResolver() } = options; | ||
if (!configPath) | ||
return { rawConfig: {} }; | ||
try { | ||
const { document, resolvedRefMap } = await (0, config_resolvers_1.resolveConfigFileAndRefs)({ | ||
const { document, resolvedRefMap } = await resolveConfigFileAndRefs({ | ||
configPath, | ||
externalRefResolver, | ||
}); | ||
const bundledRefMap = (0, utils_2.deepCloneMapWithJSON)(resolvedRefMap); | ||
const parsed = await (0, bundle_1.bundleConfig)(JSON.parse(JSON.stringify(document)), bundledRefMap); | ||
const bundledRefMap = deepCloneMapWithJSON(resolvedRefMap); | ||
const parsed = await bundleConfig(JSON.parse(JSON.stringify(document)), bundledRefMap); | ||
return { | ||
rawConfig: (0, utils_2.transformConfig)(parsed), | ||
rawConfig: transformConfig(parsed), | ||
document, | ||
@@ -142,7 +96,8 @@ parsed, | ||
} | ||
async function createConfig(config, options) { | ||
export async function createConfig(config, options) { | ||
return addConfigMetadata({ | ||
rawConfig: (0, utils_2.transformConfig)(typeof config === 'string' ? (0, js_yaml_1.parseYaml)(config) : config), | ||
rawConfig: transformConfig(typeof config === 'string' ? parseYaml(config) : config), | ||
...options, | ||
}); | ||
} | ||
//# sourceMappingURL=load.js.map |
@@ -1,3 +0,4 @@ | ||
import type { PluginStyleguideConfig } from './types'; | ||
import type { PluginStyleguideConfig } from './types.js'; | ||
declare const minimal: PluginStyleguideConfig<'built-in'>; | ||
export default minimal; | ||
//# sourceMappingURL=minimal.d.ts.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const minimal = { | ||
@@ -209,2 +207,3 @@ rules: { | ||
}; | ||
exports.default = minimal; | ||
export default minimal; | ||
//# sourceMappingURL=minimal.js.map |
@@ -1,3 +0,4 @@ | ||
import type { PluginStyleguideConfig } from './types'; | ||
import type { PluginStyleguideConfig } from './types.js'; | ||
declare const recommendedStrict: PluginStyleguideConfig<'built-in'>; | ||
export default recommendedStrict; | ||
//# sourceMappingURL=recommended-strict.d.ts.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const recommendedStrict = { | ||
@@ -209,2 +207,3 @@ rules: { | ||
}; | ||
exports.default = recommendedStrict; | ||
export default recommendedStrict; | ||
//# sourceMappingURL=recommended-strict.js.map |
@@ -1,3 +0,4 @@ | ||
import type { PluginStyleguideConfig } from './types'; | ||
import type { PluginStyleguideConfig } from './types.js'; | ||
declare const recommended: PluginStyleguideConfig<'built-in'>; | ||
export default recommended; | ||
//# sourceMappingURL=recommended.d.ts.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const recommended = { | ||
@@ -209,2 +207,3 @@ rules: { | ||
}; | ||
exports.default = recommended; | ||
export default recommended; | ||
//# sourceMappingURL=recommended.js.map |
@@ -1,4 +0,4 @@ | ||
import type { Arazzo1RuleSet, Async2RuleSet, Async3RuleSet, Oas2RuleSet, Oas3RuleSet, Overlay1RuleSet, SpecVersion } from '../oas-types'; | ||
import type { StyleguideConfig } from './config'; | ||
import type { ProblemSeverity } from '../walk'; | ||
import type { Arazzo1RuleSet, Async2RuleSet, Async3RuleSet, Oas2RuleSet, Oas3RuleSet, Overlay1RuleSet, SpecVersion } from '../oas-types.js'; | ||
import type { StyleguideConfig } from './config.js'; | ||
import type { ProblemSeverity } from '../walk.js'; | ||
type InitializedRule = { | ||
@@ -11,1 +11,2 @@ severity: ProblemSeverity; | ||
export {}; | ||
//# sourceMappingURL=rules.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.initRules = initRules; | ||
const utils_1 = require("../utils"); | ||
function initRules(rules, config, type, oasVersion) { | ||
import { isDefined } from '../utils.js'; | ||
export function initRules(rules, config, type, oasVersion) { | ||
return rules | ||
@@ -36,3 +33,4 @@ .flatMap((ruleset) => Object.keys(ruleset).map((ruleId) => { | ||
.flatMap((visitor) => visitor) | ||
.filter(utils_1.isDefined); | ||
.filter(isDefined); | ||
} | ||
//# sourceMappingURL=rules.js.map |
@@ -1,3 +0,4 @@ | ||
import type { PluginStyleguideConfig } from './types'; | ||
import type { PluginStyleguideConfig } from './types.js'; | ||
declare const spec: PluginStyleguideConfig<'built-in'>; | ||
export default spec; | ||
//# sourceMappingURL=spec.d.ts.map |
@@ -1,3 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const spec = { | ||
@@ -32,2 +30,3 @@ rules: { | ||
}; | ||
exports.default = spec; | ||
export default spec; | ||
//# sourceMappingURL=spec.js.map |
@@ -1,6 +0,6 @@ | ||
import type { Location } from '../ref-utils'; | ||
import type { ProblemSeverity, UserContext } from '../walk'; | ||
import type { Oas3PreprocessorsSet, SpecMajorVersion, Oas3DecoratorsSet, Oas2RuleSet, Oas2PreprocessorsSet, Oas2DecoratorsSet, Oas3RuleSet, SpecVersion, Async2PreprocessorsSet, Async2DecoratorsSet, Async2RuleSet, Async3PreprocessorsSet, Async3DecoratorsSet, Async3RuleSet, Arazzo1RuleSet, Arazzo1PreprocessorsSet, Arazzo1DecoratorsSet, RuleMap, Overlay1PreprocessorsSet, Overlay1DecoratorsSet, Overlay1RuleSet } from '../oas-types'; | ||
import type { NodeType } from '../types'; | ||
import type { SkipFunctionContext } from '../visitors'; | ||
import type { Location } from '../ref-utils.js'; | ||
import type { ProblemSeverity, UserContext } from '../walk.js'; | ||
import type { Oas3PreprocessorsSet, SpecMajorVersion, Oas3DecoratorsSet, Oas2RuleSet, Oas2PreprocessorsSet, Oas2DecoratorsSet, Oas3RuleSet, SpecVersion, Async2PreprocessorsSet, Async2DecoratorsSet, Async2RuleSet, Async3PreprocessorsSet, Async3DecoratorsSet, Async3RuleSet, Arazzo1RuleSet, Arazzo1PreprocessorsSet, Arazzo1DecoratorsSet, RuleMap, Overlay1PreprocessorsSet, Overlay1DecoratorsSet, Overlay1RuleSet } from '../oas-types.js'; | ||
import type { NodeType } from '../types/index.js'; | ||
import type { SkipFunctionContext } from '../visitors.js'; | ||
import type { JSONSchema } from 'json-schema-to-ts'; | ||
@@ -140,7 +140,3 @@ export type RuleSeverity = ProblemSeverity | 'off'; | ||
}; | ||
export type Region = 'us' | 'eu'; | ||
export type Telemetry = 'on' | 'off'; | ||
export type AccessTokens = { | ||
[region in Region]?: string; | ||
}; | ||
export type DeprecatedInRawConfig = { | ||
@@ -163,3 +159,2 @@ apiDefinitions?: Record<string, string>; | ||
styleguide: ResolvedStyleguideConfig; | ||
files?: string[]; | ||
}; | ||
@@ -170,5 +165,2 @@ export type RawConfig = { | ||
resolve?: RawResolveConfig; | ||
region?: Region; | ||
organization?: string; | ||
files?: string[]; | ||
telemetry?: Telemetry; | ||
@@ -199,1 +191,2 @@ } & ThemeConfig; | ||
export {}; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=types.js.map |
@@ -1,3 +0,3 @@ | ||
import { Config } from './config'; | ||
import type { Api, DeprecatedInRawConfig, ImportedPlugin, FlatRawConfig, RawConfig, RawResolveConfig, ResolveConfig, ResolvedStyleguideConfig, RulesFields, Plugin, PluginCreator } from './types'; | ||
import { Config } from './config.js'; | ||
import type { Api, DeprecatedInRawConfig, ImportedPlugin, FlatRawConfig, RawConfig, RawResolveConfig, ResolveConfig, ResolvedStyleguideConfig, RulesFields, Plugin, PluginCreator } from './types.js'; | ||
export declare function parsePresetName(presetName: string): { | ||
@@ -20,1 +20,2 @@ pluginId: string; | ||
export declare function isCommonJsPlugin(plugin: ImportedPlugin | undefined): plugin is PluginCreator; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -1,20 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ConfigValidationError = void 0; | ||
exports.parsePresetName = parsePresetName; | ||
exports.transformApiDefinitionsToApis = transformApiDefinitionsToApis; | ||
exports.prefixRules = prefixRules; | ||
exports.mergeExtends = mergeExtends; | ||
exports.getMergedConfig = getMergedConfig; | ||
exports.checkForDeprecatedFields = checkForDeprecatedFields; | ||
exports.transformConfig = transformConfig; | ||
exports.getResolveConfig = getResolveConfig; | ||
exports.getUniquePlugins = getUniquePlugins; | ||
exports.deepCloneMapWithJSON = deepCloneMapWithJSON; | ||
exports.isDeprecatedPluginFormat = isDeprecatedPluginFormat; | ||
exports.isCommonJsPlugin = isCommonJsPlugin; | ||
const utils_1 = require("../utils"); | ||
const config_1 = require("./config"); | ||
const logger_1 = require("../logger"); | ||
function parsePresetName(presetName) { | ||
import { assignOnlyExistingConfig, assignConfig, isDefined, isTruthy, showErrorForDeprecatedField, showWarningForDeprecatedField, } from '../utils.js'; | ||
import { Config } from './config.js'; | ||
import { logger, colorize } from '../logger.js'; | ||
export function parsePresetName(presetName) { | ||
if (presetName.indexOf('/') > -1) { | ||
@@ -28,3 +13,3 @@ const [pluginId, configName] = presetName.split('/'); | ||
} | ||
function transformApiDefinitionsToApis(apiDefinitions) { | ||
export function transformApiDefinitionsToApis(apiDefinitions) { | ||
if (!apiDefinitions) | ||
@@ -69,3 +54,3 @@ return undefined; | ||
if ((rawConfigRest.lint && rawConfigRest.styleguide) || | ||
(Object.values(styleguideConfig).some(utils_1.isDefined) && | ||
(Object.values(styleguideConfig).some(isDefined) && | ||
(rawConfigRest.lint || rawConfigRest.styleguide))) { | ||
@@ -75,3 +60,3 @@ throw new Error(`Do not use 'lint', 'styleguide' and flat syntax together. \nSee more about the configuration in the docs: https://redocly.com/docs/cli/configuration/ \n`); | ||
return { | ||
styleguideConfig: Object.values(styleguideConfig).some(utils_1.isDefined) | ||
styleguideConfig: Object.values(styleguideConfig).some(isDefined) | ||
? styleguideConfig | ||
@@ -95,3 +80,3 @@ : undefined, | ||
} | ||
function prefixRules(rules, prefix) { | ||
export function prefixRules(rules, prefix) { | ||
if (!prefix) | ||
@@ -105,3 +90,3 @@ return rules; | ||
} | ||
function mergeExtends(rulesConfList) { | ||
export function mergeExtends(rulesConfList) { | ||
const result = { | ||
@@ -140,47 +125,47 @@ rules: {}, | ||
} | ||
(0, utils_1.assignConfig)(result.rules, rulesConf.rules); | ||
(0, utils_1.assignConfig)(result.oas2Rules, rulesConf.oas2Rules); | ||
(0, utils_1.assignOnlyExistingConfig)(result.oas2Rules, rulesConf.rules); | ||
(0, utils_1.assignConfig)(result.oas3_0Rules, rulesConf.oas3_0Rules); | ||
(0, utils_1.assignOnlyExistingConfig)(result.oas3_0Rules, rulesConf.rules); | ||
(0, utils_1.assignConfig)(result.oas3_1Rules, rulesConf.oas3_1Rules); | ||
(0, utils_1.assignOnlyExistingConfig)(result.oas3_1Rules, rulesConf.rules); | ||
(0, utils_1.assignConfig)(result.async2Rules, rulesConf.async2Rules); | ||
(0, utils_1.assignOnlyExistingConfig)(result.async2Rules, rulesConf.rules); | ||
(0, utils_1.assignConfig)(result.async3Rules, rulesConf.async3Rules); | ||
(0, utils_1.assignOnlyExistingConfig)(result.async3Rules, rulesConf.rules); | ||
(0, utils_1.assignConfig)(result.arazzo1Rules, rulesConf.arazzo1Rules); | ||
(0, utils_1.assignOnlyExistingConfig)(result.arazzo1Rules, rulesConf.rules); | ||
(0, utils_1.assignConfig)(result.overlay1Rules, rulesConf.overlay1Rules); | ||
(0, utils_1.assignOnlyExistingConfig)(result.overlay1Rules, rulesConf.rules); | ||
(0, utils_1.assignConfig)(result.preprocessors, rulesConf.preprocessors); | ||
(0, utils_1.assignConfig)(result.oas2Preprocessors, rulesConf.oas2Preprocessors); | ||
(0, utils_1.assignOnlyExistingConfig)(result.oas2Preprocessors, rulesConf.preprocessors); | ||
(0, utils_1.assignConfig)(result.oas3_0Preprocessors, rulesConf.oas3_0Preprocessors); | ||
(0, utils_1.assignOnlyExistingConfig)(result.oas3_0Preprocessors, rulesConf.preprocessors); | ||
(0, utils_1.assignConfig)(result.oas3_1Preprocessors, rulesConf.oas3_1Preprocessors); | ||
(0, utils_1.assignOnlyExistingConfig)(result.oas3_1Preprocessors, rulesConf.preprocessors); | ||
(0, utils_1.assignConfig)(result.async2Preprocessors, rulesConf.async2Preprocessors); | ||
(0, utils_1.assignOnlyExistingConfig)(result.async2Preprocessors, rulesConf.preprocessors); | ||
(0, utils_1.assignConfig)(result.async3Preprocessors, rulesConf.async3Preprocessors); | ||
(0, utils_1.assignOnlyExistingConfig)(result.async3Preprocessors, rulesConf.preprocessors); | ||
(0, utils_1.assignConfig)(result.arazzo1Preprocessors, rulesConf.arazzo1Preprocessors); | ||
(0, utils_1.assignOnlyExistingConfig)(result.arazzo1Preprocessors, rulesConf.preprocessors); | ||
(0, utils_1.assignConfig)(result.overlay1Preprocessors, rulesConf.overlay1Preprocessors); | ||
(0, utils_1.assignOnlyExistingConfig)(result.overlay1Preprocessors, rulesConf.preprocessors); | ||
(0, utils_1.assignConfig)(result.decorators, rulesConf.decorators); | ||
(0, utils_1.assignConfig)(result.oas2Decorators, rulesConf.oas2Decorators); | ||
(0, utils_1.assignOnlyExistingConfig)(result.oas2Decorators, rulesConf.decorators); | ||
(0, utils_1.assignConfig)(result.oas3_0Decorators, rulesConf.oas3_0Decorators); | ||
(0, utils_1.assignOnlyExistingConfig)(result.oas3_0Decorators, rulesConf.decorators); | ||
(0, utils_1.assignConfig)(result.oas3_1Decorators, rulesConf.oas3_1Decorators); | ||
(0, utils_1.assignOnlyExistingConfig)(result.oas3_1Decorators, rulesConf.decorators); | ||
(0, utils_1.assignConfig)(result.async2Decorators, rulesConf.async2Decorators); | ||
(0, utils_1.assignOnlyExistingConfig)(result.async2Decorators, rulesConf.decorators); | ||
(0, utils_1.assignConfig)(result.async3Decorators, rulesConf.async3Decorators); | ||
(0, utils_1.assignOnlyExistingConfig)(result.async3Decorators, rulesConf.decorators); | ||
(0, utils_1.assignConfig)(result.arazzo1Decorators, rulesConf.arazzo1Decorators); | ||
(0, utils_1.assignOnlyExistingConfig)(result.arazzo1Decorators, rulesConf.decorators); | ||
(0, utils_1.assignConfig)(result.overlay1Decorators, rulesConf.overlay1Decorators); | ||
(0, utils_1.assignOnlyExistingConfig)(result.overlay1Decorators, rulesConf.decorators); | ||
assignConfig(result.rules, rulesConf.rules); | ||
assignConfig(result.oas2Rules, rulesConf.oas2Rules); | ||
assignOnlyExistingConfig(result.oas2Rules, rulesConf.rules); | ||
assignConfig(result.oas3_0Rules, rulesConf.oas3_0Rules); | ||
assignOnlyExistingConfig(result.oas3_0Rules, rulesConf.rules); | ||
assignConfig(result.oas3_1Rules, rulesConf.oas3_1Rules); | ||
assignOnlyExistingConfig(result.oas3_1Rules, rulesConf.rules); | ||
assignConfig(result.async2Rules, rulesConf.async2Rules); | ||
assignOnlyExistingConfig(result.async2Rules, rulesConf.rules); | ||
assignConfig(result.async3Rules, rulesConf.async3Rules); | ||
assignOnlyExistingConfig(result.async3Rules, rulesConf.rules); | ||
assignConfig(result.arazzo1Rules, rulesConf.arazzo1Rules); | ||
assignOnlyExistingConfig(result.arazzo1Rules, rulesConf.rules); | ||
assignConfig(result.overlay1Rules, rulesConf.overlay1Rules); | ||
assignOnlyExistingConfig(result.overlay1Rules, rulesConf.rules); | ||
assignConfig(result.preprocessors, rulesConf.preprocessors); | ||
assignConfig(result.oas2Preprocessors, rulesConf.oas2Preprocessors); | ||
assignOnlyExistingConfig(result.oas2Preprocessors, rulesConf.preprocessors); | ||
assignConfig(result.oas3_0Preprocessors, rulesConf.oas3_0Preprocessors); | ||
assignOnlyExistingConfig(result.oas3_0Preprocessors, rulesConf.preprocessors); | ||
assignConfig(result.oas3_1Preprocessors, rulesConf.oas3_1Preprocessors); | ||
assignOnlyExistingConfig(result.oas3_1Preprocessors, rulesConf.preprocessors); | ||
assignConfig(result.async2Preprocessors, rulesConf.async2Preprocessors); | ||
assignOnlyExistingConfig(result.async2Preprocessors, rulesConf.preprocessors); | ||
assignConfig(result.async3Preprocessors, rulesConf.async3Preprocessors); | ||
assignOnlyExistingConfig(result.async3Preprocessors, rulesConf.preprocessors); | ||
assignConfig(result.arazzo1Preprocessors, rulesConf.arazzo1Preprocessors); | ||
assignOnlyExistingConfig(result.arazzo1Preprocessors, rulesConf.preprocessors); | ||
assignConfig(result.overlay1Preprocessors, rulesConf.overlay1Preprocessors); | ||
assignOnlyExistingConfig(result.overlay1Preprocessors, rulesConf.preprocessors); | ||
assignConfig(result.decorators, rulesConf.decorators); | ||
assignConfig(result.oas2Decorators, rulesConf.oas2Decorators); | ||
assignOnlyExistingConfig(result.oas2Decorators, rulesConf.decorators); | ||
assignConfig(result.oas3_0Decorators, rulesConf.oas3_0Decorators); | ||
assignOnlyExistingConfig(result.oas3_0Decorators, rulesConf.decorators); | ||
assignConfig(result.oas3_1Decorators, rulesConf.oas3_1Decorators); | ||
assignOnlyExistingConfig(result.oas3_1Decorators, rulesConf.decorators); | ||
assignConfig(result.async2Decorators, rulesConf.async2Decorators); | ||
assignOnlyExistingConfig(result.async2Decorators, rulesConf.decorators); | ||
assignConfig(result.async3Decorators, rulesConf.async3Decorators); | ||
assignOnlyExistingConfig(result.async3Decorators, rulesConf.decorators); | ||
assignConfig(result.arazzo1Decorators, rulesConf.arazzo1Decorators); | ||
assignOnlyExistingConfig(result.arazzo1Decorators, rulesConf.decorators); | ||
assignConfig(result.overlay1Decorators, rulesConf.overlay1Decorators); | ||
assignOnlyExistingConfig(result.overlay1Decorators, rulesConf.decorators); | ||
result.plugins.push(...(rulesConf.plugins || [])); | ||
@@ -192,3 +177,3 @@ result.pluginPaths.push(...(rulesConf.pluginPaths || [])); | ||
} | ||
function getMergedConfig(config, apiName) { | ||
export function getMergedConfig(config, apiName) { | ||
const extendPaths = [ | ||
@@ -199,3 +184,3 @@ ...Object.values(config.apis).map((api) => api?.styleguide?.extendPaths), | ||
.flat() | ||
.filter(utils_1.isTruthy); | ||
.filter(isTruthy); | ||
const pluginPaths = [ | ||
@@ -206,5 +191,5 @@ ...Object.values(config.apis).map((api) => api?.styleguide?.pluginPaths), | ||
.flat() | ||
.filter(utils_1.isTruthy); | ||
.filter(isTruthy); | ||
return apiName | ||
? new config_1.Config({ | ||
? new Config({ | ||
...config.rawConfig, | ||
@@ -218,2 +203,3 @@ styleguide: { | ||
}, | ||
// FIXME: theme is deprecated (2.0) | ||
theme: { | ||
@@ -223,3 +209,2 @@ ...config.rawConfig.theme, | ||
}, | ||
files: [...config.files, ...(config.apis?.[apiName]?.files ?? [])], | ||
// TODO: merge everything else here | ||
@@ -229,19 +214,19 @@ }, config.configFile) | ||
} | ||
function checkForDeprecatedFields(deprecatedField, updatedField, rawConfig, updatedObject, link) { | ||
export function checkForDeprecatedFields(deprecatedField, updatedField, rawConfig, updatedObject, link) { | ||
const isDeprecatedFieldInApis = rawConfig.apis && | ||
Object.values(rawConfig.apis).some((api) => api[deprecatedField]); | ||
if (rawConfig[deprecatedField] && updatedField === null) { | ||
(0, utils_1.showWarningForDeprecatedField)(deprecatedField, undefined, updatedObject, link); | ||
showWarningForDeprecatedField(deprecatedField, undefined, updatedObject, link); | ||
} | ||
if (rawConfig[deprecatedField] && updatedField && rawConfig[updatedField]) { | ||
(0, utils_1.showErrorForDeprecatedField)(deprecatedField, updatedField); | ||
showErrorForDeprecatedField(deprecatedField, updatedField); | ||
} | ||
if (rawConfig[deprecatedField] && updatedObject && rawConfig[updatedObject]) { | ||
(0, utils_1.showErrorForDeprecatedField)(deprecatedField, updatedField, updatedObject); | ||
showErrorForDeprecatedField(deprecatedField, updatedField, updatedObject); | ||
} | ||
if (rawConfig[deprecatedField] || isDeprecatedFieldInApis) { | ||
(0, utils_1.showWarningForDeprecatedField)(deprecatedField, updatedField, updatedObject, link); | ||
showWarningForDeprecatedField(deprecatedField, updatedField, updatedObject, link); | ||
} | ||
} | ||
function transformConfig(rawConfig) { | ||
export function transformConfig(rawConfig) { | ||
const migratedFields = [ | ||
@@ -270,2 +255,3 @@ ['apiDefinitions', 'apis', undefined, undefined], | ||
const transformedConfig = { | ||
// FIXME: theme is deprecated (2.0) | ||
theme: { | ||
@@ -286,17 +272,5 @@ openapi: { | ||
}; | ||
showDeprecationMessages(transformedConfig); | ||
return transformedConfig; | ||
} | ||
function showDeprecationMessages(config) { | ||
let allRules = { ...config.styleguide?.rules }; | ||
for (const api of Object.values(config.apis || {})) { | ||
allRules = { ...allRules, ...api?.styleguide?.rules }; | ||
} | ||
for (const ruleKey of Object.keys(allRules)) { | ||
if (ruleKey.startsWith('assert/')) { | ||
logger_1.logger.warn(`\nThe 'assert/' syntax in ${ruleKey} is deprecated. Update your configuration to use 'rule/' instead. Examples and more information: https://redocly.com/docs/cli/rules/configurable-rules/\n`); | ||
} | ||
} | ||
} | ||
function getResolveConfig(resolve) { | ||
export function getResolveConfig(resolve) { | ||
return { | ||
@@ -309,3 +283,3 @@ http: { | ||
} | ||
function getUniquePlugins(plugins) { | ||
export function getUniquePlugins(plugins) { | ||
const seen = new Set(); | ||
@@ -319,3 +293,3 @@ const results = []; | ||
else if (p.id) { | ||
logger_1.logger.warn(`Duplicate plugin id "${logger_1.colorize.red(p.id)}".\n`); | ||
logger.warn(`Duplicate plugin id "${colorize.red(p.id)}".\n`); | ||
} | ||
@@ -325,13 +299,13 @@ } | ||
} | ||
class ConfigValidationError extends Error { | ||
export class ConfigValidationError extends Error { | ||
} | ||
exports.ConfigValidationError = ConfigValidationError; | ||
function deepCloneMapWithJSON(originalMap) { | ||
export function deepCloneMapWithJSON(originalMap) { | ||
return new Map(JSON.parse(JSON.stringify([...originalMap]))); | ||
} | ||
function isDeprecatedPluginFormat(plugin) { | ||
export function isDeprecatedPluginFormat(plugin) { | ||
return plugin !== undefined && typeof plugin === 'object' && 'id' in plugin; | ||
} | ||
function isCommonJsPlugin(plugin) { | ||
export function isCommonJsPlugin(plugin) { | ||
return typeof plugin === 'function'; | ||
} | ||
//# sourceMappingURL=utils.js.map |
export declare const decorators: {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decorators = void 0; | ||
exports.decorators = {}; | ||
export const decorators = {}; | ||
//# sourceMappingURL=index.js.map |
export declare const decorators: {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decorators = void 0; | ||
exports.decorators = {}; | ||
export const decorators = {}; | ||
//# sourceMappingURL=index.js.map |
export declare const decorators: {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decorators = void 0; | ||
exports.decorators = {}; | ||
export const decorators = {}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,3 +0,4 @@ | ||
import type { UserContext } from '../../../walk'; | ||
import type { UserContext } from '../../../walk.js'; | ||
export declare function filter(node: any, ctx: UserContext, criteria: (item: any) => boolean): void; | ||
export declare function checkIfMatchByStrategy(nodeValue: any, decoratorValue: any, strategy: 'all' | 'any'): boolean; | ||
//# sourceMappingURL=filter-helper.d.ts.map |
@@ -1,8 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.filter = filter; | ||
exports.checkIfMatchByStrategy = checkIfMatchByStrategy; | ||
const ref_utils_1 = require("../../../ref-utils"); | ||
const utils_1 = require("../../../utils"); | ||
function filter(node, ctx, criteria) { | ||
import { isRef } from '../../../ref-utils.js'; | ||
import { isEmptyArray, isEmptyObject, isPlainObject } from '../../../utils.js'; | ||
export function filter(node, ctx, criteria) { | ||
const { parent, key } = ctx; | ||
@@ -12,3 +8,3 @@ let didDelete = false; | ||
for (let i = 0; i < node.length; i++) { | ||
if ((0, ref_utils_1.isRef)(node[i])) { | ||
if (isRef(node[i])) { | ||
const resolved = ctx.resolve(node[i]); | ||
@@ -28,6 +24,6 @@ if (criteria(resolved.node)) { | ||
} | ||
else if ((0, utils_1.isPlainObject)(node)) { | ||
else if (isPlainObject(node)) { | ||
for (const key of Object.keys(node)) { | ||
node = node; | ||
if ((0, ref_utils_1.isRef)(node[key])) { | ||
if (isRef(node[key])) { | ||
const resolved = ctx.resolve(node[key]); | ||
@@ -45,7 +41,7 @@ if (criteria(resolved.node)) { | ||
} | ||
if (didDelete && ((0, utils_1.isEmptyObject)(node) || (0, utils_1.isEmptyArray)(node))) { | ||
if (didDelete && (isEmptyObject(node) || isEmptyArray(node))) { | ||
delete parent[key]; | ||
} | ||
} | ||
function checkIfMatchByStrategy(nodeValue, decoratorValue, strategy) { | ||
export function checkIfMatchByStrategy(nodeValue, decoratorValue, strategy) { | ||
if (nodeValue === undefined || decoratorValue === undefined) { | ||
@@ -70,1 +66,2 @@ return false; | ||
} | ||
//# sourceMappingURL=filter-helper.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Decorator, Oas3Decorator } from '../../../visitors'; | ||
import type { Oas2Decorator, Oas3Decorator } from '../../../visitors.js'; | ||
export declare const FilterIn: Oas3Decorator | Oas2Decorator; | ||
//# sourceMappingURL=filter-in.d.ts.map |
@@ -1,13 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FilterIn = void 0; | ||
const filter_helper_1 = require("./filter-helper"); | ||
import { checkIfMatchByStrategy, filter } from './filter-helper.js'; | ||
const DEFAULT_STRATEGY = 'any'; | ||
const FilterIn = ({ property, value, matchStrategy }) => { | ||
export const FilterIn = ({ property, value, matchStrategy }) => { | ||
const strategy = matchStrategy || DEFAULT_STRATEGY; | ||
const filterInCriteria = (item) => item?.[property] && !(0, filter_helper_1.checkIfMatchByStrategy)(item?.[property], value, strategy); | ||
const filterInCriteria = (item) => item?.[property] && !checkIfMatchByStrategy(item?.[property], value, strategy); | ||
return { | ||
any: { | ||
enter: (node, ctx) => { | ||
(0, filter_helper_1.filter)(node, ctx, filterInCriteria); | ||
filter(node, ctx, filterInCriteria); | ||
}, | ||
@@ -17,2 +14,2 @@ }, | ||
}; | ||
exports.FilterIn = FilterIn; | ||
//# sourceMappingURL=filter-in.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Decorator, Oas3Decorator } from '../../../visitors'; | ||
import type { Oas2Decorator, Oas3Decorator } from '../../../visitors.js'; | ||
export declare const FilterOut: Oas3Decorator | Oas2Decorator; | ||
//# sourceMappingURL=filter-out.d.ts.map |
@@ -1,13 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FilterOut = void 0; | ||
const filter_helper_1 = require("./filter-helper"); | ||
import { checkIfMatchByStrategy, filter } from './filter-helper.js'; | ||
const DEFAULT_STRATEGY = 'any'; | ||
const FilterOut = ({ property, value, matchStrategy }) => { | ||
export const FilterOut = ({ property, value, matchStrategy }) => { | ||
const strategy = matchStrategy || DEFAULT_STRATEGY; | ||
const filterOutCriteria = (item) => (0, filter_helper_1.checkIfMatchByStrategy)(item?.[property], value, strategy); | ||
const filterOutCriteria = (item) => checkIfMatchByStrategy(item?.[property], value, strategy); | ||
return { | ||
any: { | ||
enter: (node, ctx) => { | ||
(0, filter_helper_1.filter)(node, ctx, filterOutCriteria); | ||
filter(node, ctx, filterOutCriteria); | ||
}, | ||
@@ -17,2 +14,2 @@ }, | ||
}; | ||
exports.FilterOut = FilterOut; | ||
//# sourceMappingURL=filter-out.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; | ||
import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; | ||
export declare const InfoDescriptionOverride: Oas3Decorator | Oas2Decorator; | ||
//# sourceMappingURL=info-description-override.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InfoDescriptionOverride = void 0; | ||
const utils_1 = require("../../utils"); | ||
const InfoDescriptionOverride = ({ filePath }) => { | ||
import { readFileAsStringSync } from '../../utils.js'; | ||
export const InfoDescriptionOverride = ({ filePath }) => { | ||
return { | ||
@@ -12,3 +9,3 @@ Info: { | ||
try { | ||
info.description = (0, utils_1.readFileAsStringSync)(filePath); | ||
info.description = readFileAsStringSync(filePath); | ||
} | ||
@@ -25,2 +22,2 @@ catch (e) { | ||
}; | ||
exports.InfoDescriptionOverride = InfoDescriptionOverride; | ||
//# sourceMappingURL=info-description-override.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; | ||
import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; | ||
export declare const InfoOverride: Oas3Decorator | Oas2Decorator; | ||
//# sourceMappingURL=info-override.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InfoOverride = void 0; | ||
const InfoOverride = (newInfo) => { | ||
export const InfoOverride = (newInfo) => { | ||
return { | ||
@@ -17,2 +14,2 @@ Info: { | ||
}; | ||
exports.InfoOverride = InfoOverride; | ||
//# sourceMappingURL=info-override.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Decorator } from '../../visitors'; | ||
import type { Oas3Decorator } from '../../visitors.js'; | ||
export declare const MediaTypeExamplesOverride: Oas3Decorator; | ||
//# sourceMappingURL=media-type-examples-override.d.ts.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MediaTypeExamplesOverride = void 0; | ||
const utils_1 = require("../../utils"); | ||
const ref_utils_1 = require("../../ref-utils"); | ||
const MediaTypeExamplesOverride = ({ operationIds }) => { | ||
import { yamlAndJsonSyncReader } from '../../utils.js'; | ||
import { isRef } from '../../ref-utils.js'; | ||
export const MediaTypeExamplesOverride = ({ operationIds }) => { | ||
return { | ||
@@ -28,3 +25,3 @@ Operation: { | ||
...resolvedResponse.content[mimeType], | ||
examples: (0, utils_1.yamlAndJsonSyncReader)(properties.responses[responseCode][mimeType]), | ||
examples: yamlAndJsonSyncReader(properties.responses[responseCode][mimeType]), | ||
}; | ||
@@ -44,3 +41,3 @@ }); | ||
...resolvedRequest.content[mimeType], | ||
examples: (0, utils_1.yamlAndJsonSyncReader)(properties.request[mimeType]), | ||
examples: yamlAndJsonSyncReader(properties.request[mimeType]), | ||
}; | ||
@@ -54,5 +51,4 @@ }); | ||
}; | ||
exports.MediaTypeExamplesOverride = MediaTypeExamplesOverride; | ||
function checkAndResolveRef(node, resolver) { | ||
if (!(0, ref_utils_1.isRef)(node)) { | ||
if (!isRef(node)) { | ||
return node; | ||
@@ -63,1 +59,2 @@ } | ||
} | ||
//# sourceMappingURL=media-type-examples-override.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; | ||
import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; | ||
export declare const OperationDescriptionOverride: Oas3Decorator | Oas2Decorator; | ||
//# sourceMappingURL=operation-description-override.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OperationDescriptionOverride = void 0; | ||
const utils_1 = require("../../utils"); | ||
const OperationDescriptionOverride = ({ operationIds }) => { | ||
import { readFileAsStringSync } from '../../utils.js'; | ||
export const OperationDescriptionOverride = ({ operationIds }) => { | ||
return { | ||
@@ -16,3 +13,3 @@ Operation: { | ||
try { | ||
operation.description = (0, utils_1.readFileAsStringSync)(operationIds[operationId]); | ||
operation.description = readFileAsStringSync(operationIds[operationId]); | ||
} | ||
@@ -30,2 +27,2 @@ catch (e) { | ||
}; | ||
exports.OperationDescriptionOverride = OperationDescriptionOverride; | ||
//# sourceMappingURL=operation-description-override.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; | ||
import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; | ||
export declare const RemoveXInternal: Oas3Decorator | Oas2Decorator; | ||
//# sourceMappingURL=remove-x-internal.d.ts.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RemoveXInternal = void 0; | ||
const utils_1 = require("../../utils"); | ||
const ref_utils_1 = require("../../ref-utils"); | ||
import { isEmptyArray, isEmptyObject, isPlainObject } from '../../utils.js'; | ||
import { isRef } from '../../ref-utils.js'; | ||
const DEFAULT_INTERNAL_PROPERTY_NAME = 'x-internal'; | ||
const RemoveXInternal = ({ internalFlagProperty = DEFAULT_INTERNAL_PROPERTY_NAME, }) => { | ||
export const RemoveXInternal = ({ internalFlagProperty = DEFAULT_INTERNAL_PROPERTY_NAME, }) => { | ||
function removeInternal(node, ctx, originalMapping) { | ||
@@ -13,7 +10,7 @@ const { parent, key } = ctx; | ||
for (let i = 0; i < node.length; i++) { | ||
if ((0, ref_utils_1.isRef)(node[i])) { | ||
if (isRef(node[i])) { | ||
const resolved = ctx.resolve(node[i]); | ||
if (resolved.node?.[internalFlagProperty]) { | ||
// First, remove the reference in the discriminator mapping, if it exists: | ||
if ((0, utils_1.isPlainObject)(parent.discriminator?.mapping)) { | ||
if (isPlainObject(parent.discriminator?.mapping)) { | ||
for (const mapping in parent.discriminator.mapping) { | ||
@@ -37,7 +34,7 @@ if (originalMapping?.[mapping] === node[i].$ref) { | ||
} | ||
else if ((0, utils_1.isPlainObject)(node)) { | ||
else if (isPlainObject(node)) { | ||
for (const key of Object.keys(node)) { | ||
if ((0, ref_utils_1.isRef)(node[key])) { | ||
if (isRef(node[key])) { | ||
const resolved = ctx.resolve(node[key]); | ||
if ((0, utils_1.isPlainObject)(resolved.node) && resolved.node?.[internalFlagProperty]) { | ||
if (isPlainObject(resolved.node) && resolved.node?.[internalFlagProperty]) { | ||
delete node[key]; | ||
@@ -47,3 +44,3 @@ didDelete = true; | ||
} | ||
if ((0, utils_1.isPlainObject)(node[key]) && node[key]?.[internalFlagProperty]) { | ||
if (isPlainObject(node[key]) && node[key]?.[internalFlagProperty]) { | ||
delete node[key]; | ||
@@ -54,3 +51,3 @@ didDelete = true; | ||
} | ||
if (didDelete && ((0, utils_1.isEmptyObject)(node) || (0, utils_1.isEmptyArray)(node))) { | ||
if (didDelete && (isEmptyObject(node) || isEmptyArray(node))) { | ||
delete parent[key]; | ||
@@ -73,2 +70,2 @@ } | ||
}; | ||
exports.RemoveXInternal = RemoveXInternal; | ||
//# sourceMappingURL=remove-x-internal.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Decorator, Oas2Decorator } from '../../visitors'; | ||
import type { Oas3Decorator, Oas2Decorator } from '../../visitors.js'; | ||
export declare const TagDescriptionOverride: Oas3Decorator | Oas2Decorator; | ||
//# sourceMappingURL=tag-description-override.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TagDescriptionOverride = void 0; | ||
const utils_1 = require("../../utils"); | ||
const TagDescriptionOverride = ({ tagNames }) => { | ||
import { readFileAsStringSync } from '../../utils.js'; | ||
export const TagDescriptionOverride = ({ tagNames }) => { | ||
return { | ||
@@ -13,3 +10,3 @@ Tag: { | ||
try { | ||
tag.description = (0, utils_1.readFileAsStringSync)(tagNames[tag.name]); | ||
tag.description = readFileAsStringSync(tagNames[tag.name]); | ||
} | ||
@@ -26,2 +23,2 @@ catch (e) { | ||
}; | ||
exports.TagDescriptionOverride = TagDescriptionOverride; | ||
//# sourceMappingURL=tag-description-override.js.map |
@@ -1,4 +0,3 @@ | ||
import type { Oas2Decorator } from '../../visitors'; | ||
import type { Oas2Decorator } from '../../visitors.js'; | ||
export declare const decorators: { | ||
'registry-dependencies': Oas2Decorator; | ||
'operation-description-override': Oas2Decorator; | ||
@@ -12,1 +11,2 @@ 'tag-description-override': Oas2Decorator; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,21 +0,17 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decorators = void 0; | ||
const registry_dependencies_1 = require("../common/registry-dependencies"); | ||
const operation_description_override_1 = require("../common/operation-description-override"); | ||
const tag_description_override_1 = require("../common/tag-description-override"); | ||
const info_description_override_1 = require("../common/info-description-override"); | ||
const info_override_1 = require("../common/info-override"); | ||
const remove_x_internal_1 = require("../common/remove-x-internal"); | ||
const filter_in_1 = require("../common/filters/filter-in"); | ||
const filter_out_1 = require("../common/filters/filter-out"); | ||
exports.decorators = { | ||
'registry-dependencies': registry_dependencies_1.RegistryDependencies, | ||
'operation-description-override': operation_description_override_1.OperationDescriptionOverride, | ||
'tag-description-override': tag_description_override_1.TagDescriptionOverride, | ||
'info-description-override': info_description_override_1.InfoDescriptionOverride, | ||
'info-override': info_override_1.InfoOverride, | ||
'remove-x-internal': remove_x_internal_1.RemoveXInternal, | ||
'filter-in': filter_in_1.FilterIn, | ||
'filter-out': filter_out_1.FilterOut, | ||
import { OperationDescriptionOverride } from '../common/operation-description-override.js'; | ||
import { TagDescriptionOverride } from '../common/tag-description-override.js'; | ||
import { InfoDescriptionOverride } from '../common/info-description-override.js'; | ||
import { InfoOverride } from '../common/info-override.js'; | ||
import { RemoveXInternal } from '../common/remove-x-internal.js'; | ||
import { FilterIn } from '../common/filters/filter-in.js'; | ||
import { FilterOut } from '../common/filters/filter-out.js'; | ||
export const decorators = { | ||
'operation-description-override': OperationDescriptionOverride, | ||
'tag-description-override': TagDescriptionOverride, | ||
'info-description-override': InfoDescriptionOverride, | ||
'info-override': InfoOverride, | ||
'remove-x-internal': RemoveXInternal, | ||
'filter-in': FilterIn, | ||
'filter-out': FilterOut, | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Decorator } from '../../visitors'; | ||
import type { Oas2Decorator } from '../../visitors.js'; | ||
export declare const RemoveUnusedComponents: Oas2Decorator; | ||
//# sourceMappingURL=remove-unused-components.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RemoveUnusedComponents = void 0; | ||
const utils_1 = require("../../utils"); | ||
const RemoveUnusedComponents = () => { | ||
import { isEmptyObject } from '../../utils.js'; | ||
export const RemoveUnusedComponents = () => { | ||
const components = new Map(); | ||
@@ -27,3 +24,3 @@ function registerComponent(location, componentType, name) { | ||
components.delete(path); | ||
if ((0, utils_1.isEmptyObject)(root[componentType])) { | ||
if (isEmptyObject(root[componentType])) { | ||
delete root[componentType]; | ||
@@ -90,2 +87,2 @@ } | ||
}; | ||
exports.RemoveUnusedComponents = RemoveUnusedComponents; | ||
//# sourceMappingURL=remove-unused-components.js.map |
@@ -1,4 +0,3 @@ | ||
import type { Oas3Decorator } from '../../visitors'; | ||
import type { Oas3Decorator } from '../../visitors.js'; | ||
export declare const decorators: { | ||
'registry-dependencies': Oas3Decorator; | ||
'operation-description-override': Oas3Decorator; | ||
@@ -13,1 +12,2 @@ 'tag-description-override': Oas3Decorator; | ||
}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,23 +0,19 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decorators = void 0; | ||
const registry_dependencies_1 = require("../common/registry-dependencies"); | ||
const operation_description_override_1 = require("../common/operation-description-override"); | ||
const tag_description_override_1 = require("../common/tag-description-override"); | ||
const info_description_override_1 = require("../common/info-description-override"); | ||
const info_override_1 = require("../common/info-override"); | ||
const remove_x_internal_1 = require("../common/remove-x-internal"); | ||
const filter_in_1 = require("../common/filters/filter-in"); | ||
const filter_out_1 = require("../common/filters/filter-out"); | ||
const media_type_examples_override_1 = require("../common/media-type-examples-override"); | ||
exports.decorators = { | ||
'registry-dependencies': registry_dependencies_1.RegistryDependencies, | ||
'operation-description-override': operation_description_override_1.OperationDescriptionOverride, | ||
'tag-description-override': tag_description_override_1.TagDescriptionOverride, | ||
'info-description-override': info_description_override_1.InfoDescriptionOverride, | ||
'info-override': info_override_1.InfoOverride, | ||
'remove-x-internal': remove_x_internal_1.RemoveXInternal, | ||
'filter-in': filter_in_1.FilterIn, | ||
'filter-out': filter_out_1.FilterOut, | ||
'media-type-examples-override': media_type_examples_override_1.MediaTypeExamplesOverride, | ||
import { OperationDescriptionOverride } from '../common/operation-description-override.js'; | ||
import { TagDescriptionOverride } from '../common/tag-description-override.js'; | ||
import { InfoDescriptionOverride } from '../common/info-description-override.js'; | ||
import { InfoOverride } from '../common/info-override.js'; | ||
import { RemoveXInternal } from '../common/remove-x-internal.js'; | ||
import { FilterIn } from '../common/filters/filter-in.js'; | ||
import { FilterOut } from '../common/filters/filter-out.js'; | ||
import { MediaTypeExamplesOverride } from '../common/media-type-examples-override.js'; | ||
export const decorators = { | ||
'operation-description-override': OperationDescriptionOverride, | ||
'tag-description-override': TagDescriptionOverride, | ||
'info-description-override': InfoDescriptionOverride, | ||
'info-override': InfoOverride, | ||
'remove-x-internal': RemoveXInternal, | ||
'filter-in': FilterIn, | ||
'filter-out': FilterOut, | ||
'media-type-examples-override': MediaTypeExamplesOverride, | ||
}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Decorator } from '../../visitors'; | ||
import type { Oas3Decorator } from '../../visitors.js'; | ||
export declare const RemoveUnusedComponents: Oas3Decorator; | ||
//# sourceMappingURL=remove-unused-components.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RemoveUnusedComponents = void 0; | ||
const utils_1 = require("../../utils"); | ||
const RemoveUnusedComponents = () => { | ||
import { isEmptyObject } from '../../utils.js'; | ||
export const RemoveUnusedComponents = () => { | ||
const components = new Map(); | ||
@@ -25,3 +22,3 @@ function registerComponent(location, componentType, name) { | ||
components.delete(path); | ||
if ((0, utils_1.isEmptyObject)(componentChild)) { | ||
if (isEmptyObject(componentChild)) { | ||
delete root.components[componentType]; | ||
@@ -62,3 +59,3 @@ } | ||
data.removedCount = removeUnusedComponents(root, []); | ||
if ((0, utils_1.isEmptyObject)(root.components)) { | ||
if (isEmptyObject(root.components)) { | ||
delete root.components; | ||
@@ -102,2 +99,2 @@ } | ||
}; | ||
exports.RemoveUnusedComponents = RemoveUnusedComponents; | ||
//# sourceMappingURL=remove-unused-components.js.map |
export declare const decorators: {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.decorators = void 0; | ||
exports.decorators = {}; | ||
export const decorators = {}; | ||
//# sourceMappingURL=index.js.map |
export declare const isBrowser: boolean; | ||
export declare const env: NodeJS.ProcessEnv; | ||
//# sourceMappingURL=env.d.ts.map |
@@ -1,7 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.env = exports.isBrowser = void 0; | ||
exports.isBrowser = typeof window !== 'undefined' || | ||
export const isBrowser = typeof window !== 'undefined' || | ||
typeof process === 'undefined' || | ||
process?.platform === 'browser'; // main and worker thread | ||
exports.env = exports.isBrowser ? {} : process.env || {}; | ||
export const env = isBrowser ? {} : process.env || {}; | ||
//# sourceMappingURL=env.js.map |
import * as yamlAst from 'yaml-ast-parser'; | ||
import type { LineColLocationObject, LocationObject } from '../walk'; | ||
import type { LineColLocationObject, LocationObject } from '../walk.js'; | ||
type YAMLMapping = yamlAst.YAMLMapping & { | ||
@@ -23,1 +23,2 @@ kind: yamlAst.Kind.MAPPING; | ||
export {}; | ||
//# sourceMappingURL=codeframes.d.ts.map |
@@ -1,9 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getCodeframe = getCodeframe; | ||
exports.getLineColLocation = getLineColLocation; | ||
exports.getAstNodeByPointer = getAstNodeByPointer; | ||
const yamlAst = require("yaml-ast-parser"); | ||
const ref_utils_1 = require("../ref-utils"); | ||
const logger_1 = require("../logger"); | ||
import * as yamlAst from 'yaml-ast-parser'; | ||
import { unescapePointer } from '../ref-utils.js'; | ||
import { colorize, colorOptions } from '../logger.js'; | ||
const MAX_LINE_LENGTH = 150; | ||
@@ -13,6 +8,6 @@ const MAX_CODEFRAME_LINES = 3; | ||
function parsePointer(pointer) { | ||
return pointer.substr(2).split('/').map(ref_utils_1.unescapePointer); | ||
return pointer.substr(2).split('/').map(unescapePointer); | ||
} | ||
function getCodeframe(location, color) { | ||
logger_1.colorOptions.enabled = color; | ||
export function getCodeframe(location, color) { | ||
colorOptions.enabled = color; | ||
const { start, end = { line: start.line, col: start.col + 1 }, source } = location; | ||
@@ -36,3 +31,3 @@ const lines = source.getLines(); | ||
const endIdx = i === endLineNum ? end.col - 1 : line.length; | ||
prefixedLines.push([`${i}`, markLine(line, startIdx, endIdx, logger_1.colorize.red)]); | ||
prefixedLines.push([`${i}`, markLine(line, startIdx, endIdx, colorize.red)]); | ||
if (!color) | ||
@@ -44,3 +39,3 @@ prefixedLines.push(['', underlineLine(line, startIdx, endIdx)]); | ||
`…`, | ||
`${whitespace(currentPad)}${logger_1.colorize.gray(`< ${skipLines} more lines >`)}`, | ||
`${whitespace(currentPad)}${colorize.gray(`< ${skipLines} more lines >`)}`, | ||
]); | ||
@@ -50,3 +45,3 @@ // print last line | ||
`${endLineNum}`, | ||
markLine(lines[endLineNum - 1], -1, end.col - 1, logger_1.colorize.red), | ||
markLine(lines[endLineNum - 1], -1, end.col - 1, colorize.red), | ||
]); | ||
@@ -63,3 +58,3 @@ if (!color) | ||
]); | ||
function markLine(line, startIdx = -1, endIdx = +Infinity, variant = logger_1.colorize.gray) { | ||
function markLine(line, startIdx = -1, endIdx = +Infinity, variant = colorize.gray) { | ||
if (!color) | ||
@@ -81,3 +76,3 @@ return line; | ||
return existingLines | ||
.map(([prefix, line]) => logger_1.colorize.gray(leftPad(padLen, prefix) + ' |') + | ||
.map(([prefix, line]) => colorize.gray(leftPad(padLen, prefix) + ' |') + | ||
(line ? ' ' + limitLineLength(line.substring(dedentLen)) : '')) | ||
@@ -89,3 +84,3 @@ .join('\n'); | ||
if (overflowLen > 0) { | ||
const charsMoreText = logger_1.colorize.gray(`...<${overflowLen} chars>`); | ||
const charsMoreText = colorize.gray(`...<${overflowLen} chars>`); | ||
return line.substring(0, maxLen - charsMoreText.length) + charsMoreText; | ||
@@ -117,3 +112,3 @@ } | ||
} | ||
function getLineColLocation(location) { | ||
export function getLineColLocation(location) { | ||
if (location.pointer === undefined) | ||
@@ -153,3 +148,3 @@ return location; | ||
} | ||
function getAstNodeByPointer(root, pointer, reportOnKey) { | ||
export function getAstNodeByPointer(root, pointer, reportOnKey) { | ||
const pointerSegments = parsePointer(pointer); | ||
@@ -195,1 +190,2 @@ if (root === undefined) { | ||
} | ||
//# sourceMappingURL=codeframes.js.map |
@@ -1,2 +0,2 @@ | ||
import type { NormalizedProblem } from '../walk'; | ||
import type { NormalizedProblem } from '../walk.js'; | ||
export type Totals = { | ||
@@ -21,1 +21,2 @@ errors: number; | ||
}): void; | ||
//# sourceMappingURL=format.d.ts.map |
@@ -1,12 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTotals = getTotals; | ||
exports.formatProblems = formatProblems; | ||
const path = require("path"); | ||
const logger_1 = require("../logger"); | ||
const output_1 = require("../output"); | ||
const codeframes_1 = require("./codeframes"); | ||
const env_1 = require("../env"); | ||
const ref_utils_1 = require("../ref-utils"); | ||
const coreVersion = require('../../package.json').version; | ||
import * as path from 'node:path'; | ||
import { colorOptions, colorize, logger } from '../logger.js'; | ||
import { getCodeframe, getLineColLocation } from './codeframes.js'; | ||
import { env, isBrowser } from '../env.js'; | ||
import { isAbsoluteUrl } from '../ref-utils.js'; | ||
const ERROR_MESSAGE = { | ||
@@ -16,8 +10,8 @@ INVALID_SEVERITY_LEVEL: 'Invalid severity level; accepted values: error or warn', | ||
const BG_COLORS = { | ||
warn: (str) => logger_1.colorize.bgYellow(logger_1.colorize.black(str)), | ||
error: logger_1.colorize.bgRed, | ||
warn: (str) => colorize.bgYellow(colorize.black(str)), | ||
error: colorize.bgRed, | ||
}; | ||
const COLORS = { | ||
warn: logger_1.colorize.yellow, | ||
error: logger_1.colorize.red, | ||
warn: colorize.yellow, | ||
error: colorize.red, | ||
}; | ||
@@ -36,3 +30,3 @@ const SEVERITY_NAMES = { | ||
} | ||
function getTotals(problems) { | ||
export function getTotals(problems) { | ||
let errors = 0; | ||
@@ -57,5 +51,5 @@ let warnings = 0; | ||
} | ||
function formatProblems(problems, opts) { | ||
const { maxProblems = 100, cwd = env_1.isBrowser ? '' : process.cwd(), format = 'codeframe', color = logger_1.colorOptions.enabled, totals = getTotals(problems), version = coreVersion, } = opts; | ||
logger_1.colorOptions.enabled = color; // force colors if specified | ||
export function formatProblems(problems, opts) { | ||
const { maxProblems = 100, cwd = isBrowser ? '' : process.cwd(), format = 'codeframe', color = colorOptions.enabled, totals = getTotals(problems), version = '2.0', } = opts; | ||
colorOptions.enabled = color; // force colors if specified | ||
const totalProblems = problems.length; | ||
@@ -76,3 +70,3 @@ problems = problems.filter((m) => !m.ignored); | ||
const problem = problems[i]; | ||
logger_1.logger.info(`${formatCodeframe(problem, i)}\n`); | ||
logger.output(`${formatCodeframe(problem, i)}\n`); | ||
} | ||
@@ -83,8 +77,8 @@ break; | ||
for (const [file, { ruleIdPad, locationPad: positionPad, fileProblems }] of Object.entries(groupedByFile)) { | ||
logger_1.logger.info(`${logger_1.colorize.blue((0, ref_utils_1.isAbsoluteUrl)(file) ? file : path.relative(cwd, file))}:\n`); | ||
logger.output(`${colorize.blue(isAbsoluteUrl(file) ? file : path.relative(cwd, file))}:\n`); | ||
for (let i = 0; i < fileProblems.length; i++) { | ||
const problem = fileProblems[i]; | ||
logger_1.logger.info(`${formatStylish(problem, positionPad, ruleIdPad)}\n`); | ||
logger.output(`${formatStylish(problem, positionPad, ruleIdPad)}\n`); | ||
} | ||
logger_1.logger.info('\n'); | ||
logger.output('\n'); | ||
} | ||
@@ -96,20 +90,20 @@ break; | ||
for (const [file, { fileProblems }] of Object.entries(groupedByFile)) { | ||
output_1.output.write(`## Lint: ${(0, ref_utils_1.isAbsoluteUrl)(file) ? file : path.relative(cwd, file)}\n\n`); | ||
output_1.output.write(`| Severity | Location | Problem | Message |\n`); | ||
output_1.output.write(`|---|---|---|---|\n`); | ||
logger.output(`## Lint: ${isAbsoluteUrl(file) ? file : path.relative(cwd, file)}\n\n`); | ||
logger.output(`| Severity | Location | Problem | Message |\n`); | ||
logger.output(`|---|---|---|---|\n`); | ||
for (let i = 0; i < fileProblems.length; i++) { | ||
const problem = fileProblems[i]; | ||
output_1.output.write(`${formatMarkdown(problem)}\n`); | ||
logger.output(`${formatMarkdown(problem)}\n`); | ||
} | ||
output_1.output.write('\n'); | ||
logger.output('\n'); | ||
if (totals.errors > 0) { | ||
output_1.output.write(`Validation failed\nErrors: ${totals.errors}\n`); | ||
logger.output(`Validation failed\nErrors: ${totals.errors}\n`); | ||
} | ||
else { | ||
output_1.output.write('Validation successful\n'); | ||
logger.output('Validation successful\n'); | ||
} | ||
if (totals.warnings > 0) { | ||
output_1.output.write(`Warnings: ${totals.warnings}\n`); | ||
logger.output(`Warnings: ${totals.warnings}\n`); | ||
} | ||
output_1.output.write('\n'); | ||
logger.output('\n'); | ||
} | ||
@@ -120,10 +114,10 @@ break; | ||
const groupedByFile = groupByFiles(problems); | ||
output_1.output.write('<?xml version="1.0" encoding="UTF-8"?>\n'); | ||
output_1.output.write('<checkstyle version="4.3">\n'); | ||
logger.output('<?xml version="1.0" encoding="UTF-8"?>\n'); | ||
logger.output('<checkstyle version="4.3">\n'); | ||
for (const [file, { fileProblems }] of Object.entries(groupedByFile)) { | ||
output_1.output.write(`<file name="${xmlEscape((0, ref_utils_1.isAbsoluteUrl)(file) ? file : path.relative(cwd, file))}">\n`); | ||
logger.output(`<file name="${xmlEscape(isAbsoluteUrl(file) ? file : path.relative(cwd, file))}">\n`); | ||
fileProblems.forEach(formatCheckstyle); | ||
output_1.output.write(`</file>\n`); | ||
logger.output(`</file>\n`); | ||
} | ||
output_1.output.write(`</checkstyle>\n`); | ||
logger.output(`</checkstyle>\n`); | ||
break; | ||
@@ -141,3 +135,3 @@ } | ||
if (totalProblems - ignoredProblems > maxProblems) { | ||
logger_1.logger.info(`< ... ${totalProblems - maxProblems} more problems hidden > ${logger_1.colorize.gray('increase with `--max-problems N`')}\n`); | ||
logger.info(`< ... ${totalProblems - maxProblems} more problems hidden > ${colorize.gray('increase with `--max-problems N`')}\n`); | ||
} | ||
@@ -147,7 +141,7 @@ function outputForCodeClimate() { | ||
const location = p.location[0]; // TODO: support multiple location | ||
const lineCol = (0, codeframes_1.getLineColLocation)(location); | ||
const lineCol = getLineColLocation(location); | ||
return { | ||
description: p.message, | ||
location: { | ||
path: (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef) | ||
path: isAbsoluteUrl(location.source.absoluteRef) | ||
? location.source.absoluteRef | ||
@@ -163,3 +157,3 @@ : path.relative(cwd, location.source.absoluteRef), | ||
}); | ||
output_1.output.write(JSON.stringify(issues, null, 2)); | ||
logger.output(JSON.stringify(issues, null, 2)); | ||
} | ||
@@ -176,3 +170,3 @@ function outputJSON() { | ||
source: { | ||
ref: (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef) | ||
ref: isAbsoluteUrl(location.source.absoluteRef) | ||
? location.source.absoluteRef | ||
@@ -186,3 +180,3 @@ : path.relative(cwd, location.source.absoluteRef), | ||
source: { | ||
ref: (0, ref_utils_1.isAbsoluteUrl)(p.from?.source.absoluteRef) | ||
ref: isAbsoluteUrl(p.from?.source.absoluteRef) | ||
? p.from?.source.absoluteRef | ||
@@ -194,6 +188,6 @@ : path.relative(cwd, p.from?.source.absoluteRef || cwd), | ||
}; | ||
if (env_1.env.FORMAT_JSON_WITH_CODEFRAMES) { | ||
if (env.FORMAT_JSON_WITH_CODEFRAMES) { | ||
const location = p.location[0]; // TODO: support multiple locations | ||
const loc = (0, codeframes_1.getLineColLocation)(location); | ||
problem.codeframe = (0, codeframes_1.getCodeframe)(loc, color); | ||
const loc = getLineColLocation(location); | ||
problem.codeframe = getCodeframe(loc, color); | ||
} | ||
@@ -203,3 +197,3 @@ return problem; | ||
}; | ||
output_1.output.write(JSON.stringify(resultObject, null, 2)); | ||
logger.output(JSON.stringify(resultObject, null, 2)); | ||
} | ||
@@ -216,7 +210,7 @@ function getBgColor(problem) { | ||
const location = problem.location[0]; // TODO: support multiple locations | ||
const relativePath = (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef) | ||
const relativePath = isAbsoluteUrl(location.source.absoluteRef) | ||
? location.source.absoluteRef | ||
: path.relative(cwd, location.source.absoluteRef); | ||
const loc = (0, codeframes_1.getLineColLocation)(location); | ||
const atPointer = location.pointer ? logger_1.colorize.gray(`at ${location.pointer}`) : ''; | ||
const loc = getLineColLocation(location); | ||
const atPointer = location.pointer ? colorize.gray(`at ${location.pointer}`) : ''; | ||
const fileWithLoc = `${relativePath}:${loc.start.line}:${loc.start.col}`; | ||
@@ -226,6 +220,6 @@ return (`[${idx + 1}] ${bgColor(fileWithLoc)} ${atPointer}\n\n` + | ||
formatDidYouMean(problem) + | ||
(0, codeframes_1.getCodeframe)(loc, color) + | ||
getCodeframe(loc, color) + | ||
'\n\n' + | ||
formatFrom(cwd, problem.from) + | ||
`${SEVERITY_NAMES[problem.severity]} was generated by the ${logger_1.colorize.blue(problem.ruleId)} rule.\n\n`); | ||
`${SEVERITY_NAMES[problem.severity]} was generated by the ${colorize.blue(problem.ruleId)} rule.\n\n`); | ||
} | ||
@@ -254,3 +248,3 @@ function formatStylish(problem, locationPad, ruleIdPad) { | ||
const source = xmlEscape(problem.ruleId); | ||
output_1.output.write(`<error line="${line}" column="${col}" severity="${severity}" message="${message}" source="${source}" />\n`); | ||
logger.output(`<error line="${line}" column="${col}" severity="${severity}" message="${message}" source="${source}" />\n`); | ||
} | ||
@@ -271,5 +265,5 @@ } | ||
const severityName = color(SEVERITY_NAMES[info.severity].toLowerCase().padEnd(7)); | ||
logger_1.logger.info(`${severityName} ${ruleId}: ${info.count}\n`); | ||
logger.output(`${severityName} ${ruleId}: ${info.count}\n`); | ||
} | ||
logger_1.logger.info('\n'); | ||
logger.output('\n'); | ||
} | ||
@@ -280,6 +274,6 @@ function formatFrom(cwd, location) { | ||
const relativePath = path.relative(cwd, location.source.absoluteRef); | ||
const loc = (0, codeframes_1.getLineColLocation)(location); | ||
const loc = getLineColLocation(location); | ||
const fileWithLoc = `${relativePath}:${loc.start.line}:${loc.start.col}`; | ||
const atPointer = location.pointer ? logger_1.colorize.gray(`at ${location.pointer}`) : ''; | ||
return `referenced from ${logger_1.colorize.blue(fileWithLoc)} ${atPointer} \n\n`; | ||
const atPointer = location.pointer ? colorize.gray(`at ${location.pointer}`) : ''; | ||
return `referenced from ${colorize.blue(fileWithLoc)} ${atPointer} \n\n`; | ||
} | ||
@@ -305,3 +299,3 @@ function formatDidYouMean(problem) { | ||
}; | ||
const mappedProblem = { ...problem, location: problem.location.map(codeframes_1.getLineColLocation) }; | ||
const mappedProblem = { ...problem, location: problem.location.map(getLineColLocation) }; | ||
fileGroups[absoluteRef].fileProblems.push(mappedProblem); | ||
@@ -334,3 +328,3 @@ fileGroups[absoluteRef].ruleIdPad = Math.max(problem.ruleId.length, fileGroups[absoluteRef].ruleIdPad); | ||
for (const problem of problems) { | ||
for (const location of problem.location.map(codeframes_1.getLineColLocation)) { | ||
for (const location of problem.location.map(getLineColLocation)) { | ||
let command; | ||
@@ -349,3 +343,3 @@ switch (problem.severity) { | ||
title: problem.ruleId, | ||
file: (0, ref_utils_1.isAbsoluteUrl)(location.source.absoluteRef) | ||
file: isAbsoluteUrl(location.source.absoluteRef) | ||
? location.source.absoluteRef | ||
@@ -358,3 +352,3 @@ : path.relative(cwd, location.source.absoluteRef), | ||
}; | ||
output_1.output.write(`::${command} ${formatProperties(properties)}::${escapeMessage(message)}\n`); | ||
logger.output(`::${command} ${formatProperties(properties)}::${escapeMessage(message)}\n`); | ||
} | ||
@@ -389,1 +383,2 @@ } | ||
} | ||
//# sourceMappingURL=format.js.map |
@@ -1,26 +0,29 @@ | ||
export { BundleOutputFormat, readFileFromUrl, slash, doesYamlFileExist, isTruthy, getProxyAgent, pause, } from './utils'; | ||
export { Oas3_1Types } from './types/oas3_1'; | ||
export { Arazzo1Types } from './types/arazzo'; | ||
export { Oas3Types } from './types/oas3'; | ||
export { Oas2Types } from './types/oas2'; | ||
export { AsyncApi2Types } from './types/asyncapi2'; | ||
export { AsyncApi3Types } from './types/asyncapi3'; | ||
export { ConfigTypes } from './types/redocly-yaml'; | ||
export type { Oas3Definition, Oas3_1Definition, Oas3Components, Oas3_1Components, Oas3PathItem, Oas3Paths, Oas3ComponentName, Oas3Schema, Oas3_1Schema, Oas3Tag, Referenced, OasRef, } from './typings/openapi'; | ||
export type { Oas2Definition } from './typings/swagger'; | ||
export type { StatsAccumulator, StatsName } from './typings/common'; | ||
export { normalizeTypes } from './types'; | ||
export { Stats } from './rules/other/stats'; | ||
export { Config, StyleguideConfig, RawConfig, RawUniversalConfig, IGNORE_FILE, Region, getMergedConfig, transformConfig, loadConfig, getConfig, findConfig, CONFIG_FILE_NAMES, RuleSeverity, createConfig, ResolvedApi, } from './config'; | ||
export { RedoclyClient } from './redocly'; | ||
export * from './redocly/domains'; | ||
export { Source, BaseResolver, Document, resolveDocument, ResolveError, YamlParseError, makeDocumentFromString, } from './resolve'; | ||
export { parseYaml, stringifyYaml } from './js-yaml'; | ||
export { unescapePointer, isRef, isAbsoluteUrl } from './ref-utils'; | ||
export { SpecMajorVersion, getMajorSpecVersion, SpecVersion, detectSpec, getTypes, } from './oas-types'; | ||
export { normalizeVisitors } from './visitors'; | ||
export { WalkContext, walkDocument, NormalizedProblem, ProblemSeverity, LineColLocationObject, LocationObject, Loc, } from './walk'; | ||
export { getAstNodeByPointer, getLineColLocation } from './format/codeframes'; | ||
export { formatProblems, OutputFormat, getTotals, Totals } from './format/format'; | ||
export { lint, lint as validate, lintDocument, lintFromString, lintConfig } from './lint'; | ||
export { bundle, bundleDocument, mapTypeToComponent, bundleFromString } from './bundle'; | ||
export { type BundleOutputFormat, type CollectFn, type StrictObject, readFileFromUrl, slash, doesYamlFileExist, isTruthy, pause, isPlainObject, dequal, pluralize, isEmptyObject, isNotEmptyArray, isNotEmptyObject, } from './utils.js'; | ||
export { Oas3_1Types } from './types/oas3_1.js'; | ||
export { Arazzo1Types } from './types/arazzo.js'; | ||
export type { ArazzoDefinition, ExtendedOperation } from './typings/arazzo.js'; | ||
export { Oas3Types } from './types/oas3.js'; | ||
export { Oas2Types } from './types/oas2.js'; | ||
export { AsyncApi2Types } from './types/asyncapi2.js'; | ||
export { AsyncApi3Types } from './types/asyncapi3.js'; | ||
export { ConfigTypes, createConfigTypes } from './types/redocly-yaml.js'; | ||
export type { Oas3Definition, Oas3_1Definition, Oas3Components, Oas3_1Components, Oas3PathItem, Oas3Paths, Oas3ComponentName, Oas3Schema, Oas3_1Schema, Oas3Tag, Referenced, OasRef, Oas3Parameter, Oas3Server, Oas3Operation, Oas3Responses, Oas3SecurityScheme, Oas3SecurityRequirement, } from './typings/openapi.js'; | ||
export type { Oas2Definition } from './typings/swagger.js'; | ||
export type { StatsAccumulator, StatsName } from './typings/common.js'; | ||
export { type NormalizedNodeType, type NodeType, normalizeTypes } from './types/index.js'; | ||
export { Stats } from './rules/other/stats.js'; | ||
export { type RawConfigProcessor, type ResolvedConfig, type Plugin, Config, StyleguideConfig, RawConfig, RawUniversalConfig, IGNORE_FILE, getMergedConfig, transformConfig, loadConfig, getConfig, findConfig, CONFIG_FILE_NAMES, RuleSeverity, createConfig, ResolvedApi, ConfigValidationError, resolvePlugins, } from './config/index.js'; | ||
export { type ResolvedRefMap, Source, BaseResolver, Document, resolveDocument, ResolveError, YamlParseError, makeDocumentFromString, } from './resolve.js'; | ||
export { parseYaml, stringifyYaml } from './js-yaml/index.js'; | ||
export { unescapePointer, isRef, isAbsoluteUrl, escapePointer } from './ref-utils.js'; | ||
export { SpecMajorVersion, getMajorSpecVersion, SpecVersion, detectSpec, getTypes, } from './oas-types.js'; | ||
export { normalizeVisitors } from './visitors.js'; | ||
export { WalkContext, walkDocument, NormalizedProblem, ProblemSeverity, LineColLocationObject, LocationObject, Loc, } from './walk.js'; | ||
export { getAstNodeByPointer, getLineColLocation, getCodeframe } from './format/codeframes.js'; | ||
export { formatProblems, OutputFormat, getTotals, Totals } from './format/format.js'; | ||
export { lint, lint as validate, lintDocument, lintFromString, lintConfig } from './lint.js'; | ||
export { type BundleResult, bundle, bundleDocument, mapTypeToComponent, bundleFromString, } from './bundle.js'; | ||
export { type Assertions, type Assertion } from './rules/common/assertions/index.js'; | ||
export { logger } from './logger.js'; | ||
export { HandledError } from './utils/error.js'; | ||
//# sourceMappingURL=index.d.ts.map |
122
lib/index.js
@@ -1,98 +0,24 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validate = exports.lint = exports.getTotals = exports.formatProblems = exports.getLineColLocation = exports.getAstNodeByPointer = exports.walkDocument = exports.normalizeVisitors = exports.getTypes = exports.detectSpec = exports.SpecVersion = exports.getMajorSpecVersion = exports.SpecMajorVersion = exports.isAbsoluteUrl = exports.isRef = exports.unescapePointer = exports.stringifyYaml = exports.parseYaml = exports.makeDocumentFromString = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.RedoclyClient = exports.createConfig = exports.CONFIG_FILE_NAMES = exports.findConfig = exports.getConfig = exports.loadConfig = exports.transformConfig = exports.getMergedConfig = exports.IGNORE_FILE = exports.StyleguideConfig = exports.Config = exports.Stats = exports.normalizeTypes = exports.ConfigTypes = exports.AsyncApi3Types = exports.AsyncApi2Types = exports.Oas2Types = exports.Oas3Types = exports.Arazzo1Types = exports.Oas3_1Types = exports.pause = exports.getProxyAgent = exports.isTruthy = exports.doesYamlFileExist = exports.slash = exports.readFileFromUrl = void 0; | ||
exports.bundleFromString = exports.mapTypeToComponent = exports.bundleDocument = exports.bundle = exports.lintConfig = exports.lintFromString = exports.lintDocument = void 0; | ||
var utils_1 = require("./utils"); | ||
Object.defineProperty(exports, "readFileFromUrl", { enumerable: true, get: function () { return utils_1.readFileFromUrl; } }); | ||
Object.defineProperty(exports, "slash", { enumerable: true, get: function () { return utils_1.slash; } }); | ||
Object.defineProperty(exports, "doesYamlFileExist", { enumerable: true, get: function () { return utils_1.doesYamlFileExist; } }); | ||
Object.defineProperty(exports, "isTruthy", { enumerable: true, get: function () { return utils_1.isTruthy; } }); | ||
Object.defineProperty(exports, "getProxyAgent", { enumerable: true, get: function () { return utils_1.getProxyAgent; } }); | ||
Object.defineProperty(exports, "pause", { enumerable: true, get: function () { return utils_1.pause; } }); | ||
var oas3_1_1 = require("./types/oas3_1"); | ||
Object.defineProperty(exports, "Oas3_1Types", { enumerable: true, get: function () { return oas3_1_1.Oas3_1Types; } }); | ||
var arazzo_1 = require("./types/arazzo"); | ||
Object.defineProperty(exports, "Arazzo1Types", { enumerable: true, get: function () { return arazzo_1.Arazzo1Types; } }); | ||
var oas3_1 = require("./types/oas3"); | ||
Object.defineProperty(exports, "Oas3Types", { enumerable: true, get: function () { return oas3_1.Oas3Types; } }); | ||
var oas2_1 = require("./types/oas2"); | ||
Object.defineProperty(exports, "Oas2Types", { enumerable: true, get: function () { return oas2_1.Oas2Types; } }); | ||
var asyncapi2_1 = require("./types/asyncapi2"); | ||
Object.defineProperty(exports, "AsyncApi2Types", { enumerable: true, get: function () { return asyncapi2_1.AsyncApi2Types; } }); | ||
var asyncapi3_1 = require("./types/asyncapi3"); | ||
Object.defineProperty(exports, "AsyncApi3Types", { enumerable: true, get: function () { return asyncapi3_1.AsyncApi3Types; } }); | ||
var redocly_yaml_1 = require("./types/redocly-yaml"); | ||
Object.defineProperty(exports, "ConfigTypes", { enumerable: true, get: function () { return redocly_yaml_1.ConfigTypes; } }); | ||
var types_1 = require("./types"); | ||
Object.defineProperty(exports, "normalizeTypes", { enumerable: true, get: function () { return types_1.normalizeTypes; } }); | ||
var stats_1 = require("./rules/other/stats"); | ||
Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return stats_1.Stats; } }); | ||
var config_1 = require("./config"); | ||
Object.defineProperty(exports, "Config", { enumerable: true, get: function () { return config_1.Config; } }); | ||
Object.defineProperty(exports, "StyleguideConfig", { enumerable: true, get: function () { return config_1.StyleguideConfig; } }); | ||
Object.defineProperty(exports, "IGNORE_FILE", { enumerable: true, get: function () { return config_1.IGNORE_FILE; } }); | ||
Object.defineProperty(exports, "getMergedConfig", { enumerable: true, get: function () { return config_1.getMergedConfig; } }); | ||
Object.defineProperty(exports, "transformConfig", { enumerable: true, get: function () { return config_1.transformConfig; } }); | ||
Object.defineProperty(exports, "loadConfig", { enumerable: true, get: function () { return config_1.loadConfig; } }); | ||
Object.defineProperty(exports, "getConfig", { enumerable: true, get: function () { return config_1.getConfig; } }); | ||
Object.defineProperty(exports, "findConfig", { enumerable: true, get: function () { return config_1.findConfig; } }); | ||
Object.defineProperty(exports, "CONFIG_FILE_NAMES", { enumerable: true, get: function () { return config_1.CONFIG_FILE_NAMES; } }); | ||
Object.defineProperty(exports, "createConfig", { enumerable: true, get: function () { return config_1.createConfig; } }); | ||
var redocly_1 = require("./redocly"); | ||
Object.defineProperty(exports, "RedoclyClient", { enumerable: true, get: function () { return redocly_1.RedoclyClient; } }); | ||
__exportStar(require("./redocly/domains"), exports); | ||
var resolve_1 = require("./resolve"); | ||
Object.defineProperty(exports, "Source", { enumerable: true, get: function () { return resolve_1.Source; } }); | ||
Object.defineProperty(exports, "BaseResolver", { enumerable: true, get: function () { return resolve_1.BaseResolver; } }); | ||
Object.defineProperty(exports, "resolveDocument", { enumerable: true, get: function () { return resolve_1.resolveDocument; } }); | ||
Object.defineProperty(exports, "ResolveError", { enumerable: true, get: function () { return resolve_1.ResolveError; } }); | ||
Object.defineProperty(exports, "YamlParseError", { enumerable: true, get: function () { return resolve_1.YamlParseError; } }); | ||
Object.defineProperty(exports, "makeDocumentFromString", { enumerable: true, get: function () { return resolve_1.makeDocumentFromString; } }); | ||
var js_yaml_1 = require("./js-yaml"); | ||
Object.defineProperty(exports, "parseYaml", { enumerable: true, get: function () { return js_yaml_1.parseYaml; } }); | ||
Object.defineProperty(exports, "stringifyYaml", { enumerable: true, get: function () { return js_yaml_1.stringifyYaml; } }); | ||
var ref_utils_1 = require("./ref-utils"); | ||
Object.defineProperty(exports, "unescapePointer", { enumerable: true, get: function () { return ref_utils_1.unescapePointer; } }); | ||
Object.defineProperty(exports, "isRef", { enumerable: true, get: function () { return ref_utils_1.isRef; } }); | ||
Object.defineProperty(exports, "isAbsoluteUrl", { enumerable: true, get: function () { return ref_utils_1.isAbsoluteUrl; } }); | ||
var oas_types_1 = require("./oas-types"); | ||
Object.defineProperty(exports, "SpecMajorVersion", { enumerable: true, get: function () { return oas_types_1.SpecMajorVersion; } }); | ||
Object.defineProperty(exports, "getMajorSpecVersion", { enumerable: true, get: function () { return oas_types_1.getMajorSpecVersion; } }); | ||
Object.defineProperty(exports, "SpecVersion", { enumerable: true, get: function () { return oas_types_1.SpecVersion; } }); | ||
Object.defineProperty(exports, "detectSpec", { enumerable: true, get: function () { return oas_types_1.detectSpec; } }); | ||
Object.defineProperty(exports, "getTypes", { enumerable: true, get: function () { return oas_types_1.getTypes; } }); | ||
var visitors_1 = require("./visitors"); | ||
Object.defineProperty(exports, "normalizeVisitors", { enumerable: true, get: function () { return visitors_1.normalizeVisitors; } }); | ||
var walk_1 = require("./walk"); | ||
Object.defineProperty(exports, "walkDocument", { enumerable: true, get: function () { return walk_1.walkDocument; } }); | ||
var codeframes_1 = require("./format/codeframes"); | ||
Object.defineProperty(exports, "getAstNodeByPointer", { enumerable: true, get: function () { return codeframes_1.getAstNodeByPointer; } }); | ||
Object.defineProperty(exports, "getLineColLocation", { enumerable: true, get: function () { return codeframes_1.getLineColLocation; } }); | ||
var format_1 = require("./format/format"); | ||
Object.defineProperty(exports, "formatProblems", { enumerable: true, get: function () { return format_1.formatProblems; } }); | ||
Object.defineProperty(exports, "getTotals", { enumerable: true, get: function () { return format_1.getTotals; } }); | ||
var lint_1 = require("./lint"); | ||
Object.defineProperty(exports, "lint", { enumerable: true, get: function () { return lint_1.lint; } }); | ||
Object.defineProperty(exports, "validate", { enumerable: true, get: function () { return lint_1.lint; } }); | ||
Object.defineProperty(exports, "lintDocument", { enumerable: true, get: function () { return lint_1.lintDocument; } }); | ||
Object.defineProperty(exports, "lintFromString", { enumerable: true, get: function () { return lint_1.lintFromString; } }); | ||
Object.defineProperty(exports, "lintConfig", { enumerable: true, get: function () { return lint_1.lintConfig; } }); | ||
var bundle_1 = require("./bundle"); | ||
Object.defineProperty(exports, "bundle", { enumerable: true, get: function () { return bundle_1.bundle; } }); | ||
Object.defineProperty(exports, "bundleDocument", { enumerable: true, get: function () { return bundle_1.bundleDocument; } }); | ||
Object.defineProperty(exports, "mapTypeToComponent", { enumerable: true, get: function () { return bundle_1.mapTypeToComponent; } }); | ||
Object.defineProperty(exports, "bundleFromString", { enumerable: true, get: function () { return bundle_1.bundleFromString; } }); | ||
export { readFileFromUrl, slash, doesYamlFileExist, isTruthy, pause, isPlainObject, dequal, pluralize, isEmptyObject, isNotEmptyArray, isNotEmptyObject, } from './utils.js'; | ||
export { Oas3_1Types } from './types/oas3_1.js'; | ||
export { Arazzo1Types } from './types/arazzo.js'; | ||
export { Oas3Types } from './types/oas3.js'; | ||
export { Oas2Types } from './types/oas2.js'; | ||
export { AsyncApi2Types } from './types/asyncapi2.js'; | ||
export { AsyncApi3Types } from './types/asyncapi3.js'; | ||
export { ConfigTypes, createConfigTypes } from './types/redocly-yaml.js'; | ||
export { normalizeTypes } from './types/index.js'; | ||
export { Stats } from './rules/other/stats.js'; | ||
export { Config, StyleguideConfig, IGNORE_FILE, getMergedConfig, transformConfig, loadConfig, getConfig, findConfig, CONFIG_FILE_NAMES, createConfig, ConfigValidationError, resolvePlugins, } from './config/index.js'; | ||
export { Source, BaseResolver, resolveDocument, ResolveError, YamlParseError, makeDocumentFromString, } from './resolve.js'; | ||
export { parseYaml, stringifyYaml } from './js-yaml/index.js'; | ||
export { unescapePointer, isRef, isAbsoluteUrl, escapePointer } from './ref-utils.js'; | ||
export { SpecMajorVersion, getMajorSpecVersion, SpecVersion, detectSpec, getTypes, } from './oas-types.js'; | ||
export { normalizeVisitors } from './visitors.js'; | ||
export { walkDocument, } from './walk.js'; | ||
export { getAstNodeByPointer, getLineColLocation, getCodeframe } from './format/codeframes.js'; | ||
export { formatProblems, getTotals } from './format/format.js'; | ||
export { lint, lint as validate, lintDocument, lintFromString, lintConfig } from './lint.js'; | ||
export { bundle, bundleDocument, mapTypeToComponent, bundleFromString, } from './bundle.js'; | ||
export { logger } from './logger.js'; | ||
export { HandledError } from './utils/error.js'; | ||
//# sourceMappingURL=index.js.map |
import type { LoadOptions, DumpOptions } from 'js-yaml'; | ||
export declare const parseYaml: (str: string, opts?: LoadOptions) => unknown; | ||
export declare const stringifyYaml: (obj: any, opts?: DumpOptions) => string; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,15 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stringifyYaml = exports.parseYaml = void 0; | ||
// TODO: add a type for "types" https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/js-yaml/index.d.ts | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
const js_yaml_1 = require("js-yaml"); | ||
const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = js_yaml_1.JSON_SCHEMA.extend({ | ||
implicit: [js_yaml_1.types.merge], | ||
explicit: [js_yaml_1.types.binary, js_yaml_1.types.omap, js_yaml_1.types.pairs, js_yaml_1.types.set], | ||
import { JSON_SCHEMA, types, load, dump } from 'js-yaml'; | ||
const DEFAULT_SCHEMA_WITHOUT_TIMESTAMP = JSON_SCHEMA.extend({ | ||
implicit: [types.merge], | ||
explicit: [types.binary, types.omap, types.pairs, types.set], | ||
}); | ||
const parseYaml = (str, opts) => (0, js_yaml_1.load)(str, { schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP, ...opts }); | ||
exports.parseYaml = parseYaml; | ||
const stringifyYaml = (obj, opts) => (0, js_yaml_1.dump)(obj, opts); | ||
exports.stringifyYaml = stringifyYaml; | ||
export const parseYaml = (str, opts) => load(str, { schema: DEFAULT_SCHEMA_WITHOUT_TIMESTAMP, ...opts }); | ||
export const stringifyYaml = (obj, opts) => dump(obj, opts); | ||
//# sourceMappingURL=index.js.map |
@@ -1,7 +0,7 @@ | ||
import { BaseResolver } from './resolve'; | ||
import type { StyleguideConfig, Config } from './config'; | ||
import type { Document, ResolvedRefMap } from './resolve'; | ||
import type { ProblemSeverity } from './walk'; | ||
import type { NodeType } from './types'; | ||
import type { CollectFn } from './utils'; | ||
import { BaseResolver } from './resolve.js'; | ||
import type { StyleguideConfig, Config } from './config/index.js'; | ||
import type { Document, ResolvedRefMap } from './resolve.js'; | ||
import type { ProblemSeverity } from './walk.js'; | ||
import type { NodeType } from './types/index.js'; | ||
import type { CollectFn } from './utils.js'; | ||
export declare function lint(opts: { | ||
@@ -12,3 +12,3 @@ ref: string; | ||
collectSpecData?: CollectFn; | ||
}): Promise<import("./walk").NormalizedProblem[]>; | ||
}): Promise<import("./walk.js").NormalizedProblem[]>; | ||
export declare function lintFromString(opts: { | ||
@@ -19,3 +19,3 @@ source: string; | ||
externalRefResolver?: BaseResolver; | ||
}): Promise<import("./walk").NormalizedProblem[]>; | ||
}): Promise<import("./walk.js").NormalizedProblem[]>; | ||
export declare function lintDocument(opts: { | ||
@@ -26,3 +26,3 @@ document: Document; | ||
externalRefResolver: BaseResolver; | ||
}): Promise<import("./walk").NormalizedProblem[]>; | ||
}): Promise<import("./walk.js").NormalizedProblem[]>; | ||
export declare function lintConfig(opts: { | ||
@@ -35,2 +35,3 @@ document: Document; | ||
externalConfigTypes?: Record<string, NodeType>; | ||
}): Promise<import("./walk").NormalizedProblem[]>; | ||
}): Promise<import("./walk.js").NormalizedProblem[]>; | ||
//# sourceMappingURL=lint.d.ts.map |
@@ -1,20 +0,14 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.lint = lint; | ||
exports.lintFromString = lintFromString; | ||
exports.lintDocument = lintDocument; | ||
exports.lintConfig = lintConfig; | ||
const config_1 = require("@redocly/config"); | ||
const resolve_1 = require("./resolve"); | ||
const visitors_1 = require("./visitors"); | ||
const walk_1 = require("./walk"); | ||
const config_2 = require("./config"); | ||
const types_1 = require("./types"); | ||
const ajv_1 = require("./rules/ajv"); | ||
const oas_types_1 = require("./oas-types"); | ||
const redocly_yaml_1 = require("./types/redocly-yaml"); | ||
const struct_1 = require("./rules/common/struct"); | ||
const no_unresolved_refs_1 = require("./rules/no-unresolved-refs"); | ||
async function lint(opts) { | ||
const { ref, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts; | ||
import { rootRedoclyConfigSchema } from '@redocly/config'; | ||
import { BaseResolver, resolveDocument, makeDocumentFromString } from './resolve.js'; | ||
import { normalizeVisitors } from './visitors.js'; | ||
import { walkDocument } from './walk.js'; | ||
import { initRules } from './config/rules.js'; | ||
import { normalizeTypes } from './types/index.js'; | ||
import { releaseAjvInstance } from './rules/ajv.js'; | ||
import { SpecVersion, getMajorSpecVersion, detectSpec, getTypes } from './oas-types.js'; | ||
import { createConfigTypes } from './types/redocly-yaml.js'; | ||
import { Struct } from './rules/common/struct.js'; | ||
import { NoUnresolvedRefs } from './rules/no-unresolved-refs.js'; | ||
export async function lint(opts) { | ||
const { ref, externalRefResolver = new BaseResolver(opts.config.resolve) } = opts; | ||
const document = (await externalRefResolver.resolveDocument(null, ref, true)); | ||
@@ -29,5 +23,5 @@ opts.collectSpecData?.(document.parsed); | ||
} | ||
async function lintFromString(opts) { | ||
const { source, absoluteRef, externalRefResolver = new resolve_1.BaseResolver(opts.config.resolve) } = opts; | ||
const document = (0, resolve_1.makeDocumentFromString)(source, absoluteRef || '/'); | ||
export async function lintFromString(opts) { | ||
const { source, absoluteRef, externalRefResolver = new BaseResolver(opts.config.resolve) } = opts; | ||
const document = makeDocumentFromString(source, absoluteRef || '/'); | ||
return lintDocument({ | ||
@@ -40,9 +34,9 @@ document, | ||
} | ||
async function lintDocument(opts) { | ||
(0, ajv_1.releaseAjvInstance)(); // FIXME: preprocessors can modify nodes which are then cached to ajv-instance by absolute path | ||
export async function lintDocument(opts) { | ||
releaseAjvInstance(); // FIXME: preprocessors can modify nodes which are then cached to ajv-instance by absolute path | ||
const { document, customTypes, externalRefResolver, config } = opts; | ||
const specVersion = (0, oas_types_1.detectSpec)(document.parsed); | ||
const specMajorVersion = (0, oas_types_1.getMajorSpecVersion)(specVersion); | ||
const specVersion = detectSpec(document.parsed); | ||
const specMajorVersion = getMajorSpecVersion(specVersion); | ||
const rules = config.getRulesForSpecVersion(specMajorVersion); | ||
const types = (0, types_1.normalizeTypes)(config.extendTypes(customTypes ?? (0, oas_types_1.getTypes)(specVersion), specVersion), config); | ||
const types = normalizeTypes(config.extendTypes(customTypes ?? getTypes(specVersion), specVersion), config); | ||
const ctx = { | ||
@@ -53,5 +47,5 @@ problems: [], | ||
}; | ||
const preprocessors = (0, config_2.initRules)(rules, config, 'preprocessors', specVersion); | ||
const regularRules = (0, config_2.initRules)(rules, config, 'rules', specVersion); | ||
let resolvedRefMap = await (0, resolve_1.resolveDocument)({ | ||
const preprocessors = initRules(rules, config, 'preprocessors', specVersion); | ||
const regularRules = initRules(rules, config, 'rules', specVersion); | ||
let resolvedRefMap = await resolveDocument({ | ||
rootDocument: document, | ||
@@ -63,10 +57,10 @@ rootType: types.Root, | ||
// Make additional pass to resolve refs defined in preprocessors. | ||
(0, walk_1.walkDocument)({ | ||
walkDocument({ | ||
document, | ||
rootType: types.Root, | ||
normalizedVisitors: (0, visitors_1.normalizeVisitors)(preprocessors, types), | ||
normalizedVisitors: normalizeVisitors(preprocessors, types), | ||
resolvedRefMap, | ||
ctx, | ||
}); | ||
resolvedRefMap = await (0, resolve_1.resolveDocument)({ | ||
resolvedRefMap = await resolveDocument({ | ||
rootDocument: document, | ||
@@ -77,4 +71,4 @@ rootType: types.Root, | ||
} | ||
const normalizedVisitors = (0, visitors_1.normalizeVisitors)(regularRules, types); | ||
(0, walk_1.walkDocument)({ | ||
const normalizedVisitors = normalizeVisitors(regularRules, types); | ||
walkDocument({ | ||
document, | ||
@@ -88,15 +82,15 @@ rootType: types.Root, | ||
} | ||
async function lintConfig(opts) { | ||
const { document, severity, externalRefResolver = new resolve_1.BaseResolver(), config } = opts; | ||
export async function lintConfig(opts) { | ||
const { document, severity, externalRefResolver = new BaseResolver(), config } = opts; | ||
const ctx = { | ||
problems: [], | ||
oasVersion: oas_types_1.SpecVersion.OAS3_0, | ||
oasVersion: SpecVersion.OAS3_0, | ||
visitorsData: {}, | ||
}; | ||
const types = (0, types_1.normalizeTypes)(opts.externalConfigTypes || (0, redocly_yaml_1.createConfigTypes)(config_1.rootRedoclyConfigSchema, config), { doNotResolveExamples: config.styleguide.doNotResolveExamples }); | ||
const types = normalizeTypes(opts.externalConfigTypes || createConfigTypes(rootRedoclyConfigSchema, config), { doNotResolveExamples: config.styleguide.doNotResolveExamples }); | ||
const rules = [ | ||
{ | ||
severity: severity || 'error', | ||
ruleId: 'configuration spec', | ||
visitor: (0, struct_1.Struct)({ severity: 'error' }), | ||
ruleId: 'configuration struct', | ||
visitor: Struct({ severity: 'error' }), | ||
}, | ||
@@ -106,8 +100,8 @@ { | ||
ruleId: 'configuration no-unresolved-refs', | ||
visitor: (0, no_unresolved_refs_1.NoUnresolvedRefs)({ severity: 'error' }), | ||
visitor: NoUnresolvedRefs({ severity: 'error' }), | ||
}, | ||
]; | ||
const normalizedVisitors = (0, visitors_1.normalizeVisitors)(rules, types); | ||
const normalizedVisitors = normalizeVisitors(rules, types); | ||
const resolvedRefMap = opts.resolvedRefMap || | ||
(await (0, resolve_1.resolveDocument)({ | ||
(await resolveDocument({ | ||
rootDocument: document, | ||
@@ -117,3 +111,3 @@ rootType: types.ConfigRoot, | ||
})); | ||
(0, walk_1.walkDocument)({ | ||
walkDocument({ | ||
document, | ||
@@ -127,1 +121,2 @@ rootType: types.ConfigRoot, | ||
} | ||
//# sourceMappingURL=lint.js.map |
@@ -7,8 +7,9 @@ import * as colorette from 'colorette'; | ||
declare class Logger { | ||
protected stderr(str: string): boolean; | ||
info(str: string): boolean | void; | ||
warn(str: string): boolean | void; | ||
error(str: string): boolean | void; | ||
output(str: string): boolean | void; | ||
} | ||
export declare const logger: Logger; | ||
export {}; | ||
//# sourceMappingURL=logger.d.ts.map |
@@ -1,14 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.logger = exports.colorize = exports.colorOptions = void 0; | ||
const colorette = require("colorette"); | ||
const env_1 = require("./env"); | ||
const utils_1 = require("./utils"); | ||
import * as colorette from 'colorette'; | ||
import { isBrowser } from './env.js'; | ||
import { identity } from './utils.js'; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore this works but some types are not working | ||
exports.colorOptions = colorette.options; | ||
exports.colorize = new Proxy(colorette, { | ||
export const colorOptions = colorette.options; | ||
export const colorize = new Proxy(colorette, { | ||
get(target, prop) { | ||
if (env_1.isBrowser) { | ||
return utils_1.identity; | ||
if (isBrowser) { | ||
return identity; | ||
} | ||
@@ -19,15 +16,16 @@ return target[prop]; | ||
class Logger { | ||
stderr(str) { | ||
return process.stderr.write(str); | ||
} | ||
info(str) { | ||
return env_1.isBrowser ? console.log(str) : this.stderr(str); | ||
return isBrowser ? console.info(str) : process.stderr.write(str); | ||
} | ||
warn(str) { | ||
return env_1.isBrowser ? console.warn(str) : this.stderr(exports.colorize.yellow(str)); | ||
return isBrowser ? console.warn(str) : process.stderr.write(colorize.yellow(str)); | ||
} | ||
error(str) { | ||
return env_1.isBrowser ? console.error(str) : this.stderr(exports.colorize.red(str)); | ||
return isBrowser ? console.error(str) : process.stderr.write(colorize.red(str)); | ||
} | ||
output(str) { | ||
return isBrowser ? console.info(str) : process.stdout.write(str); | ||
} | ||
} | ||
exports.logger = new Logger(); | ||
export const logger = new Logger(); | ||
//# sourceMappingURL=logger.js.map |
@@ -1,3 +0,3 @@ | ||
import type { BuiltInAsync2RuleId, BuiltInAsync3RuleId, BuiltInArazzo1RuleId, BuiltInOAS2RuleId, BuiltInOAS3RuleId, BuiltInOverlay1RuleId } from './types/redocly-yaml'; | ||
import type { Oas3Rule, Oas3Preprocessor, Oas2Rule, Oas2Preprocessor, Async2Preprocessor, Async2Rule, Async3Preprocessor, Async3Rule, Arazzo1Preprocessor, Arazzo1Rule, Overlay1Preprocessor, Overlay1Rule } from './visitors'; | ||
import type { BuiltInAsync2RuleId, BuiltInAsync3RuleId, BuiltInArazzo1RuleId, BuiltInOAS2RuleId, BuiltInOAS3RuleId, BuiltInOverlay1RuleId } from './types/redocly-yaml.js'; | ||
import type { Oas3Rule, Oas3Preprocessor, Oas2Rule, Oas2Preprocessor, Async2Preprocessor, Async2Rule, Async3Preprocessor, Async3Rule, Arazzo1Preprocessor, Arazzo1Rule, Overlay1Preprocessor, Overlay1Rule } from './visitors.js'; | ||
export declare enum SpecVersion { | ||
@@ -41,2 +41,3 @@ OAS2 = "oas2", | ||
export declare function getMajorSpecVersion(version: SpecVersion): SpecMajorVersion; | ||
export declare function getTypes(spec: SpecVersion): Record<string, import("./types").NodeType> | Record<"Root" | "Tag" | "TagList" | "ExternalDocs" | "SecurityRequirement" | "SecurityRequirementList" | "Info" | "Contact" | "License" | "Paths" | "PathItem" | "Parameter" | "ParameterList" | "ParameterItems" | "Operation" | "Example" | "ExamplesMap" | "Examples" | "Header" | "Responses" | "Response" | "Schema" | "Xml" | "SchemaProperties" | "NamedSchemas" | "NamedResponses" | "NamedParameters" | "NamedSecuritySchemes" | "SecurityScheme" | "TagGroup" | "TagGroups" | "EnumDescriptions" | "Logo" | "XCodeSample" | "XCodeSampleList" | "XServer" | "XServerList", import("./types").NodeType> | Record<"Root" | "Tag" | "TagList" | "ExternalDocs" | "SecurityRequirement" | "SecurityRequirementList" | "Info" | "Contact" | "License" | "Paths" | "PathItem" | "Parameter" | "ParameterList" | "Operation" | "Example" | "ExamplesMap" | "Header" | "Responses" | "Response" | "Schema" | "Xml" | "SchemaProperties" | "NamedSchemas" | "NamedResponses" | "NamedParameters" | "NamedSecuritySchemes" | "SecurityScheme" | "TagGroup" | "TagGroups" | "EnumDescriptions" | "Logo" | "XCodeSample" | "XCodeSampleList" | "Server" | "ServerList" | "ServerVariable" | "ServerVariablesMap" | "Callback" | "CallbacksMap" | "RequestBody" | "MediaTypesMap" | "MediaType" | "Encoding" | "EncodingMap" | "HeadersMap" | "Link" | "LinksMap" | "DiscriminatorMapping" | "Discriminator" | "Components" | "NamedExamples" | "NamedRequestBodies" | "NamedHeaders" | "NamedLinks" | "NamedCallbacks" | "ImplicitFlow" | "PasswordFlow" | "ClientCredentials" | "AuthorizationCode" | "OAuth2Flows" | "XUsePkce" | "WebhooksMap", import("./types").NodeType> | Record<"Root" | "Info" | "License" | "Operation" | "Schema" | "SchemaProperties" | "SecurityScheme" | "Components" | "PatternProperties" | "NamedPathItems" | "DependentRequired", import("./types").NodeType>; | ||
export declare function getTypes(spec: SpecVersion): Record<string, import("./index.js").NodeType> | Record<"Root" | "Tag" | "TagList" | "ExternalDocs" | "SecurityRequirement" | "SecurityRequirementList" | "Info" | "Contact" | "License" | "Paths" | "PathItem" | "Parameter" | "ParameterList" | "ParameterItems" | "Operation" | "Example" | "ExamplesMap" | "Examples" | "Header" | "Responses" | "Response" | "Schema" | "Xml" | "SchemaProperties" | "NamedSchemas" | "NamedResponses" | "NamedParameters" | "NamedSecuritySchemes" | "SecurityScheme" | "TagGroup" | "TagGroups" | "EnumDescriptions" | "Logo" | "XCodeSample" | "XCodeSampleList" | "XServer" | "XServerList", import("./index.js").NodeType> | Record<"Root" | "Tag" | "TagList" | "ExternalDocs" | "SecurityRequirement" | "SecurityRequirementList" | "Info" | "Contact" | "License" | "Paths" | "PathItem" | "Parameter" | "ParameterList" | "Operation" | "Example" | "ExamplesMap" | "Header" | "Responses" | "Response" | "Schema" | "Xml" | "SchemaProperties" | "NamedSchemas" | "NamedResponses" | "NamedParameters" | "NamedSecuritySchemes" | "SecurityScheme" | "TagGroup" | "TagGroups" | "EnumDescriptions" | "Logo" | "XCodeSample" | "XCodeSampleList" | "Server" | "ServerList" | "ServerVariable" | "ServerVariablesMap" | "Callback" | "CallbacksMap" | "RequestBody" | "MediaTypesMap" | "MediaType" | "Encoding" | "EncodingMap" | "HeadersMap" | "Link" | "LinksMap" | "DiscriminatorMapping" | "Discriminator" | "Components" | "NamedExamples" | "NamedRequestBodies" | "NamedHeaders" | "NamedLinks" | "NamedCallbacks" | "ImplicitFlow" | "PasswordFlow" | "ClientCredentials" | "AuthorizationCode" | "OAuth2Flows" | "XUsePkce" | "WebhooksMap", import("./index.js").NodeType> | Record<"Root" | "Info" | "License" | "Operation" | "Schema" | "SchemaProperties" | "SecurityScheme" | "Components" | "PatternProperties" | "NamedPathItems" | "DependentRequired", import("./index.js").NodeType>; | ||
//# sourceMappingURL=oas-types.d.ts.map |
@@ -1,17 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SpecMajorVersion = exports.SpecVersion = void 0; | ||
exports.detectSpec = detectSpec; | ||
exports.getMajorSpecVersion = getMajorSpecVersion; | ||
exports.getTypes = getTypes; | ||
const oas2_1 = require("./types/oas2"); | ||
const oas3_1 = require("./types/oas3"); | ||
const oas3_1_1 = require("./types/oas3_1"); | ||
const asyncapi2_1 = require("./types/asyncapi2"); | ||
const asyncapi3_1 = require("./types/asyncapi3"); | ||
const arazzo_1 = require("./types/arazzo"); | ||
const overlay_1 = require("./types/overlay"); | ||
const utils_1 = require("./utils"); | ||
const arazzo_2 = require("./typings/arazzo"); | ||
var SpecVersion; | ||
import { Oas2Types } from './types/oas2.js'; | ||
import { Oas3Types } from './types/oas3.js'; | ||
import { Oas3_1Types } from './types/oas3_1.js'; | ||
import { AsyncApi2Types } from './types/asyncapi2.js'; | ||
import { AsyncApi3Types } from './types/asyncapi3.js'; | ||
import { Arazzo1Types } from './types/arazzo.js'; | ||
import { Overlay1Types } from './types/overlay.js'; | ||
import { isPlainObject } from './utils.js'; | ||
import { VERSION_PATTERN } from './typings/arazzo.js'; | ||
export var SpecVersion; | ||
(function (SpecVersion) { | ||
@@ -25,4 +19,4 @@ SpecVersion["OAS2"] = "oas2"; | ||
SpecVersion["Overlay1"] = "overlay1"; | ||
})(SpecVersion || (exports.SpecVersion = SpecVersion = {})); | ||
var SpecMajorVersion; | ||
})(SpecVersion || (SpecVersion = {})); | ||
export var SpecMajorVersion; | ||
(function (SpecMajorVersion) { | ||
@@ -35,14 +29,14 @@ SpecMajorVersion["OAS2"] = "oas2"; | ||
SpecMajorVersion["Overlay1"] = "overlay1"; | ||
})(SpecMajorVersion || (exports.SpecMajorVersion = SpecMajorVersion = {})); | ||
})(SpecMajorVersion || (SpecMajorVersion = {})); | ||
const typesMap = { | ||
[SpecVersion.OAS2]: oas2_1.Oas2Types, | ||
[SpecVersion.OAS3_0]: oas3_1.Oas3Types, | ||
[SpecVersion.OAS3_1]: oas3_1_1.Oas3_1Types, | ||
[SpecVersion.Async2]: asyncapi2_1.AsyncApi2Types, | ||
[SpecVersion.Async3]: asyncapi3_1.AsyncApi3Types, | ||
[SpecVersion.Arazzo1]: arazzo_1.Arazzo1Types, | ||
[SpecVersion.Overlay1]: overlay_1.Overlay1Types, | ||
[SpecVersion.OAS2]: Oas2Types, | ||
[SpecVersion.OAS3_0]: Oas3Types, | ||
[SpecVersion.OAS3_1]: Oas3_1Types, | ||
[SpecVersion.Async2]: AsyncApi2Types, | ||
[SpecVersion.Async3]: AsyncApi3Types, | ||
[SpecVersion.Arazzo1]: Arazzo1Types, | ||
[SpecVersion.Overlay1]: Overlay1Types, | ||
}; | ||
function detectSpec(root) { | ||
if (!(0, utils_1.isPlainObject)(root)) { | ||
export function detectSpec(root) { | ||
if (!isPlainObject(root)) { | ||
throw new Error(`Document must be JSON object, got ${typeof root}`); | ||
@@ -74,6 +68,6 @@ } | ||
} | ||
if (typeof root.arazzo === 'string' && arazzo_2.VERSION_PATTERN.test(root.arazzo)) { | ||
if (typeof root.arazzo === 'string' && VERSION_PATTERN.test(root.arazzo)) { | ||
return SpecVersion.Arazzo1; | ||
} | ||
if (typeof root.overlay === 'string' && arazzo_2.VERSION_PATTERN.test(root.overlay)) { | ||
if (typeof root.overlay === 'string' && VERSION_PATTERN.test(root.overlay)) { | ||
return SpecVersion.Overlay1; | ||
@@ -83,3 +77,3 @@ } | ||
} | ||
function getMajorSpecVersion(version) { | ||
export function getMajorSpecVersion(version) { | ||
if (version === SpecVersion.OAS2) { | ||
@@ -104,4 +98,5 @@ return SpecMajorVersion.OAS2; | ||
} | ||
function getTypes(spec) { | ||
export function getTypes(spec) { | ||
return typesMap[spec]; | ||
} | ||
//# sourceMappingURL=oas-types.js.map |
@@ -1,3 +0,3 @@ | ||
import type { Source } from './resolve'; | ||
import type { OasRef } from './typings/openapi'; | ||
import type { Source } from './resolve.js'; | ||
import type { OasRef } from './typings/openapi.js'; | ||
export declare function joinPointer(base: string, key: string | number): string; | ||
@@ -28,1 +28,2 @@ export declare function isRef(node: unknown): node is OasRef; | ||
export declare function isAnchor(ref: string): boolean; | ||
//# sourceMappingURL=ref-utils.d.ts.map |
@@ -1,18 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Location = void 0; | ||
exports.joinPointer = joinPointer; | ||
exports.isRef = isRef; | ||
exports.isExternalValue = isExternalValue; | ||
exports.unescapePointer = unescapePointer; | ||
exports.escapePointer = escapePointer; | ||
exports.parseRef = parseRef; | ||
exports.parsePointer = parsePointer; | ||
exports.pointerBaseName = pointerBaseName; | ||
exports.refBaseName = refBaseName; | ||
exports.isAbsoluteUrl = isAbsoluteUrl; | ||
exports.isMappingRef = isMappingRef; | ||
exports.isAnchor = isAnchor; | ||
const utils_1 = require("./utils"); | ||
function joinPointer(base, key) { | ||
import { isPlainObject, isTruthy } from './utils.js'; | ||
export function joinPointer(base, key) { | ||
if (base === '') | ||
@@ -22,9 +7,9 @@ base = '#/'; | ||
} | ||
function isRef(node) { | ||
return (0, utils_1.isPlainObject)(node) && typeof node.$ref === 'string'; | ||
export function isRef(node) { | ||
return isPlainObject(node) && typeof node.$ref === 'string'; | ||
} | ||
function isExternalValue(node) { | ||
return (0, utils_1.isPlainObject)(node) && typeof node.externalValue === 'string'; | ||
export function isExternalValue(node) { | ||
return isPlainObject(node) && typeof node.externalValue === 'string'; | ||
} | ||
class Location { | ||
export class Location { | ||
constructor(source, pointer) { | ||
@@ -44,7 +29,6 @@ this.source = source; | ||
} | ||
exports.Location = Location; | ||
function unescapePointer(fragment) { | ||
export function unescapePointer(fragment) { | ||
return decodeURIComponent(fragment.replace(/~1/g, '/').replace(/~0/g, '~')); | ||
} | ||
function escapePointer(fragment) { | ||
export function escapePointer(fragment) { | ||
if (typeof fragment === 'number') | ||
@@ -54,3 +38,3 @@ return fragment; | ||
} | ||
function parseRef(ref) { | ||
export function parseRef(ref) { | ||
const [uri, pointer = ''] = ref.split('#/'); | ||
@@ -62,10 +46,10 @@ return { | ||
} | ||
function parsePointer(pointer) { | ||
return pointer.split('/').map(unescapePointer).filter(utils_1.isTruthy); | ||
export function parsePointer(pointer) { | ||
return pointer.split('/').map(unescapePointer).filter(isTruthy); | ||
} | ||
function pointerBaseName(pointer) { | ||
export function pointerBaseName(pointer) { | ||
const parts = pointer.split('/'); | ||
return parts[parts.length - 1]; | ||
} | ||
function refBaseName(ref) { | ||
export function refBaseName(ref) { | ||
// eslint-disable-next-line no-useless-escape | ||
@@ -75,6 +59,6 @@ const parts = ref.split(/[\/\\]/); // split by '\' and '/' | ||
} | ||
function isAbsoluteUrl(ref) { | ||
export function isAbsoluteUrl(ref) { | ||
return ref.startsWith('http://') || ref.startsWith('https://'); | ||
} | ||
function isMappingRef(mapping) { | ||
export function isMappingRef(mapping) { | ||
// TODO: proper detection of mapping refs | ||
@@ -88,4 +72,5 @@ return (mapping.startsWith('#') || | ||
} | ||
function isAnchor(ref) { | ||
export function isAnchor(ref) { | ||
return /^#[A-Za-z][A-Za-z0-9\-_:.]*$/.test(ref); | ||
} | ||
//# sourceMappingURL=ref-utils.js.map |
import type { YAMLNode, LoadOptions } from 'yaml-ast-parser'; | ||
import type { NormalizedNodeType } from './types'; | ||
import type { ResolveConfig } from './config/types'; | ||
import type { NormalizedNodeType } from './types/index.js'; | ||
import type { ResolveConfig } from './config/types.js'; | ||
export type CollectedRefs = Map<string, Document>; | ||
@@ -67,1 +67,2 @@ export declare class Source { | ||
}): Promise<ResolvedRefMap>; | ||
//# sourceMappingURL=resolve.d.ts.map |
@@ -1,13 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BaseResolver = exports.YamlParseError = exports.ResolveError = exports.Source = void 0; | ||
exports.makeRefId = makeRefId; | ||
exports.makeDocumentFromString = makeDocumentFromString; | ||
exports.resolveDocument = resolveDocument; | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const ref_utils_1 = require("./ref-utils"); | ||
const types_1 = require("./types"); | ||
const utils_1 = require("./utils"); | ||
class Source { | ||
import * as fs from 'node:fs'; | ||
import * as path from 'node:path'; | ||
import { isRef, joinPointer, escapePointer, parseRef, isAbsoluteUrl, isAnchor, isExternalValue, } from './ref-utils.js'; | ||
import { isNamedType, SpecExtension } from './types/index.js'; | ||
import { readFileFromUrl, parseYaml, nextTick } from './utils.js'; | ||
export class Source { | ||
constructor(absoluteRef, body, mimeType) { | ||
@@ -40,4 +34,3 @@ this.absoluteRef = absoluteRef; | ||
} | ||
exports.Source = Source; | ||
class ResolveError extends Error { | ||
export class ResolveError extends Error { | ||
constructor(originalError) { | ||
@@ -50,5 +43,4 @@ super(originalError.message); | ||
} | ||
exports.ResolveError = ResolveError; | ||
const jsYamlErrorLineColRegexp = /\((\d+):(\d+)\)$/; | ||
class YamlParseError extends Error { | ||
export class YamlParseError extends Error { | ||
constructor(originalError, source) { | ||
@@ -65,7 +57,6 @@ super(originalError.message.split('\n')[0]); | ||
} | ||
exports.YamlParseError = YamlParseError; | ||
function makeRefId(absoluteRef, pointer) { | ||
export function makeRefId(absoluteRef, pointer) { | ||
return absoluteRef + '::' + pointer; | ||
} | ||
function makeDocumentFromString(sourceString, absoluteRef) { | ||
export function makeDocumentFromString(sourceString, absoluteRef) { | ||
const source = new Source(absoluteRef, sourceString); | ||
@@ -75,3 +66,3 @@ try { | ||
source, | ||
parsed: (0, utils_1.parseYaml)(sourceString, { filename: absoluteRef }), | ||
parsed: parseYaml(sourceString, { filename: absoluteRef }), | ||
}; | ||
@@ -83,3 +74,3 @@ } | ||
} | ||
class BaseResolver { | ||
export class BaseResolver { | ||
constructor(config = { http: { headers: [] } }) { | ||
@@ -93,6 +84,6 @@ this.config = config; | ||
resolveExternalRef(base, ref) { | ||
if ((0, ref_utils_1.isAbsoluteUrl)(ref)) { | ||
if (isAbsoluteUrl(ref)) { | ||
return ref; | ||
} | ||
if (base && (0, ref_utils_1.isAbsoluteUrl)(base)) { | ||
if (base && isAbsoluteUrl(base)) { | ||
return new URL(ref, base).href; | ||
@@ -104,4 +95,4 @@ } | ||
try { | ||
if ((0, ref_utils_1.isAbsoluteUrl)(absoluteRef)) { | ||
const { body, mimeType } = await (0, utils_1.readFileFromUrl)(absoluteRef, this.config.http); | ||
if (isAbsoluteUrl(absoluteRef)) { | ||
const { body, mimeType } = await readFileFromUrl(absoluteRef, this.config.http); | ||
return new Source(absoluteRef, body, mimeType); | ||
@@ -134,3 +125,3 @@ } | ||
source, | ||
parsed: (0, utils_1.parseYaml)(source.body, { filename: source.absoluteRef }), | ||
parsed: parseYaml(source.body, { filename: source.absoluteRef }), | ||
}; | ||
@@ -155,3 +146,2 @@ } | ||
} | ||
exports.BaseResolver = BaseResolver; | ||
function pushRef(head, node) { | ||
@@ -174,3 +164,3 @@ return { | ||
const resolvableScalarType = { name: 'scalar', properties: {} }; | ||
async function resolveDocument(opts) { | ||
export async function resolveDocument(opts) { | ||
const { rootDocument, externalRefResolver, rootType } = opts; | ||
@@ -206,3 +196,3 @@ const resolvedRefMap = new Map(); | ||
// we continue resolving unknown types, but stop early on known scalars | ||
if (itemsType === undefined && type !== unknownType && type !== types_1.SpecExtension) { | ||
if (itemsType === undefined && type !== unknownType && type !== SpecExtension) { | ||
return; | ||
@@ -213,9 +203,9 @@ } | ||
const itemType = isTypeAFunction | ||
? itemsType(node[i], (0, ref_utils_1.joinPointer)(nodeAbsoluteRef, i)) | ||
? itemsType(node[i], joinPointer(nodeAbsoluteRef, i)) | ||
: itemsType; | ||
// we continue resolving unknown types, but stop early on known scalars | ||
if (itemType === undefined && type !== unknownType && type !== types_1.SpecExtension) { | ||
if (itemType === undefined && type !== unknownType && type !== SpecExtension) { | ||
continue; | ||
} | ||
walk(node[i], (0, types_1.isNamedType)(itemType) ? itemType : unknownType, (0, ref_utils_1.joinPointer)(nodeAbsoluteRef, i)); | ||
walk(node[i], isNamedType(itemType) ? itemType : unknownType, joinPointer(nodeAbsoluteRef, i)); | ||
} | ||
@@ -236,5 +226,5 @@ return; | ||
propType === unknownType) { | ||
propType = types_1.SpecExtension; | ||
propType = SpecExtension; | ||
} | ||
if (!(0, types_1.isNamedType)(propType) && propType?.directResolveAs) { | ||
if (!isNamedType(propType) && propType?.directResolveAs) { | ||
propType = propType.directResolveAs; | ||
@@ -246,8 +236,8 @@ propValue = { $ref: propValue }; | ||
} | ||
if (!(0, types_1.isNamedType)(propType) || typeof propValue !== 'object') { | ||
if (!isNamedType(propType) || typeof propValue !== 'object') { | ||
continue; | ||
} | ||
walk(propValue, propType, (0, ref_utils_1.joinPointer)(nodeAbsoluteRef, (0, ref_utils_1.escapePointer)(propName))); | ||
walk(propValue, propType, joinPointer(nodeAbsoluteRef, escapePointer(propName))); | ||
} | ||
if ((0, ref_utils_1.isRef)(node)) { | ||
if (isRef(node)) { | ||
const promise = followRef(rootNodeDocument, node, { | ||
@@ -264,3 +254,3 @@ prev: null, | ||
// handle example.externalValue as reference | ||
if ((0, ref_utils_1.isExternalValue)(node)) { | ||
if (isExternalValue(node)) { | ||
const promise = followRef(rootNodeDocument, { $ref: node.externalValue }, { | ||
@@ -281,5 +271,5 @@ prev: null, | ||
} | ||
if ((0, ref_utils_1.isAnchor)(ref.$ref)) { | ||
if (isAnchor(ref.$ref)) { | ||
// Wait for all anchors in the document to be collected firstly. | ||
await (0, utils_1.nextTick)(); | ||
await nextTick(); | ||
const resolvedRef = { | ||
@@ -296,3 +286,3 @@ resolved: true, | ||
} | ||
const { uri, pointer } = (0, ref_utils_1.parseRef)(ref.$ref); | ||
const { uri, pointer } = parseRef(ref.$ref); | ||
const isRemote = uri !== null; | ||
@@ -332,5 +322,5 @@ let targetDoc; | ||
target = target[segment]; | ||
resolvedRef.nodePointer = (0, ref_utils_1.joinPointer)(resolvedRef.nodePointer, (0, ref_utils_1.escapePointer)(segment)); | ||
resolvedRef.nodePointer = joinPointer(resolvedRef.nodePointer, escapePointer(segment)); | ||
} | ||
else if ((0, ref_utils_1.isRef)(target)) { | ||
else if (isRef(target)) { | ||
resolvedRef = await followRef(targetDoc, target, pushRef(refStack, target)); | ||
@@ -343,3 +333,3 @@ targetDoc = resolvedRef.document || targetDoc; | ||
target = resolvedRef.node[segment]; | ||
resolvedRef.nodePointer = (0, ref_utils_1.joinPointer)(resolvedRef.nodePointer, (0, ref_utils_1.escapePointer)(segment)); | ||
resolvedRef.nodePointer = joinPointer(resolvedRef.nodePointer, escapePointer(segment)); | ||
} | ||
@@ -354,3 +344,3 @@ else { | ||
const refId = makeRefId(document.source.absoluteRef, ref.$ref); | ||
if (resolvedRef.document && (0, ref_utils_1.isRef)(target)) { | ||
if (resolvedRef.document && isRef(target)) { | ||
resolvedRef = await followRef(resolvedRef.document, target, pushRef(refStack, target)); | ||
@@ -363,1 +353,2 @@ } | ||
} | ||
//# sourceMappingURL=resolve.js.map |
@@ -1,4 +0,4 @@ | ||
import type { Location } from '../ref-utils'; | ||
import type { ErrorObject } from '@redocly/ajv/dist/2020'; | ||
import type { ResolveFn } from '../walk'; | ||
import type { Location } from '../ref-utils.js'; | ||
import type { ErrorObject } from '@redocly/ajv/dist/2020.js'; | ||
import type { ResolveFn } from '../walk.js'; | ||
export declare function releaseAjvInstance(): void; | ||
@@ -11,1 +11,2 @@ export declare function validateJsonSchema(data: any, schema: any, schemaLoc: Location, instancePath: string, resolve: ResolveFn, allowAdditionalProperties: boolean): { | ||
}; | ||
//# sourceMappingURL=ajv.d.ts.map |
@@ -1,9 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.releaseAjvInstance = releaseAjvInstance; | ||
exports.validateJsonSchema = validateJsonSchema; | ||
const _2020_1 = require("@redocly/ajv/dist/2020"); | ||
const ref_utils_1 = require("../ref-utils"); | ||
import Ajv from '@redocly/ajv/dist/2020.js'; | ||
import { escapePointer } from '../ref-utils.js'; | ||
let ajvInstance = null; | ||
function releaseAjvInstance() { | ||
export function releaseAjvInstance() { | ||
ajvInstance = null; | ||
@@ -13,3 +9,3 @@ } | ||
if (!ajvInstance) { | ||
ajvInstance = new _2020_1.default({ | ||
ajvInstance = new Ajv({ | ||
schemaId: '$id', | ||
@@ -43,3 +39,3 @@ meta: true, | ||
} | ||
function validateJsonSchema(data, schema, schemaLoc, instancePath, resolve, allowAdditionalProperties) { | ||
export function validateJsonSchema(data, schema, schemaLoc, instancePath, resolve, allowAdditionalProperties) { | ||
const validate = getAjvValidator(schema, schemaLoc, resolve, allowAdditionalProperties); | ||
@@ -76,3 +72,3 @@ if (!validate) | ||
message = `${message} \`${property}\``; | ||
error.instancePath += '/' + (0, ref_utils_1.escapePointer)(property); | ||
error.instancePath += '/' + escapePointer(property); | ||
} | ||
@@ -86,1 +82,2 @@ return { | ||
} | ||
//# sourceMappingURL=ajv.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const CriteriaUnique: Arazzo1Rule; | ||
//# sourceMappingURL=criteria-unique.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CriteriaUnique = void 0; | ||
const CriteriaUnique = () => { | ||
export const CriteriaUnique = () => { | ||
return { | ||
@@ -71,2 +68,2 @@ FailureActionObject: { | ||
}; | ||
exports.CriteriaUnique = CriteriaUnique; | ||
//# sourceMappingURL=criteria-unique.js.map |
@@ -1,3 +0,4 @@ | ||
import type { Arazzo1RuleSet } from '../../oas-types'; | ||
import type { Arazzo1RuleSet } from '../../oas-types.js'; | ||
export declare const rules: Arazzo1RuleSet<'built-in'>; | ||
export declare const preprocessors: {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,36 +0,34 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.preprocessors = exports.rules = void 0; | ||
const struct_1 = require("../common/struct"); | ||
const assertions_1 = require("../common/assertions"); | ||
const sourceDescription_type_1 = require("../arazzo/sourceDescription-type"); | ||
const sourceDescriptions_not_empty_1 = require("./sourceDescriptions-not-empty"); | ||
const respect_supported_versions_1 = require("../respect/respect-supported-versions"); | ||
const workflowId_unique_1 = require("./workflowId-unique"); | ||
const stepId_unique_1 = require("./stepId-unique"); | ||
const sourceDescriptions_name_unique_1 = require("./sourceDescriptions-name-unique"); | ||
const workflow_dependsOn_1 = require("./workflow-dependsOn"); | ||
const parameters_unique_1 = require("./parameters-unique"); | ||
const step_onSuccess_unique_1 = require("./step-onSuccess-unique"); | ||
const step_onFailure_unique_1 = require("./step-onFailure-unique"); | ||
const requestBody_replacements_unique_1 = require("./requestBody-replacements-unique"); | ||
const no_criteria_xpath_1 = require("../respect/no-criteria-xpath"); | ||
const criteria_unique_1 = require("./criteria-unique"); | ||
exports.rules = { | ||
struct: struct_1.Struct, | ||
assertions: assertions_1.Assertions, | ||
'sourceDescription-type': sourceDescription_type_1.SourceDescriptionType, | ||
'respect-supported-versions': respect_supported_versions_1.RespectSupportedVersions, | ||
'workflowId-unique': workflowId_unique_1.WorkflowIdUnique, | ||
'stepId-unique': stepId_unique_1.StepIdUnique, | ||
'sourceDescription-name-unique': sourceDescriptions_name_unique_1.SourceDescriptionsNameUnique, | ||
'sourceDescriptions-not-empty': sourceDescriptions_not_empty_1.SourceDescriptionsNotEmpty, | ||
'workflow-dependsOn': workflow_dependsOn_1.WorkflowDependsOn, | ||
'parameters-unique': parameters_unique_1.ParametersUnique, | ||
'step-onSuccess-unique': step_onSuccess_unique_1.StepOnSuccessUnique, | ||
'step-onFailure-unique': step_onFailure_unique_1.StepOnFailureUnique, | ||
'requestBody-replacements-unique': requestBody_replacements_unique_1.RequestBodyReplacementsUnique, | ||
'no-criteria-xpath': no_criteria_xpath_1.NoCriteriaXpath, | ||
'criteria-unique': criteria_unique_1.CriteriaUnique, | ||
import { Struct } from '../common/struct.js'; | ||
import { Assertions } from '../common/assertions/index.js'; | ||
import { SourceDescriptionType } from '../arazzo/sourceDescription-type.js'; | ||
import { SourceDescriptionsNotEmpty } from './sourceDescriptions-not-empty.js'; | ||
import { RespectSupportedVersions } from '../respect/respect-supported-versions.js'; | ||
import { WorkflowIdUnique } from './workflowId-unique.js'; | ||
import { StepIdUnique } from './stepId-unique.js'; | ||
import { SourceDescriptionsNameUnique } from './sourceDescriptions-name-unique.js'; | ||
import { WorkflowDependsOn } from './workflow-dependsOn.js'; | ||
import { ParametersUnique } from './parameters-unique.js'; | ||
import { StepOnSuccessUnique } from './step-onSuccess-unique.js'; | ||
import { StepOnFailureUnique } from './step-onFailure-unique.js'; | ||
import { RequestBodyReplacementsUnique } from './requestBody-replacements-unique.js'; | ||
import { NoCriteriaXpath } from '../respect/no-criteria-xpath.js'; | ||
import { CriteriaUnique } from './criteria-unique.js'; | ||
export const rules = { | ||
struct: Struct, | ||
assertions: Assertions, | ||
'sourceDescription-type': SourceDescriptionType, | ||
'respect-supported-versions': RespectSupportedVersions, | ||
'workflowId-unique': WorkflowIdUnique, | ||
'stepId-unique': StepIdUnique, | ||
'sourceDescription-name-unique': SourceDescriptionsNameUnique, | ||
'sourceDescriptions-not-empty': SourceDescriptionsNotEmpty, | ||
'workflow-dependsOn': WorkflowDependsOn, | ||
'parameters-unique': ParametersUnique, | ||
'step-onSuccess-unique': StepOnSuccessUnique, | ||
'step-onFailure-unique': StepOnFailureUnique, | ||
'requestBody-replacements-unique': RequestBodyReplacementsUnique, | ||
'no-criteria-xpath': NoCriteriaXpath, | ||
'criteria-unique': CriteriaUnique, | ||
}; | ||
exports.preprocessors = {}; | ||
export const preprocessors = {}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const ParametersUnique: Arazzo1Rule; | ||
//# sourceMappingURL=parameters-unique.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ParametersUnique = void 0; | ||
const ParametersUnique = () => { | ||
export const ParametersUnique = () => { | ||
return { | ||
@@ -32,2 +29,2 @@ Parameters: { | ||
}; | ||
exports.ParametersUnique = ParametersUnique; | ||
//# sourceMappingURL=parameters-unique.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const RequestBodyReplacementsUnique: Arazzo1Rule; | ||
//# sourceMappingURL=requestBody-replacements-unique.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RequestBodyReplacementsUnique = void 0; | ||
const RequestBodyReplacementsUnique = () => { | ||
export const RequestBodyReplacementsUnique = () => { | ||
const seenReplacements = new Set(); | ||
@@ -33,2 +30,2 @@ return { | ||
}; | ||
exports.RequestBodyReplacementsUnique = RequestBodyReplacementsUnique; | ||
//# sourceMappingURL=requestBody-replacements-unique.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const SourceDescriptionType: Arazzo1Rule; | ||
//# sourceMappingURL=sourceDescription-type.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SourceDescriptionType = void 0; | ||
const SourceDescriptionType = () => { | ||
export const SourceDescriptionType = () => { | ||
return { | ||
@@ -22,2 +19,2 @@ SourceDescriptions: { | ||
}; | ||
exports.SourceDescriptionType = SourceDescriptionType; | ||
//# sourceMappingURL=sourceDescription-type.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const SourceDescriptionsNameUnique: Arazzo1Rule; | ||
//# sourceMappingURL=sourceDescriptions-name-unique.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SourceDescriptionsNameUnique = void 0; | ||
const SourceDescriptionsNameUnique = () => { | ||
export const SourceDescriptionsNameUnique = () => { | ||
const seenSourceDescriptions = new Set(); | ||
@@ -24,2 +21,2 @@ return { | ||
}; | ||
exports.SourceDescriptionsNameUnique = SourceDescriptionsNameUnique; | ||
//# sourceMappingURL=sourceDescriptions-name-unique.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const SourceDescriptionsNotEmpty: Arazzo1Rule; | ||
//# sourceMappingURL=sourceDescriptions-not-empty.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SourceDescriptionsNotEmpty = void 0; | ||
const SourceDescriptionsNotEmpty = () => { | ||
export const SourceDescriptionsNotEmpty = () => { | ||
return { | ||
@@ -18,2 +15,2 @@ SourceDescriptions: { | ||
}; | ||
exports.SourceDescriptionsNotEmpty = SourceDescriptionsNotEmpty; | ||
//# sourceMappingURL=sourceDescriptions-not-empty.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const StepOnFailureUnique: Arazzo1Rule; | ||
//# sourceMappingURL=step-onFailure-unique.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StepOnFailureUnique = void 0; | ||
const StepOnFailureUnique = () => { | ||
export const StepOnFailureUnique = () => { | ||
return { | ||
@@ -32,2 +29,2 @@ OnFailureActionList: { | ||
}; | ||
exports.StepOnFailureUnique = StepOnFailureUnique; | ||
//# sourceMappingURL=step-onFailure-unique.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const StepOnSuccessUnique: Arazzo1Rule; | ||
//# sourceMappingURL=step-onSuccess-unique.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StepOnSuccessUnique = void 0; | ||
const StepOnSuccessUnique = () => { | ||
export const StepOnSuccessUnique = () => { | ||
return { | ||
@@ -32,2 +29,2 @@ OnSuccessActionList: { | ||
}; | ||
exports.StepOnSuccessUnique = StepOnSuccessUnique; | ||
//# sourceMappingURL=step-onSuccess-unique.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const StepIdUnique: Arazzo1Rule; | ||
//# sourceMappingURL=stepId-unique.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.StepIdUnique = void 0; | ||
const StepIdUnique = () => { | ||
export const StepIdUnique = () => { | ||
return { | ||
@@ -26,2 +23,2 @@ Workflow: { | ||
}; | ||
exports.StepIdUnique = StepIdUnique; | ||
//# sourceMappingURL=stepId-unique.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const WorkflowDependsOn: Arazzo1Rule; | ||
//# sourceMappingURL=workflow-dependsOn.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WorkflowDependsOn = void 0; | ||
const WorkflowDependsOn = () => { | ||
export const WorkflowDependsOn = () => { | ||
const seenWorkflow = new Set(); | ||
@@ -56,2 +53,2 @@ const existingSourceDescriptions = new Set(); | ||
}; | ||
exports.WorkflowDependsOn = WorkflowDependsOn; | ||
//# sourceMappingURL=workflow-dependsOn.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const WorkflowIdUnique: Arazzo1Rule; | ||
//# sourceMappingURL=workflowId-unique.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WorkflowIdUnique = void 0; | ||
const WorkflowIdUnique = () => { | ||
export const WorkflowIdUnique = () => { | ||
const seenWorkflow = new Set(); | ||
@@ -22,2 +19,2 @@ return { | ||
}; | ||
exports.WorkflowIdUnique = WorkflowIdUnique; | ||
//# sourceMappingURL=workflowId-unique.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Async2Rule } from '../../visitors'; | ||
import type { Async2Rule } from '../../visitors.js'; | ||
export declare const ChannelsKebabCase: Async2Rule; | ||
//# sourceMappingURL=channels-kebab-case.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ChannelsKebabCase = void 0; | ||
const ChannelsKebabCase = () => { | ||
export const ChannelsKebabCase = () => { | ||
return { | ||
@@ -19,2 +16,2 @@ Channel(_channel, { report, key }) { | ||
}; | ||
exports.ChannelsKebabCase = ChannelsKebabCase; | ||
//# sourceMappingURL=channels-kebab-case.js.map |
@@ -1,3 +0,4 @@ | ||
import type { Async2RuleSet } from '../../oas-types'; | ||
import type { Async2RuleSet } from '../../oas-types.js'; | ||
export declare const rules: Async2RuleSet<'built-in'>; | ||
export declare const preprocessors: {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,27 +0,22 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.preprocessors = exports.rules = void 0; | ||
const assertions_1 = require("../common/assertions"); | ||
const struct_1 = require("../common/struct"); | ||
const info_contact_1 = require("../common/info-contact"); | ||
const info_license_strict_1 = require("../common/info-license-strict"); | ||
const operation_operationId_1 = require("../common/operation-operationId"); | ||
const tag_description_1 = require("../common/tag-description"); | ||
const tags_alphabetical_1 = require("../common/tags-alphabetical"); | ||
const channels_kebab_case_1 = require("./channels-kebab-case"); | ||
const no_channel_trailing_slash_1 = require("./no-channel-trailing-slash"); | ||
exports.rules = { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore TODO: This is depricated property `spec` and should be removed in the future | ||
spec: struct_1.Struct, | ||
struct: struct_1.Struct, | ||
assertions: assertions_1.Assertions, | ||
'info-contact': info_contact_1.InfoContact, | ||
'info-license-strict': info_license_strict_1.InfoLicenseStrict, | ||
'operation-operationId': operation_operationId_1.OperationOperationId, | ||
'channels-kebab-case': channels_kebab_case_1.ChannelsKebabCase, | ||
'no-channel-trailing-slash': no_channel_trailing_slash_1.NoChannelTrailingSlash, | ||
'tag-description': tag_description_1.TagDescription, | ||
'tags-alphabetical': tags_alphabetical_1.TagsAlphabetical, | ||
import { Assertions } from '../common/assertions/index.js'; | ||
import { Struct } from '../common/struct.js'; | ||
import { InfoContact } from '../common/info-contact.js'; | ||
import { InfoLicenseStrict } from '../common/info-license-strict.js'; | ||
import { OperationOperationId } from '../common/operation-operationId.js'; | ||
import { TagDescription } from '../common/tag-description.js'; | ||
import { TagsAlphabetical } from '../common/tags-alphabetical.js'; | ||
import { ChannelsKebabCase } from './channels-kebab-case.js'; | ||
import { NoChannelTrailingSlash } from './no-channel-trailing-slash.js'; | ||
export const rules = { | ||
struct: Struct, | ||
assertions: Assertions, | ||
'info-contact': InfoContact, | ||
'info-license-strict': InfoLicenseStrict, | ||
'operation-operationId': OperationOperationId, | ||
'channels-kebab-case': ChannelsKebabCase, | ||
'no-channel-trailing-slash': NoChannelTrailingSlash, | ||
'tag-description': TagDescription, | ||
'tags-alphabetical': TagsAlphabetical, | ||
}; | ||
exports.preprocessors = {}; | ||
export const preprocessors = {}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Async2Rule } from '../../visitors'; | ||
import type { Async2Rule } from '../../visitors.js'; | ||
export declare const NoChannelTrailingSlash: Async2Rule; | ||
//# sourceMappingURL=no-channel-trailing-slash.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoChannelTrailingSlash = void 0; | ||
const NoChannelTrailingSlash = () => { | ||
export const NoChannelTrailingSlash = () => { | ||
return { | ||
@@ -16,2 +13,2 @@ Channel(_channel, { report, key, location }) { | ||
}; | ||
exports.NoChannelTrailingSlash = NoChannelTrailingSlash; | ||
//# sourceMappingURL=no-channel-trailing-slash.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Async3Rule } from '../../visitors'; | ||
import type { Async3Rule } from '../../visitors.js'; | ||
export declare const ChannelsKebabCase: Async3Rule; | ||
//# sourceMappingURL=channels-kebab-case.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ChannelsKebabCase = void 0; | ||
const ChannelsKebabCase = () => { | ||
export const ChannelsKebabCase = () => { | ||
return { | ||
@@ -19,2 +16,2 @@ Channel(channel, { report }) { | ||
}; | ||
exports.ChannelsKebabCase = ChannelsKebabCase; | ||
//# sourceMappingURL=channels-kebab-case.js.map |
@@ -1,3 +0,4 @@ | ||
import type { Async3RuleSet } from '../../oas-types'; | ||
import type { Async3RuleSet } from '../../oas-types.js'; | ||
export declare const rules: Async3RuleSet<'built-in'>; | ||
export declare const preprocessors: {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,27 +0,22 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.preprocessors = exports.rules = void 0; | ||
const assertions_1 = require("../common/assertions"); | ||
const struct_1 = require("../common/struct"); | ||
const info_contact_1 = require("../common/info-contact"); | ||
const info_license_strict_1 = require("../common/info-license-strict"); | ||
const operation_operationId_1 = require("../common/operation-operationId"); | ||
const tag_description_1 = require("../common/tag-description"); | ||
const tags_alphabetical_1 = require("../common/tags-alphabetical"); | ||
const channels_kebab_case_1 = require("./channels-kebab-case"); | ||
const no_channel_trailing_slash_1 = require("./no-channel-trailing-slash"); | ||
exports.rules = { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore TODO: This is depricated property `spec` and should be removed in the future | ||
spec: struct_1.Struct, | ||
struct: struct_1.Struct, | ||
assertions: assertions_1.Assertions, | ||
'info-contact': info_contact_1.InfoContact, | ||
'info-license-strict': info_license_strict_1.InfoLicenseStrict, | ||
'operation-operationId': operation_operationId_1.OperationOperationId, | ||
'channels-kebab-case': channels_kebab_case_1.ChannelsKebabCase, | ||
'no-channel-trailing-slash': no_channel_trailing_slash_1.NoChannelTrailingSlash, | ||
'tag-description': tag_description_1.TagDescription, | ||
'tags-alphabetical': tags_alphabetical_1.TagsAlphabetical, | ||
import { Assertions } from '../common/assertions/index.js'; | ||
import { Struct } from '../common/struct.js'; | ||
import { InfoContact } from '../common/info-contact.js'; | ||
import { InfoLicenseStrict } from '../common/info-license-strict.js'; | ||
import { OperationOperationId } from '../common/operation-operationId.js'; | ||
import { TagDescription } from '../common/tag-description.js'; | ||
import { TagsAlphabetical } from '../common/tags-alphabetical.js'; | ||
import { ChannelsKebabCase } from './channels-kebab-case.js'; | ||
import { NoChannelTrailingSlash } from './no-channel-trailing-slash.js'; | ||
export const rules = { | ||
struct: Struct, | ||
assertions: Assertions, | ||
'info-contact': InfoContact, | ||
'info-license-strict': InfoLicenseStrict, | ||
'operation-operationId': OperationOperationId, | ||
'channels-kebab-case': ChannelsKebabCase, | ||
'no-channel-trailing-slash': NoChannelTrailingSlash, | ||
'tag-description': TagDescription, | ||
'tags-alphabetical': TagsAlphabetical, | ||
}; | ||
exports.preprocessors = {}; | ||
export const preprocessors = {}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Async3Rule } from '../../visitors'; | ||
import type { Async3Rule } from '../../visitors.js'; | ||
export declare const NoChannelTrailingSlash: Async3Rule; | ||
//# sourceMappingURL=no-channel-trailing-slash.d.ts.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoChannelTrailingSlash = void 0; | ||
const NoChannelTrailingSlash = () => { | ||
export const NoChannelTrailingSlash = () => { | ||
return { | ||
Channel(channel, { report, location }) { | ||
if (channel.address.endsWith('/') && channel.address !== '/') { | ||
if (channel?.address?.endsWith('/') && channel?.address !== '/') { | ||
report({ | ||
@@ -16,2 +13,2 @@ message: `\`${channel.address}\` should not have a trailing slash.`, | ||
}; | ||
exports.NoChannelTrailingSlash = NoChannelTrailingSlash; | ||
//# sourceMappingURL=no-channel-trailing-slash.js.map |
@@ -1,3 +0,3 @@ | ||
import type { AssertionContext, AssertResult, CustomFunction } from '../../../config/types'; | ||
import type { Location } from '../../../ref-utils'; | ||
import type { AssertionContext, AssertResult, CustomFunction } from '../../../config/types.js'; | ||
import type { Location } from '../../../ref-utils.js'; | ||
export type AssertionFnContext = AssertionContext & { | ||
@@ -31,1 +31,2 @@ baseLocation: Location; | ||
export declare function buildAssertCustomFunction(fn: CustomFunction): AssertionFn; | ||
//# sourceMappingURL=asserts.d.ts.map |
@@ -1,8 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.asserts = exports.runOnValuesSet = exports.runOnKeysSet = void 0; | ||
exports.buildAssertCustomFunction = buildAssertCustomFunction; | ||
const utils_1 = require("../../../utils"); | ||
const utils_2 = require("./utils"); | ||
exports.runOnKeysSet = new Set([ | ||
import { isPlainObject, isString as runOnValue, isTruthy } from '../../../utils.js'; | ||
import { isOrdered, getIntersectionLength, regexFromString } from './utils.js'; | ||
export const runOnKeysSet = new Set([ | ||
'mutuallyExclusive', | ||
@@ -24,3 +20,3 @@ 'mutuallyRequired', | ||
]); | ||
exports.runOnValuesSet = new Set([ | ||
export const runOnValuesSet = new Set([ | ||
'pattern', | ||
@@ -39,37 +35,37 @@ 'notPattern', | ||
]); | ||
exports.asserts = { | ||
export const asserts = { | ||
pattern: (value, condition, { baseLocation, rawValue }) => { | ||
if (typeof value === 'undefined' || (0, utils_1.isPlainObject)(value)) | ||
if (typeof value === 'undefined' || isPlainObject(value)) | ||
return []; // property doesn't exist or is an object, no need to lint it with this assert | ||
const values = Array.isArray(value) ? value : [value]; | ||
const regex = (0, utils_2.regexFromString)(condition); | ||
const regex = regexFromString(condition); | ||
return values | ||
.map((_val) => !regex?.test(_val) && { | ||
message: `"${_val}" should match a regex ${condition}`, | ||
location: (0, utils_1.isString)(value) | ||
location: runOnValue(value) | ||
? baseLocation | ||
: (0, utils_1.isPlainObject)(rawValue) | ||
: isPlainObject(rawValue) | ||
? baseLocation.child(_val).key() | ||
: baseLocation.key(), | ||
}) | ||
.filter(utils_1.isTruthy); | ||
.filter(isTruthy); | ||
}, | ||
notPattern: (value, condition, { baseLocation, rawValue }) => { | ||
if (typeof value === 'undefined' || (0, utils_1.isPlainObject)(value)) | ||
if (typeof value === 'undefined' || isPlainObject(value)) | ||
return []; // property doesn't exist or is an object, no need to lint it with this assert | ||
const values = Array.isArray(value) ? value : [value]; | ||
const regex = (0, utils_2.regexFromString)(condition); | ||
const regex = regexFromString(condition); | ||
return values | ||
.map((_val) => regex?.test(_val) && { | ||
message: `"${_val}" should not match a regex ${condition}`, | ||
location: (0, utils_1.isString)(value) | ||
location: runOnValue(value) | ||
? baseLocation | ||
: (0, utils_1.isPlainObject)(rawValue) | ||
: isPlainObject(rawValue) | ||
? baseLocation.child(_val).key() | ||
: baseLocation.key(), | ||
}) | ||
.filter(utils_1.isTruthy); | ||
.filter(isTruthy); | ||
}, | ||
enum: (value, condition, { baseLocation }) => { | ||
if (typeof value === 'undefined' || (0, utils_1.isPlainObject)(value)) | ||
if (typeof value === 'undefined' || isPlainObject(value)) | ||
return []; // property doesn't exist or is an object, no need to lint it with this assert | ||
@@ -80,5 +76,5 @@ const values = Array.isArray(value) ? value : [value]; | ||
message: `"${_val}" should be one of the predefined values`, | ||
location: (0, utils_1.isString)(value) ? baseLocation : baseLocation.child(_val).key(), | ||
location: runOnValue(value) ? baseLocation : baseLocation.child(_val).key(), | ||
}) | ||
.filter(utils_1.isTruthy); | ||
.filter(isTruthy); | ||
}, | ||
@@ -103,6 +99,6 @@ defined: (value, condition = true, { baseLocation }) => { | ||
}) | ||
.filter(utils_1.isTruthy); | ||
.filter(isTruthy); | ||
}, | ||
disallowed: (value, condition, { baseLocation }) => { | ||
if (typeof value === 'undefined' || (0, utils_1.isPlainObject)(value)) | ||
if (typeof value === 'undefined' || isPlainObject(value)) | ||
return []; // property doesn't exist or is an object, no need to lint it with this assert | ||
@@ -113,5 +109,5 @@ const values = Array.isArray(value) ? value : [value]; | ||
message: `"${_val}" is disallowed`, | ||
location: (0, utils_1.isString)(value) ? baseLocation : baseLocation.child(_val).key(), | ||
location: runOnValue(value) ? baseLocation : baseLocation.child(_val).key(), | ||
}) | ||
.filter(utils_1.isTruthy); | ||
.filter(isTruthy); | ||
}, | ||
@@ -125,5 +121,5 @@ const: (value, condition, { baseLocation }) => { | ||
message: `"${_val}" should be equal ${condition} `, | ||
location: (0, utils_1.isString)(value) ? baseLocation : baseLocation.child(_val).key(), | ||
location: runOnValue(value) ? baseLocation : baseLocation.child(_val).key(), | ||
}) | ||
.filter(utils_1.isTruthy); | ||
.filter(isTruthy); | ||
} | ||
@@ -186,3 +182,3 @@ else { | ||
casing: (value, condition, { baseLocation }) => { | ||
if (typeof value === 'undefined' || (0, utils_1.isPlainObject)(value)) | ||
if (typeof value === 'undefined' || isPlainObject(value)) | ||
return []; // property doesn't exist or is an object, no need to lint it with this assert | ||
@@ -202,5 +198,5 @@ const values = Array.isArray(value) ? value : [value]; | ||
message: `"${_val}" should use ${condition}`, | ||
location: (0, utils_1.isString)(value) ? baseLocation : baseLocation.child(_val).key(), | ||
location: runOnValue(value) ? baseLocation : baseLocation.child(_val).key(), | ||
}) | ||
.filter(utils_1.isTruthy); | ||
.filter(isTruthy); | ||
}, | ||
@@ -218,3 +214,3 @@ sortOrder: (value, condition, { baseLocation }) => { | ||
} | ||
if (typeof value === 'undefined' || (0, utils_2.isOrdered)(value, condition)) | ||
if (typeof value === 'undefined' || isOrdered(value, condition)) | ||
return []; | ||
@@ -229,3 +225,3 @@ return [ | ||
mutuallyExclusive: (value, condition, { baseLocation }) => { | ||
if ((0, utils_2.getIntersectionLength)(value, condition) < 2) | ||
if (getIntersectionLength(value, condition) < 2) | ||
return []; | ||
@@ -240,4 +236,4 @@ return [ | ||
mutuallyRequired: (value, condition, { baseLocation }) => { | ||
const isValid = (0, utils_2.getIntersectionLength)(value, condition) > 0 | ||
? (0, utils_2.getIntersectionLength)(value, condition) === condition.length | ||
const isValid = getIntersectionLength(value, condition) > 0 | ||
? getIntersectionLength(value, condition) === condition.length | ||
: true; | ||
@@ -254,3 +250,3 @@ return isValid | ||
requireAny: (value, condition, { baseLocation }) => { | ||
return (0, utils_2.getIntersectionLength)(value, condition) >= 1 | ||
return getIntersectionLength(value, condition) >= 1 | ||
? [] | ||
@@ -279,3 +275,3 @@ : [ | ||
} | ||
const regex = (0, utils_2.regexFromString)(condition); | ||
const regex = regexFromString(condition); | ||
const isValid = hasRef && regex?.test(rawValue['$ref']); | ||
@@ -292,4 +288,5 @@ return isValid | ||
}; | ||
function buildAssertCustomFunction(fn) { | ||
export function buildAssertCustomFunction(fn) { | ||
return (value, options, ctx) => fn.call(null, value, options, ctx); | ||
} | ||
//# sourceMappingURL=asserts.js.map |
@@ -1,4 +0,4 @@ | ||
import type { asserts, AssertionFn } from './asserts'; | ||
import type { Arazzo1Visitor, Async2Visitor, Async3Visitor, Oas2Visitor, Oas3Visitor, Overlay1Visitor } from '../../../visitors'; | ||
import type { RuleSeverity } from '../../../config'; | ||
import type { asserts, AssertionFn } from './asserts.js'; | ||
import type { Arazzo1Visitor, Async2Visitor, Async3Visitor, Oas2Visitor, Oas3Visitor, Overlay1Visitor } from '../../../visitors.js'; | ||
import type { RuleSeverity } from '../../../config/index.js'; | ||
export type AssertionLocators = { | ||
@@ -28,1 +28,2 @@ filterInParentKeys?: (string | number)[]; | ||
export declare const Assertions: (opts: Record<string, Assertion>) => (Oas3Visitor | Oas2Visitor | Async2Visitor | Async3Visitor | Arazzo1Visitor | Overlay1Visitor)[]; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Assertions = void 0; | ||
const utils_1 = require("./utils"); | ||
const utils_2 = require("../../../utils"); | ||
const Assertions = (opts) => { | ||
import { buildSubjectVisitor, buildVisitorObject } from './utils.js'; | ||
import { isString } from '../../../utils.js'; | ||
export const Assertions = (opts) => { | ||
const visitors = []; | ||
@@ -15,7 +12,7 @@ // As 'Assertions' has an array of asserts, | ||
for (const [_, assertion] of assertions.entries()) { | ||
if (!(0, utils_2.isString)(assertion.subject.type)) { | ||
if (!isString(assertion.subject.type)) { | ||
throw new Error(`${assertion.assertionId}: 'type' (String) is required`); | ||
} | ||
const subjectVisitor = (0, utils_1.buildSubjectVisitor)(assertion.assertionId, assertion); | ||
const visitorObject = (0, utils_1.buildVisitorObject)(assertion, subjectVisitor); | ||
const subjectVisitor = buildSubjectVisitor(assertion.assertionId, assertion); | ||
const visitorObject = buildVisitorObject(assertion, subjectVisitor); | ||
visitors.push(visitorObject); | ||
@@ -25,2 +22,2 @@ } | ||
}; | ||
exports.Assertions = Assertions; | ||
//# sourceMappingURL=index.js.map |
@@ -1,5 +0,5 @@ | ||
import type { Asserts } from './asserts'; | ||
import type { AssertionContext, AssertResult } from '../../../config'; | ||
import type { Assertion, AssertionDefinition } from '.'; | ||
import type { Oas2Visitor, Oas3Visitor, VisitFunction } from '../../../visitors'; | ||
import type { Asserts } from './asserts.js'; | ||
import type { AssertionContext, AssertResult } from '../../../config/index.js'; | ||
import type { Assertion, AssertionDefinition } from './index.js'; | ||
import type { Oas2Visitor, Oas3Visitor, VisitFunction } from '../../../visitors.js'; | ||
export type OrderDirection = 'asc' | 'desc'; | ||
@@ -29,1 +29,2 @@ export type OrderOptions = { | ||
export {}; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -1,14 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getAssertsToApply = getAssertsToApply; | ||
exports.buildVisitorObject = buildVisitorObject; | ||
exports.buildSubjectVisitor = buildSubjectVisitor; | ||
exports.getIntersectionLength = getIntersectionLength; | ||
exports.isOrdered = isOrdered; | ||
exports.runAssertion = runAssertion; | ||
exports.regexFromString = regexFromString; | ||
const asserts_1 = require("./asserts"); | ||
const logger_1 = require("../../../logger"); | ||
const ref_utils_1 = require("../../../ref-utils"); | ||
const utils_1 = require("../../../utils"); | ||
import { asserts, runOnKeysSet, runOnValuesSet } from './asserts.js'; | ||
import { colorize } from '../../../logger.js'; | ||
import { isRef } from '../../../ref-utils.js'; | ||
import { isTruthy, keysOf, isString } from '../../../utils.js'; | ||
const assertionMessageTemplates = { | ||
@@ -25,6 +16,6 @@ problems: '{{problems}}', | ||
((key) => !filterOutParentKeys.includes(key.toString())); | ||
return [matchKeysPredicate, filterInPredicate, filterOutPredicate].filter(utils_1.isTruthy); | ||
return [matchKeysPredicate, filterInPredicate, filterOutPredicate].filter(isTruthy); | ||
} | ||
function getAssertsToApply(assertion) { | ||
const assertsToApply = (0, utils_1.keysOf)(asserts_1.asserts) | ||
export function getAssertsToApply(assertion) { | ||
const assertsToApply = keysOf(asserts) | ||
.filter((assertName) => assertion.assertions[assertName] !== undefined) | ||
@@ -35,4 +26,4 @@ .map((assertName) => { | ||
conditions: assertion.assertions[assertName], | ||
runsOnKeys: asserts_1.runOnKeysSet.has(assertName), | ||
runsOnValues: asserts_1.runOnValuesSet.has(assertName), | ||
runsOnKeys: runOnKeysSet.has(assertName), | ||
runsOnValues: runOnValuesSet.has(assertName), | ||
}; | ||
@@ -75,3 +66,3 @@ }); | ||
} | ||
function buildVisitorObject(assertion, subjectVisitor) { | ||
export function buildVisitorObject(assertion, subjectVisitor) { | ||
const targetVisitorLocatorPredicates = getPredicatesFromLocators(assertion.subject); | ||
@@ -95,3 +86,3 @@ const targetVisitorSkipFunction = targetVisitorLocatorPredicates.length | ||
const assertionDefinitionNode = context[index]; | ||
if (!(0, utils_1.isString)(assertionDefinitionNode.subject?.type)) { | ||
if (!isString(assertionDefinitionNode.subject?.type)) { | ||
throw new Error(`${assertion.assertionId} -> where -> [${index}]: 'type' (String) is required`); | ||
@@ -126,6 +117,6 @@ } | ||
} | ||
function buildSubjectVisitor(assertId, assertion) { | ||
export function buildSubjectVisitor(assertId, assertion) { | ||
return (node, ctx) => { | ||
const properties = getAssertionProperties(assertion); | ||
const defaultMessage = `${logger_1.colorize.blue(assertId)} failed because the ${logger_1.colorize.blue(assertion.subject.type)} ${logger_1.colorize.blue(properties.join(', '))} didn't meet the assertions: ${assertionMessageTemplates.problems}`.replace(/ +/g, ' '); | ||
const defaultMessage = `${colorize.blue(assertId)} failed because the ${colorize.blue(assertion.subject.type)} ${colorize.blue(properties.join(', '))} didn't meet the assertions: ${assertionMessageTemplates.problems}`.replace(/ +/g, ' '); | ||
const problems = applyAssertions(assertion, getAssertsToApply(assertion), { | ||
@@ -169,3 +160,3 @@ ...ctx, | ||
} | ||
function getIntersectionLength(keys, properties) { | ||
export function getIntersectionLength(keys, properties) { | ||
const props = new Set(properties); | ||
@@ -180,3 +171,3 @@ let count = 0; | ||
} | ||
function isOrdered(value, options) { | ||
export function isOrdered(value, options) { | ||
const direction = options.direction || options; | ||
@@ -207,6 +198,6 @@ const property = options.property; | ||
} | ||
function runAssertion({ assert, ctx, assertionProperty, }) { | ||
export function runAssertion({ assert, ctx, assertionProperty, }) { | ||
const currentLocation = assert.name === 'ref' ? ctx.rawLocation : ctx.location; | ||
if (assertionProperty) { | ||
const values = (0, ref_utils_1.isRef)(ctx.node[assertionProperty]) | ||
const values = isRef(ctx.node[assertionProperty]) | ||
? ctx.resolve(ctx.node[assertionProperty])?.node | ||
@@ -216,3 +207,3 @@ : ctx.node[assertionProperty]; | ||
const location = currentLocation.child(assertionProperty); | ||
return asserts_1.asserts[assert.name](values, assert.conditions, { | ||
return asserts[assert.name](values, assert.conditions, { | ||
...ctx, | ||
@@ -225,3 +216,3 @@ baseLocation: location, | ||
const value = Array.isArray(ctx.node) ? ctx.node : Object.keys(ctx.node); | ||
return asserts_1.asserts[assert.name](value, assert.conditions, { | ||
return asserts[assert.name](value, assert.conditions, { | ||
...ctx, | ||
@@ -233,5 +224,6 @@ rawValue: ctx.rawNode, | ||
} | ||
function regexFromString(input) { | ||
export function regexFromString(input) { | ||
const matches = input.match(/^\/(.*)\/(.*)|(.*)/); | ||
return matches && new RegExp(matches[1] || matches[3], matches[2]); | ||
} | ||
//# sourceMappingURL=utils.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const InfoContact: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=info-contact.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InfoContact = void 0; | ||
const utils_1 = require("../utils"); | ||
const InfoContact = () => { | ||
import { missingRequiredField } from '../utils.js'; | ||
export const InfoContact = () => { | ||
return { | ||
@@ -10,3 +7,3 @@ Info(info, { report, location }) { | ||
report({ | ||
message: (0, utils_1.missingRequiredField)('Info', 'contact'), | ||
message: missingRequiredField('Info', 'contact'), | ||
location: location.child('contact').key(), | ||
@@ -18,2 +15,2 @@ }); | ||
}; | ||
exports.InfoContact = InfoContact; | ||
//# sourceMappingURL=info-contact.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule } from '../../visitors.js'; | ||
export declare const InfoLicenseStrict: Oas2Rule | Oas3Rule | Async2Rule | Async3Rule; | ||
//# sourceMappingURL=info-license-strict.d.ts.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InfoLicenseStrict = void 0; | ||
const oas_types_1 = require("../../oas-types"); | ||
const utils_1 = require("../utils"); | ||
const InfoLicenseStrict = () => { | ||
import { detectSpec } from '../../oas-types.js'; | ||
import { validateDefinedAndNonEmpty, validateOneOfDefinedAndNonEmpty } from '../utils.js'; | ||
export const InfoLicenseStrict = () => { | ||
let specVersion; | ||
@@ -11,3 +8,3 @@ return { | ||
enter(root) { | ||
specVersion = (0, oas_types_1.detectSpec)(root); | ||
specVersion = detectSpec(root); | ||
}, | ||
@@ -17,6 +14,6 @@ License: { | ||
if (specVersion === 'oas3_1') { | ||
(0, utils_1.validateOneOfDefinedAndNonEmpty)(['url', 'identifier'], license, ctx); | ||
validateOneOfDefinedAndNonEmpty(['url', 'identifier'], license, ctx); | ||
} | ||
else { | ||
(0, utils_1.validateDefinedAndNonEmpty)('url', license, ctx); | ||
validateDefinedAndNonEmpty('url', license, ctx); | ||
} | ||
@@ -28,2 +25,2 @@ }, | ||
}; | ||
exports.InfoLicenseStrict = InfoLicenseStrict; | ||
//# sourceMappingURL=info-license-strict.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const InfoLicenseUrl: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=info-license-url.d.ts.map |
@@ -1,12 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InfoLicenseUrl = void 0; | ||
const utils_1 = require("../utils"); | ||
const InfoLicenseUrl = () => { | ||
import { validateDefinedAndNonEmpty } from '../utils.js'; | ||
export const InfoLicenseUrl = () => { | ||
return { | ||
License(license, ctx) { | ||
(0, utils_1.validateDefinedAndNonEmpty)('url', license, ctx); | ||
validateDefinedAndNonEmpty('url', license, ctx); | ||
}, | ||
}; | ||
}; | ||
exports.InfoLicenseUrl = InfoLicenseUrl; | ||
//# sourceMappingURL=info-license-url.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const InfoLicense: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=info-license.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.InfoLicense = void 0; | ||
const utils_1 = require("../utils"); | ||
const InfoLicense = () => { | ||
import { missingRequiredField } from '../utils.js'; | ||
export const InfoLicense = () => { | ||
return { | ||
@@ -10,3 +7,3 @@ Info(info, { report }) { | ||
report({ | ||
message: (0, utils_1.missingRequiredField)('Info', 'license'), | ||
message: missingRequiredField('Info', 'license'), | ||
location: { reportOnKey: true }, | ||
@@ -18,2 +15,2 @@ }); | ||
}; | ||
exports.InfoLicense = InfoLicense; | ||
//# sourceMappingURL=info-license.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const NoAmbiguousPaths: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=no-ambiguous-paths.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoAmbiguousPaths = void 0; | ||
const NoAmbiguousPaths = () => { | ||
export const NoAmbiguousPaths = () => { | ||
return { | ||
@@ -21,3 +18,2 @@ Paths(pathMap, { report, location }) { | ||
}; | ||
exports.NoAmbiguousPaths = NoAmbiguousPaths; | ||
function arePathsAmbiguous(a, b) { | ||
@@ -47,1 +43,2 @@ const partsA = a.split('/'); | ||
} | ||
//# sourceMappingURL=no-ambiguous-paths.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const NoEnumTypeMismatch: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=no-enum-type-mismatch.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoEnumTypeMismatch = void 0; | ||
const utils_1 = require("../utils"); | ||
const NoEnumTypeMismatch = () => { | ||
import { matchesJsonSchemaType, oasTypeOf } from '../utils.js'; | ||
export const NoEnumTypeMismatch = () => { | ||
return { | ||
@@ -11,6 +8,6 @@ Schema(schema, { report, location }) { | ||
if (schema.enum && schema.type && !Array.isArray(schema.type)) { | ||
const typeMismatchedValues = schema.enum.filter((item) => !(0, utils_1.matchesJsonSchemaType)(item, schema.type, schema.nullable)); | ||
const typeMismatchedValues = schema.enum.filter((item) => !matchesJsonSchemaType(item, schema.type, schema.nullable)); | ||
for (const mismatchedValue of typeMismatchedValues) { | ||
report({ | ||
message: `All values of \`enum\` field must be of the same type as the \`type\` field: expected "${schema.type}" but received "${(0, utils_1.oasTypeOf)(mismatchedValue)}".`, | ||
message: `All values of \`enum\` field must be of the same type as the \`type\` field: expected "${schema.type}" but received "${oasTypeOf(mismatchedValue)}".`, | ||
location: location.child(['enum', schema.enum.indexOf(mismatchedValue)]), | ||
@@ -25,3 +22,3 @@ }); | ||
for (const type of schema.type) { | ||
const valid = (0, utils_1.matchesJsonSchemaType)(enumValue, type, schema.nullable); | ||
const valid = matchesJsonSchemaType(enumValue, type, schema.nullable); | ||
if (!valid) | ||
@@ -43,2 +40,2 @@ mismatchedResults[enumValue].push(type); | ||
}; | ||
exports.NoEnumTypeMismatch = NoEnumTypeMismatch; | ||
//# sourceMappingURL=no-enum-type-mismatch.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const NoHttpVerbsInPaths: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=no-http-verbs-in-paths.d.ts.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoHttpVerbsInPaths = void 0; | ||
const utils_1 = require("../../utils"); | ||
import { isPathParameter, splitCamelCaseIntoWords } from '../../utils.js'; | ||
const httpMethods = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace']; | ||
const NoHttpVerbsInPaths = ({ splitIntoWords }) => { | ||
export const NoHttpVerbsInPaths = ({ splitIntoWords }) => { | ||
return { | ||
@@ -14,7 +11,7 @@ PathItem(_path, { key, report, location }) { | ||
for (const pathSegment of pathSegments) { | ||
if (!pathSegment || (0, utils_1.isPathParameter)(pathSegment)) | ||
if (!pathSegment || isPathParameter(pathSegment)) | ||
continue; | ||
const isHttpMethodIncluded = (method) => { | ||
return splitIntoWords | ||
? (0, utils_1.splitCamelCaseIntoWords)(pathSegment).has(method) | ||
? splitCamelCaseIntoWords(pathSegment).has(method) | ||
: pathSegment.toLocaleLowerCase().includes(method); | ||
@@ -34,2 +31,2 @@ }; | ||
}; | ||
exports.NoHttpVerbsInPaths = NoHttpVerbsInPaths; | ||
//# sourceMappingURL=no-http-verbs-in-paths.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const NoIdenticalPaths: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=no-identical-paths.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoIdenticalPaths = void 0; | ||
const NoIdenticalPaths = () => { | ||
export const NoIdenticalPaths = () => { | ||
return { | ||
@@ -24,2 +21,2 @@ Paths(pathMap, { report, location }) { | ||
}; | ||
exports.NoIdenticalPaths = NoIdenticalPaths; | ||
//# sourceMappingURL=no-identical-paths.js.map |
export declare const NoInvalidParameterExamples: any; | ||
//# sourceMappingURL=no-invalid-parameter-examples.d.ts.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoInvalidParameterExamples = void 0; | ||
const utils_1 = require("../utils"); | ||
const NoInvalidParameterExamples = (opts) => { | ||
const allowAdditionalProperties = (0, utils_1.getAdditionalPropertiesOption)(opts) ?? false; | ||
import { getAdditionalPropertiesOption, validateExample } from '../utils.js'; | ||
export const NoInvalidParameterExamples = (opts) => { | ||
const allowAdditionalProperties = getAdditionalPropertiesOption(opts) ?? false; | ||
return { | ||
@@ -11,3 +8,3 @@ Parameter: { | ||
if (parameter.example !== undefined) { | ||
(0, utils_1.validateExample)(parameter.example, parameter.schema, ctx.location.child('example'), ctx, allowAdditionalProperties); | ||
validateExample(parameter.example, parameter.schema, ctx.location.child('example'), ctx, allowAdditionalProperties); | ||
} | ||
@@ -17,3 +14,3 @@ if (parameter.examples) { | ||
if ('value' in example) { | ||
(0, utils_1.validateExample)(example.value, parameter.schema, ctx.location.child(['examples', key]), ctx, true); | ||
validateExample(example.value, parameter.schema, ctx.location.child(['examples', key]), ctx, true); | ||
} | ||
@@ -26,2 +23,2 @@ } | ||
}; | ||
exports.NoInvalidParameterExamples = NoInvalidParameterExamples; | ||
//# sourceMappingURL=no-invalid-parameter-examples.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors'; | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; | ||
export declare const NoInvalidSchemaExamples: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=no-invalid-schema-examples.d.ts.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoInvalidSchemaExamples = void 0; | ||
const utils_1 = require("../utils"); | ||
const NoInvalidSchemaExamples = (opts) => { | ||
const allowAdditionalProperties = (0, utils_1.getAdditionalPropertiesOption)(opts) ?? false; | ||
import { getAdditionalPropertiesOption, validateExample } from '../utils.js'; | ||
export const NoInvalidSchemaExamples = (opts) => { | ||
const allowAdditionalProperties = getAdditionalPropertiesOption(opts) ?? false; | ||
return { | ||
@@ -13,3 +10,3 @@ Schema: { | ||
for (const example of examples) { | ||
(0, utils_1.validateExample)(example, schema, ctx.location.child(['examples', examples.indexOf(example)]), ctx, allowAdditionalProperties); | ||
validateExample(example, schema, ctx.location.child(['examples', examples.indexOf(example)]), ctx, allowAdditionalProperties); | ||
} | ||
@@ -24,3 +21,3 @@ } | ||
} | ||
(0, utils_1.validateExample)(schema.example, schema, ctx.location.child('example'), ctx, true); | ||
validateExample(schema.example, schema, ctx.location.child('example'), ctx, true); | ||
} | ||
@@ -31,2 +28,2 @@ }, | ||
}; | ||
exports.NoInvalidSchemaExamples = NoInvalidSchemaExamples; | ||
//# sourceMappingURL=no-invalid-schema-examples.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const NoPathTrailingSlash: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=no-path-trailing-slash.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoPathTrailingSlash = void 0; | ||
const NoPathTrailingSlash = () => { | ||
export const NoPathTrailingSlash = () => { | ||
return { | ||
@@ -16,2 +13,2 @@ PathItem(_path, { report, key, rawLocation }) { | ||
}; | ||
exports.NoPathTrailingSlash = NoPathTrailingSlash; | ||
//# sourceMappingURL=no-path-trailing-slash.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors'; | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; | ||
export declare const NoRequiredSchemaPropertiesUndefined: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=no-required-schema-properties-undefined.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoRequiredSchemaPropertiesUndefined = void 0; | ||
const ref_utils_1 = require("../../ref-utils"); | ||
const NoRequiredSchemaPropertiesUndefined = () => { | ||
import { isRef } from '../../ref-utils.js'; | ||
export const NoRequiredSchemaPropertiesUndefined = () => { | ||
return { | ||
@@ -18,3 +15,3 @@ Schema: { | ||
visitedSchemas.add(schema); | ||
if ((0, ref_utils_1.isRef)(schema)) { | ||
if (isRef(schema)) { | ||
return elevateProperties(resolve(schema).node); | ||
@@ -37,2 +34,2 @@ } | ||
}; | ||
exports.NoRequiredSchemaPropertiesUndefined = NoRequiredSchemaPropertiesUndefined; | ||
//# sourceMappingURL=no-required-schema-properties-undefined.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors'; | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; | ||
export declare const NoSchemaTypeMismatch: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=no-schema-type-mismatch.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoSchemaTypeMismatch = void 0; | ||
const NoSchemaTypeMismatch = () => { | ||
export const NoSchemaTypeMismatch = () => { | ||
return { | ||
@@ -22,2 +19,2 @@ Schema(schema, { report, location }) { | ||
}; | ||
exports.NoSchemaTypeMismatch = NoSchemaTypeMismatch; | ||
//# sourceMappingURL=no-schema-type-mismatch.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const Operation2xxResponse: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=operation-2xx-response.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Operation2xxResponse = void 0; | ||
const utils_1 = require("../utils"); | ||
const Operation2xxResponse = ({ validateWebhooks }) => { | ||
import { validateResponseCodes } from '../utils.js'; | ||
export const Operation2xxResponse = ({ validateWebhooks }) => { | ||
return { | ||
@@ -10,3 +7,3 @@ Paths: { | ||
const codes = Object.keys(responses || {}); | ||
(0, utils_1.validateResponseCodes)(codes, '2XX', { report }); | ||
validateResponseCodes(codes, '2XX', { report }); | ||
}, | ||
@@ -19,3 +16,3 @@ }, | ||
const codes = Object.keys(responses || {}); | ||
(0, utils_1.validateResponseCodes)(codes, '2XX', { report }); | ||
validateResponseCodes(codes, '2XX', { report }); | ||
}, | ||
@@ -25,2 +22,2 @@ }, | ||
}; | ||
exports.Operation2xxResponse = Operation2xxResponse; | ||
//# sourceMappingURL=operation-2xx-response.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const Operation4xxResponse: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=operation-4xx-response.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Operation4xxResponse = void 0; | ||
const utils_1 = require("../utils"); | ||
const Operation4xxResponse = ({ validateWebhooks }) => { | ||
import { validateResponseCodes } from '../utils.js'; | ||
export const Operation4xxResponse = ({ validateWebhooks }) => { | ||
return { | ||
@@ -10,3 +7,3 @@ Paths: { | ||
const codes = Object.keys(responses || {}); | ||
(0, utils_1.validateResponseCodes)(codes, '4XX', { report }); | ||
validateResponseCodes(codes, '4XX', { report }); | ||
}, | ||
@@ -19,3 +16,3 @@ }, | ||
const codes = Object.keys(responses || {}); | ||
(0, utils_1.validateResponseCodes)(codes, '4XX', { report }); | ||
validateResponseCodes(codes, '4XX', { report }); | ||
}, | ||
@@ -25,2 +22,2 @@ }, | ||
}; | ||
exports.Operation4xxResponse = Operation4xxResponse; | ||
//# sourceMappingURL=operation-4xx-response.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const OperationDescription: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=operation-description.d.ts.map |
@@ -1,12 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OperationDescription = void 0; | ||
const utils_1 = require("../utils"); | ||
const OperationDescription = () => { | ||
import { validateDefinedAndNonEmpty } from '../utils.js'; | ||
export const OperationDescription = () => { | ||
return { | ||
Operation(operation, ctx) { | ||
(0, utils_1.validateDefinedAndNonEmpty)('description', operation, ctx); | ||
validateDefinedAndNonEmpty('description', operation, ctx); | ||
}, | ||
}; | ||
}; | ||
exports.OperationDescription = OperationDescription; | ||
//# sourceMappingURL=operation-description.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const OperationIdUnique: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=operation-operationId-unique.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OperationIdUnique = void 0; | ||
const OperationIdUnique = () => { | ||
export const OperationIdUnique = () => { | ||
const seenOperations = new Set(); | ||
@@ -20,2 +17,2 @@ return { | ||
}; | ||
exports.OperationIdUnique = OperationIdUnique; | ||
//# sourceMappingURL=operation-operationId-unique.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const OperationIdUrlSafe: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=operation-operationId-url-safe.d.ts.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OperationIdUrlSafe = void 0; | ||
// eslint-disable-next-line no-useless-escape | ||
const validUrlSymbols = /^[A-Za-z0-9-._~:/?#\[\]@!\$&'()*+,;=]*$/; | ||
const OperationIdUrlSafe = () => { | ||
export const OperationIdUrlSafe = () => { | ||
return { | ||
@@ -18,2 +15,2 @@ Operation(operation, { report, location }) { | ||
}; | ||
exports.OperationIdUrlSafe = OperationIdUrlSafe; | ||
//# sourceMappingURL=operation-operationId-url-safe.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const OperationOperationId: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=operation-operationId.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OperationOperationId = void 0; | ||
const utils_1 = require("../utils"); | ||
const OperationOperationId = () => { | ||
import { validateDefinedAndNonEmpty } from '../utils.js'; | ||
export const OperationOperationId = () => { | ||
return { | ||
@@ -10,3 +7,3 @@ Root: { | ||
Operation(operation, ctx) { | ||
(0, utils_1.validateDefinedAndNonEmpty)('operationId', operation, ctx); | ||
validateDefinedAndNonEmpty('operationId', operation, ctx); | ||
}, | ||
@@ -17,2 +14,2 @@ }, | ||
}; | ||
exports.OperationOperationId = OperationOperationId; | ||
//# sourceMappingURL=operation-operationId.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const OperationParametersUnique: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=operation-parameters-unique.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OperationParametersUnique = void 0; | ||
const OperationParametersUnique = () => { | ||
export const OperationParametersUnique = () => { | ||
let seenPathParams; | ||
@@ -40,2 +37,2 @@ let seenOperationParams; | ||
}; | ||
exports.OperationParametersUnique = OperationParametersUnique; | ||
//# sourceMappingURL=operation-parameters-unique.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const OperationSingularTag: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=operation-singular-tag.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OperationSingularTag = void 0; | ||
const OperationSingularTag = () => { | ||
export const OperationSingularTag = () => { | ||
return { | ||
@@ -16,2 +13,2 @@ Operation(operation, { report, location }) { | ||
}; | ||
exports.OperationSingularTag = OperationSingularTag; | ||
//# sourceMappingURL=operation-singular-tag.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const OperationSummary: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=operation-summary.d.ts.map |
@@ -1,12 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OperationSummary = void 0; | ||
const utils_1 = require("../utils"); | ||
const OperationSummary = () => { | ||
import { validateDefinedAndNonEmpty } from '../utils.js'; | ||
export const OperationSummary = () => { | ||
return { | ||
Operation(operation, ctx) { | ||
(0, utils_1.validateDefinedAndNonEmpty)('summary', operation, ctx); | ||
validateDefinedAndNonEmpty('summary', operation, ctx); | ||
}, | ||
}; | ||
}; | ||
exports.OperationSummary = OperationSummary; | ||
//# sourceMappingURL=operation-summary.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const OperationTagDefined: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=operation-tag-defined.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.OperationTagDefined = void 0; | ||
const OperationTagDefined = () => { | ||
export const OperationTagDefined = () => { | ||
let definedTags; | ||
@@ -30,2 +27,2 @@ return { | ||
}; | ||
exports.OperationTagDefined = OperationTagDefined; | ||
//# sourceMappingURL=operation-tag-defined.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const ParameterDescription: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=parameter-description.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ParameterDescription = void 0; | ||
const ParameterDescription = () => { | ||
export const ParameterDescription = () => { | ||
return { | ||
@@ -22,2 +19,2 @@ Parameter(parameter, { report, location }) { | ||
}; | ||
exports.ParameterDescription = ParameterDescription; | ||
//# sourceMappingURL=parameter-description.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const PathDeclarationMustExist: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=path-declaration-must-exist.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PathDeclarationMustExist = void 0; | ||
const PathDeclarationMustExist = () => { | ||
export const PathDeclarationMustExist = () => { | ||
return { | ||
@@ -16,2 +13,2 @@ PathItem(_path, { report, key }) { | ||
}; | ||
exports.PathDeclarationMustExist = PathDeclarationMustExist; | ||
//# sourceMappingURL=path-declaration-must-exist.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors'; | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; | ||
export declare const PathExcludesPatterns: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=path-excludes-patterns.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PathExcludesPatterns = void 0; | ||
const PathExcludesPatterns = ({ patterns }) => { | ||
export const PathExcludesPatterns = ({ patterns }) => { | ||
return { | ||
@@ -22,2 +19,2 @@ PathItem(_path, { report, key, location }) { | ||
}; | ||
exports.PathExcludesPatterns = PathExcludesPatterns; | ||
//# sourceMappingURL=path-excludes-patterns.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const PathHttpVerbsOrder: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=path-http-verbs-order.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PathHttpVerbsOrder = void 0; | ||
const defaultOrder = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace']; | ||
const PathHttpVerbsOrder = (opts) => { | ||
export const PathHttpVerbsOrder = (opts) => { | ||
const order = (opts && opts.order) || defaultOrder; | ||
@@ -26,2 +23,2 @@ if (!Array.isArray(order)) { | ||
}; | ||
exports.PathHttpVerbsOrder = PathHttpVerbsOrder; | ||
//# sourceMappingURL=path-http-verbs-order.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const PathNotIncludeQuery: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=path-not-include-query.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PathNotIncludeQuery = void 0; | ||
const PathNotIncludeQuery = () => { | ||
export const PathNotIncludeQuery = () => { | ||
return { | ||
@@ -18,2 +15,2 @@ Paths: { | ||
}; | ||
exports.PathNotIncludeQuery = PathNotIncludeQuery; | ||
//# sourceMappingURL=path-not-include-query.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const PathParamsDefined: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=path-params-defined.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PathParamsDefined = void 0; | ||
const pathRegex = /\{([a-zA-Z0-9_.-]+)\}+/g; | ||
const PathParamsDefined = () => { | ||
export const PathParamsDefined = () => { | ||
let pathTemplateParams; | ||
@@ -58,2 +55,2 @@ let definedPathParams; | ||
}; | ||
exports.PathParamsDefined = PathParamsDefined; | ||
//# sourceMappingURL=path-params-defined.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const PathSegmentPlural: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=path-segment-plural.d.ts.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PathSegmentPlural = void 0; | ||
const pluralize = require("pluralize"); | ||
const utils_1 = require("../../utils"); | ||
const PathSegmentPlural = (opts) => { | ||
import pluralize from 'pluralize'; | ||
import { isPathParameter } from '../../utils.js'; | ||
export const PathSegmentPlural = (opts) => { | ||
const { ignoreLastPathSegment, exceptions } = opts; | ||
@@ -15,3 +12,3 @@ return { | ||
pathSegments.shift(); | ||
if (ignoreLastPathSegment && pathSegments.length > 1) { | ||
if (ignoreLastPathSegment && pathSegments.length > 0) { | ||
pathSegments.pop(); | ||
@@ -22,3 +19,3 @@ } | ||
continue; | ||
if (!(0, utils_1.isPathParameter)(pathSegment) && pluralize.isSingular(pathSegment)) { | ||
if (!isPathParameter(pathSegment) && pluralize.isSingular(pathSegment)) { | ||
report({ | ||
@@ -35,2 +32,2 @@ message: `path segment \`${pathSegment}\` should be plural.`, | ||
}; | ||
exports.PathSegmentPlural = PathSegmentPlural; | ||
//# sourceMappingURL=path-segment-plural.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const PathsKebabCase: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=paths-kebab-case.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PathsKebabCase = void 0; | ||
const PathsKebabCase = () => { | ||
export const PathsKebabCase = () => { | ||
return { | ||
@@ -20,2 +17,2 @@ PathItem(_path, { report, key }) { | ||
}; | ||
exports.PathsKebabCase = PathsKebabCase; | ||
//# sourceMappingURL=paths-kebab-case.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from 'core/src/visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const RequiredStringPropertyMissingMinLength: Oas3Rule; | ||
//# sourceMappingURL=required-string-property-missing-min-length.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RequiredStringPropertyMissingMinLength = void 0; | ||
const RequiredStringPropertyMissingMinLength = () => { | ||
export const RequiredStringPropertyMissingMinLength = () => { | ||
let skipSchemaProperties; | ||
@@ -37,2 +34,2 @@ let requiredPropertiesSet; | ||
}; | ||
exports.RequiredStringPropertyMissingMinLength = RequiredStringPropertyMissingMinLength; | ||
//# sourceMappingURL=required-string-property-missing-min-length.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors'; | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; | ||
export declare const ResponseContainsHeader: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=response-contains-header.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ResponseContainsHeader = void 0; | ||
const utils_1 = require("../../utils"); | ||
const ResponseContainsHeader = (options) => { | ||
import { getMatchingStatusCodeRange } from '../../utils.js'; | ||
export const ResponseContainsHeader = (options) => { | ||
const names = options.names || {}; | ||
@@ -12,4 +9,4 @@ return { | ||
const expectedHeaders = names[key] || | ||
names[(0, utils_1.getMatchingStatusCodeRange)(key)] || | ||
names[(0, utils_1.getMatchingStatusCodeRange)(key).toLowerCase()] || | ||
names[getMatchingStatusCodeRange(key)] || | ||
names[getMatchingStatusCodeRange(key).toLowerCase()] || | ||
[]; | ||
@@ -30,2 +27,2 @@ for (const expectedHeader of expectedHeaders) { | ||
}; | ||
exports.ResponseContainsHeader = ResponseContainsHeader; | ||
//# sourceMappingURL=response-contains-header.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors'; | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; | ||
export declare const ScalarPropertyMissingExample: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=scalar-property-missing-example.d.ts.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ScalarPropertyMissingExample = void 0; | ||
const oas_types_1 = require("../../oas-types"); | ||
import { SpecVersion } from '../../oas-types.js'; | ||
const SCALAR_TYPES = ['string', 'integer', 'number', 'boolean', 'null']; | ||
const ScalarPropertyMissingExample = () => { | ||
export const ScalarPropertyMissingExample = () => { | ||
return { | ||
@@ -17,3 +14,3 @@ SchemaProperties(properties, { report, location, oasVersion, resolve }) { | ||
report({ | ||
message: `Scalar property should have "example"${oasVersion === oas_types_1.SpecVersion.OAS3_1 ? ' or "examples"' : ''} defined.`, | ||
message: `Scalar property should have "example"${oasVersion === SpecVersion.OAS3_1 ? ' or "examples"' : ''} defined.`, | ||
location: location.child(propName).key(), | ||
@@ -26,3 +23,2 @@ }); | ||
}; | ||
exports.ScalarPropertyMissingExample = ScalarPropertyMissingExample; | ||
function isScalarSchema(schema) { | ||
@@ -45,1 +41,2 @@ if (!schema.type) { | ||
} | ||
//# sourceMappingURL=scalar-property-missing-example.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const SecurityDefined: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=security-defined.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SecurityDefined = void 0; | ||
const SecurityDefined = (opts) => { | ||
export const SecurityDefined = (opts) => { | ||
const referencedSchemes = new Map(); | ||
@@ -65,2 +62,2 @@ const operationsWithoutSecurity = []; | ||
}; | ||
exports.SecurityDefined = SecurityDefined; | ||
//# sourceMappingURL=security-defined.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors'; | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; | ||
export declare const SpecStrictRefs: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=spec-strict-refs.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SpecStrictRefs = void 0; | ||
const ref_utils_1 = require("../../ref-utils"); | ||
const SpecStrictRefs = () => { | ||
import { isRef } from '../../ref-utils.js'; | ||
export const SpecStrictRefs = () => { | ||
const nodesToSkip = [ | ||
@@ -21,3 +18,3 @@ 'Schema', | ||
const shouldCheck = !nodesToSkip.includes(type.name); | ||
if (shouldCheck && (0, ref_utils_1.isRef)(rawNode)) { | ||
if (shouldCheck && isRef(rawNode)) { | ||
report({ | ||
@@ -31,2 +28,2 @@ message: 'Field $ref is not expected here.', | ||
}; | ||
exports.SpecStrictRefs = SpecStrictRefs; | ||
//# sourceMappingURL=spec-strict-refs.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule, Arazzo1Rule, Overlay1Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule, Async2Rule, Async3Rule, Arazzo1Rule, Overlay1Rule } from '../../visitors.js'; | ||
export declare const Struct: Oas3Rule | Oas2Rule | Async2Rule | Async3Rule | Arazzo1Rule | Overlay1Rule; | ||
//# sourceMappingURL=struct.d.ts.map |
@@ -1,12 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Struct = void 0; | ||
const types_1 = require("../../types"); | ||
const utils_1 = require("../utils"); | ||
const ref_utils_1 = require("../../ref-utils"); | ||
const utils_2 = require("../../utils"); | ||
const Struct = () => { | ||
import { isNamedType, SpecExtension } from '../../types/index.js'; | ||
import { oasTypeOf, matchesJsonSchemaType, getSuggest, validateSchemaEnumType } from '../utils.js'; | ||
import { isRef } from '../../ref-utils.js'; | ||
import { isPlainObject } from '../../utils.js'; | ||
export const Struct = () => { | ||
return { | ||
any(node, { report, type, location, rawLocation, key, resolve, ignoreNextVisitorsOnNode }) { | ||
const nodeType = (0, utils_1.oasTypeOf)(node); | ||
const nodeType = oasTypeOf(node); | ||
const refLocation = rawLocation !== location ? rawLocation : undefined; | ||
@@ -24,3 +21,3 @@ if (type.items) { | ||
else if (nodeType !== 'object') { | ||
if (type !== types_1.SpecExtension) { | ||
if (type !== SpecExtension) { | ||
// do not validate unknown extensions structure | ||
@@ -46,3 +43,3 @@ report({ | ||
const allowed = type.allowed?.(node); | ||
if (allowed && (0, utils_2.isPlainObject)(node)) { | ||
if (allowed && isPlainObject(node)) { | ||
for (const propName in node) { | ||
@@ -84,7 +81,7 @@ if (allowed.includes(propName) || | ||
propType = propType(propValue, propName); | ||
if ((0, types_1.isNamedType)(propType)) { | ||
if (isNamedType(propType)) { | ||
continue; // do nothing for named schema, it is executed with the next any call | ||
} | ||
const propSchema = propType; | ||
const propValueType = (0, utils_1.oasTypeOf)(propValue); | ||
const propValueType = oasTypeOf(propValue); | ||
if (propSchema === undefined) { | ||
@@ -95,3 +92,3 @@ if (propName.startsWith('x-')) | ||
message: `Property \`${propName}\` is not expected here.`, | ||
suggest: (0, utils_1.getSuggest)(propName, Object.keys(type.properties)), | ||
suggest: getSuggest(propName, Object.keys(type.properties)), | ||
from: refLocation, | ||
@@ -105,3 +102,3 @@ location: propLocation.key(), | ||
} | ||
if (propSchema.resolvable !== false && (0, ref_utils_1.isRef)(propValue)) { | ||
if (propSchema.resolvable !== false && isRef(propValue)) { | ||
propValue = resolve(propValue).node; | ||
@@ -111,3 +108,3 @@ } | ||
for (let i = 0; i < propValue.length; i++) { | ||
(0, utils_1.validateSchemaEnumType)(propSchema.items?.enum, propValue[i], propName, refLocation, { | ||
validateSchemaEnumType(propSchema.items?.enum, propValue[i], propName, refLocation, { | ||
report, | ||
@@ -119,3 +116,3 @@ location: location.child([propName, i]), | ||
if (propSchema.enum) { | ||
(0, utils_1.validateSchemaEnumType)(propSchema.enum, propValue, propName, refLocation, { | ||
validateSchemaEnumType(propSchema.enum, propValue, propName, refLocation, { | ||
report, | ||
@@ -125,3 +122,3 @@ location: location.child([propName]), | ||
} | ||
else if (propSchema.type && !(0, utils_1.matchesJsonSchemaType)(propValue, propSchema.type, false)) { | ||
else if (propSchema.type && !matchesJsonSchemaType(propValue, propSchema.type, false)) { | ||
report({ | ||
@@ -138,5 +135,5 @@ message: `Expected type \`${propSchema.type}\` but got \`${propValueType}\`.`, | ||
const item = propValue[i]; | ||
if (!(0, utils_1.matchesJsonSchemaType)(item, itemsType, false)) { | ||
if (!matchesJsonSchemaType(item, itemsType, false)) { | ||
report({ | ||
message: `Expected type \`${itemsType}\` but got \`${(0, utils_1.oasTypeOf)(item)}\`.`, | ||
message: `Expected type \`${itemsType}\` but got \`${oasTypeOf(item)}\`.`, | ||
from: refLocation, | ||
@@ -167,2 +164,2 @@ location: propLocation.child([i]), | ||
}; | ||
exports.Struct = Struct; | ||
//# sourceMappingURL=struct.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const TagDescription: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=tag-description.d.ts.map |
@@ -1,12 +0,9 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TagDescription = void 0; | ||
const utils_1 = require("../utils"); | ||
const TagDescription = () => { | ||
import { validateDefinedAndNonEmpty } from '../utils.js'; | ||
export const TagDescription = () => { | ||
return { | ||
Tag(tag, ctx) { | ||
(0, utils_1.validateDefinedAndNonEmpty)('description', tag, ctx); | ||
validateDefinedAndNonEmpty('description', tag, ctx); | ||
}, | ||
}; | ||
}; | ||
exports.TagDescription = TagDescription; | ||
//# sourceMappingURL=tag-description.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import type { Oas3Rule, Oas2Rule } from '../../visitors.js'; | ||
export declare const TagsAlphabetical: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=tags-alphabetical.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TagsAlphabetical = void 0; | ||
const TagsAlphabetical = ({ ignoreCase = false }) => { | ||
export const TagsAlphabetical = ({ ignoreCase = false }) => { | ||
return { | ||
@@ -20,5 +17,5 @@ Root(root, { report, location }) { | ||
}; | ||
exports.TagsAlphabetical = TagsAlphabetical; | ||
function getTagName(tag, ignoreCase) { | ||
return ignoreCase ? tag.name.toLowerCase() : tag.name; | ||
} | ||
//# sourceMappingURL=tags-alphabetical.js.map |
@@ -1,5 +0,6 @@ | ||
import type { Oas3Rule } from '../visitors'; | ||
import type { ResolveResult, Problem } from '../walk'; | ||
import type { Location } from '../ref-utils'; | ||
import type { Oas3Rule } from '../visitors.js'; | ||
import type { ResolveResult, Problem } from '../walk.js'; | ||
import type { Location } from '../ref-utils.js'; | ||
export declare const NoUnresolvedRefs: Oas3Rule; | ||
export declare function reportUnresolvedRef(resolved: ResolveResult<any>, report: (m: Problem) => void, location: Location): void; | ||
//# sourceMappingURL=no-unresolved-refs.d.ts.map |
@@ -1,7 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoUnresolvedRefs = void 0; | ||
exports.reportUnresolvedRef = reportUnresolvedRef; | ||
const resolve_1 = require("../resolve"); | ||
const NoUnresolvedRefs = () => { | ||
import { YamlParseError } from '../resolve.js'; | ||
export const NoUnresolvedRefs = () => { | ||
return { | ||
@@ -25,6 +21,5 @@ ref: { | ||
}; | ||
exports.NoUnresolvedRefs = NoUnresolvedRefs; | ||
function reportUnresolvedRef(resolved, report, location) { | ||
export function reportUnresolvedRef(resolved, report, location) { | ||
const error = resolved.error; | ||
if (error instanceof resolve_1.YamlParseError) { | ||
if (error instanceof YamlParseError) { | ||
report({ | ||
@@ -48,1 +43,2 @@ message: 'Failed to parse: ' + error.message, | ||
} | ||
//# sourceMappingURL=no-unresolved-refs.js.map |
@@ -1,2 +0,2 @@ | ||
import type { Oas2Rule } from '../../visitors'; | ||
import type { Oas2Rule } from '../../visitors.js'; | ||
export type BooleanParameterPrefixesOptions = { | ||
@@ -6,1 +6,2 @@ prefixes?: string[]; | ||
export declare const BooleanParameterPrefixes: Oas2Rule; | ||
//# sourceMappingURL=boolean-parameter-prefixes.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BooleanParameterPrefixes = void 0; | ||
const BooleanParameterPrefixes = (options) => { | ||
export const BooleanParameterPrefixes = (options) => { | ||
const prefixes = options.prefixes || ['is', 'has']; | ||
@@ -22,2 +19,2 @@ const regexp = new RegExp(`^(${prefixes.join('|')})[A-Z-_]`); | ||
}; | ||
exports.BooleanParameterPrefixes = BooleanParameterPrefixes; | ||
//# sourceMappingURL=boolean-parameter-prefixes.js.map |
@@ -1,3 +0,4 @@ | ||
import type { Oas2RuleSet } from '../../oas-types'; | ||
import type { Oas2RuleSet } from '../../oas-types.js'; | ||
export declare const rules: Oas2RuleSet<'built-in'>; | ||
export declare const preprocessors: {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,100 +0,95 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.preprocessors = exports.rules = void 0; | ||
const struct_1 = require("../common/struct"); | ||
const no_invalid_schema_examples_1 = require("../common/no-invalid-schema-examples"); | ||
const no_invalid_parameter_examples_1 = require("../common/no-invalid-parameter-examples"); | ||
const info_contact_1 = require("../common/info-contact"); | ||
const info_license_1 = require("../common/info-license"); | ||
const info_license_url_1 = require("../common/info-license-url"); | ||
const info_license_strict_1 = require("../common/info-license-strict"); | ||
const boolean_parameter_prefixes_1 = require("./boolean-parameter-prefixes"); | ||
const tag_description_1 = require("../common/tag-description"); | ||
const tags_alphabetical_1 = require("../common/tags-alphabetical"); | ||
const paths_kebab_case_1 = require("../common/paths-kebab-case"); | ||
const no_enum_type_mismatch_1 = require("../common/no-enum-type-mismatch"); | ||
const no_path_trailing_slash_1 = require("../common/no-path-trailing-slash"); | ||
const operation_2xx_response_1 = require("../common/operation-2xx-response"); | ||
const operation_4xx_response_1 = require("../common/operation-4xx-response"); | ||
const assertions_1 = require("../common/assertions"); | ||
const operation_operationId_unique_1 = require("../common/operation-operationId-unique"); | ||
const operation_parameters_unique_1 = require("../common/operation-parameters-unique"); | ||
const path_params_defined_1 = require("../common/path-params-defined"); | ||
const operation_tag_defined_1 = require("../common/operation-tag-defined"); | ||
const path_declaration_must_exist_1 = require("../common/path-declaration-must-exist"); | ||
const operation_operationId_url_safe_1 = require("../common/operation-operationId-url-safe"); | ||
const operation_description_1 = require("../common/operation-description"); | ||
const path_not_include_query_1 = require("../common/path-not-include-query"); | ||
const parameter_description_1 = require("../common/parameter-description"); | ||
const operation_singular_tag_1 = require("../common/operation-singular-tag"); | ||
const security_defined_1 = require("../common/security-defined"); | ||
const no_unresolved_refs_1 = require("../no-unresolved-refs"); | ||
const path_http_verbs_order_1 = require("../common/path-http-verbs-order"); | ||
const no_identical_paths_1 = require("../common/no-identical-paths"); | ||
const operation_operationId_1 = require("../common/operation-operationId"); | ||
const operation_summary_1 = require("../common/operation-summary"); | ||
const no_ambiguous_paths_1 = require("../common/no-ambiguous-paths"); | ||
const no_http_verbs_in_paths_1 = require("../common/no-http-verbs-in-paths"); | ||
const path_excludes_patterns_1 = require("../common/path-excludes-patterns"); | ||
const request_mime_type_1 = require("./request-mime-type"); | ||
const response_mime_type_1 = require("./response-mime-type"); | ||
const path_segment_plural_1 = require("../common/path-segment-plural"); | ||
const response_contains_header_1 = require("../common/response-contains-header"); | ||
const response_contains_property_1 = require("./response-contains-property"); | ||
const scalar_property_missing_example_1 = require("../common/scalar-property-missing-example"); | ||
const required_string_property_missing_min_length_1 = require("../common/required-string-property-missing-min-length"); | ||
const spec_strict_refs_1 = require("../common/spec-strict-refs"); | ||
const no_required_schema_properties_undefined_1 = require("../common/no-required-schema-properties-undefined"); | ||
const no_schema_type_mismatch_1 = require("../common/no-schema-type-mismatch"); | ||
exports.rules = { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore TODO: This is depricated property `spec` and should be removed in the future | ||
spec: struct_1.Struct, | ||
struct: struct_1.Struct, | ||
'no-invalid-schema-examples': no_invalid_schema_examples_1.NoInvalidSchemaExamples, | ||
'no-invalid-parameter-examples': no_invalid_parameter_examples_1.NoInvalidParameterExamples, | ||
'info-contact': info_contact_1.InfoContact, | ||
'info-license': info_license_1.InfoLicense, | ||
'info-license-url': info_license_url_1.InfoLicenseUrl, | ||
'info-license-strict': info_license_strict_1.InfoLicenseStrict, | ||
'tag-description': tag_description_1.TagDescription, | ||
'tags-alphabetical': tags_alphabetical_1.TagsAlphabetical, | ||
'paths-kebab-case': paths_kebab_case_1.PathsKebabCase, | ||
'no-enum-type-mismatch': no_enum_type_mismatch_1.NoEnumTypeMismatch, | ||
'boolean-parameter-prefixes': boolean_parameter_prefixes_1.BooleanParameterPrefixes, | ||
'no-path-trailing-slash': no_path_trailing_slash_1.NoPathTrailingSlash, | ||
'operation-2xx-response': operation_2xx_response_1.Operation2xxResponse, | ||
'operation-4xx-response': operation_4xx_response_1.Operation4xxResponse, | ||
assertions: assertions_1.Assertions, | ||
'operation-operationId-unique': operation_operationId_unique_1.OperationIdUnique, | ||
'operation-parameters-unique': operation_parameters_unique_1.OperationParametersUnique, | ||
'path-parameters-defined': path_params_defined_1.PathParamsDefined, | ||
'operation-tag-defined': operation_tag_defined_1.OperationTagDefined, | ||
'path-declaration-must-exist': path_declaration_must_exist_1.PathDeclarationMustExist, | ||
'operation-operationId-url-safe': operation_operationId_url_safe_1.OperationIdUrlSafe, | ||
'operation-operationId': operation_operationId_1.OperationOperationId, | ||
'operation-summary': operation_summary_1.OperationSummary, | ||
'operation-description': operation_description_1.OperationDescription, | ||
'path-not-include-query': path_not_include_query_1.PathNotIncludeQuery, | ||
'path-params-defined': path_params_defined_1.PathParamsDefined, | ||
'parameter-description': parameter_description_1.ParameterDescription, | ||
'operation-singular-tag': operation_singular_tag_1.OperationSingularTag, | ||
'security-defined': security_defined_1.SecurityDefined, | ||
'no-unresolved-refs': no_unresolved_refs_1.NoUnresolvedRefs, | ||
'no-identical-paths': no_identical_paths_1.NoIdenticalPaths, | ||
'no-ambiguous-paths': no_ambiguous_paths_1.NoAmbiguousPaths, | ||
'path-http-verbs-order': path_http_verbs_order_1.PathHttpVerbsOrder, | ||
'no-http-verbs-in-paths': no_http_verbs_in_paths_1.NoHttpVerbsInPaths, | ||
'path-excludes-patterns': path_excludes_patterns_1.PathExcludesPatterns, | ||
'request-mime-type': request_mime_type_1.RequestMimeType, | ||
'response-mime-type': response_mime_type_1.ResponseMimeType, | ||
'path-segment-plural': path_segment_plural_1.PathSegmentPlural, | ||
'response-contains-header': response_contains_header_1.ResponseContainsHeader, | ||
'response-contains-property': response_contains_property_1.ResponseContainsProperty, | ||
'scalar-property-missing-example': scalar_property_missing_example_1.ScalarPropertyMissingExample, | ||
'required-string-property-missing-min-length': required_string_property_missing_min_length_1.RequiredStringPropertyMissingMinLength, | ||
'spec-strict-refs': spec_strict_refs_1.SpecStrictRefs, | ||
'no-required-schema-properties-undefined': no_required_schema_properties_undefined_1.NoRequiredSchemaPropertiesUndefined, | ||
'no-schema-type-mismatch': no_schema_type_mismatch_1.NoSchemaTypeMismatch, | ||
import { Struct } from '../common/struct.js'; | ||
import { NoInvalidSchemaExamples } from '../common/no-invalid-schema-examples.js'; | ||
import { NoInvalidParameterExamples } from '../common/no-invalid-parameter-examples.js'; | ||
import { InfoContact } from '../common/info-contact.js'; | ||
import { InfoLicense } from '../common/info-license.js'; | ||
import { InfoLicenseUrl } from '../common/info-license-url.js'; | ||
import { InfoLicenseStrict } from '../common/info-license-strict.js'; | ||
import { BooleanParameterPrefixes } from './boolean-parameter-prefixes.js'; | ||
import { TagDescription } from '../common/tag-description.js'; | ||
import { TagsAlphabetical } from '../common/tags-alphabetical.js'; | ||
import { PathsKebabCase } from '../common/paths-kebab-case.js'; | ||
import { NoEnumTypeMismatch } from '../common/no-enum-type-mismatch.js'; | ||
import { NoPathTrailingSlash } from '../common/no-path-trailing-slash.js'; | ||
import { Operation2xxResponse } from '../common/operation-2xx-response.js'; | ||
import { Operation4xxResponse } from '../common/operation-4xx-response.js'; | ||
import { Assertions } from '../common/assertions/index.js'; | ||
import { OperationIdUnique } from '../common/operation-operationId-unique.js'; | ||
import { OperationParametersUnique } from '../common/operation-parameters-unique.js'; | ||
import { PathParamsDefined } from '../common/path-params-defined.js'; | ||
import { OperationTagDefined } from '../common/operation-tag-defined.js'; | ||
import { PathDeclarationMustExist } from '../common/path-declaration-must-exist.js'; | ||
import { OperationIdUrlSafe } from '../common/operation-operationId-url-safe.js'; | ||
import { OperationDescription } from '../common/operation-description.js'; | ||
import { PathNotIncludeQuery } from '../common/path-not-include-query.js'; | ||
import { ParameterDescription } from '../common/parameter-description.js'; | ||
import { OperationSingularTag } from '../common/operation-singular-tag.js'; | ||
import { SecurityDefined } from '../common/security-defined.js'; | ||
import { NoUnresolvedRefs } from '../no-unresolved-refs.js'; | ||
import { PathHttpVerbsOrder } from '../common/path-http-verbs-order.js'; | ||
import { NoIdenticalPaths } from '../common/no-identical-paths.js'; | ||
import { OperationOperationId } from '../common/operation-operationId.js'; | ||
import { OperationSummary } from '../common/operation-summary.js'; | ||
import { NoAmbiguousPaths } from '../common/no-ambiguous-paths.js'; | ||
import { NoHttpVerbsInPaths } from '../common/no-http-verbs-in-paths.js'; | ||
import { PathExcludesPatterns } from '../common/path-excludes-patterns.js'; | ||
import { RequestMimeType } from './request-mime-type.js'; | ||
import { ResponseMimeType } from './response-mime-type.js'; | ||
import { PathSegmentPlural } from '../common/path-segment-plural.js'; | ||
import { ResponseContainsHeader } from '../common/response-contains-header.js'; | ||
import { ResponseContainsProperty } from './response-contains-property.js'; | ||
import { ScalarPropertyMissingExample } from '../common/scalar-property-missing-example.js'; | ||
import { RequiredStringPropertyMissingMinLength } from '../common/required-string-property-missing-min-length.js'; | ||
import { SpecStrictRefs } from '../common/spec-strict-refs.js'; | ||
import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined.js'; | ||
import { NoSchemaTypeMismatch } from '../common/no-schema-type-mismatch.js'; | ||
export const rules = { | ||
struct: Struct, | ||
'no-invalid-schema-examples': NoInvalidSchemaExamples, | ||
'no-invalid-parameter-examples': NoInvalidParameterExamples, | ||
'info-contact': InfoContact, | ||
'info-license': InfoLicense, | ||
'info-license-url': InfoLicenseUrl, | ||
'info-license-strict': InfoLicenseStrict, | ||
'tag-description': TagDescription, | ||
'tags-alphabetical': TagsAlphabetical, | ||
'paths-kebab-case': PathsKebabCase, | ||
'no-enum-type-mismatch': NoEnumTypeMismatch, | ||
'boolean-parameter-prefixes': BooleanParameterPrefixes, | ||
'no-path-trailing-slash': NoPathTrailingSlash, | ||
'operation-2xx-response': Operation2xxResponse, | ||
'operation-4xx-response': Operation4xxResponse, | ||
assertions: Assertions, | ||
'operation-operationId-unique': OperationIdUnique, | ||
'operation-parameters-unique': OperationParametersUnique, | ||
'path-parameters-defined': PathParamsDefined, | ||
'operation-tag-defined': OperationTagDefined, | ||
'path-declaration-must-exist': PathDeclarationMustExist, | ||
'operation-operationId-url-safe': OperationIdUrlSafe, | ||
'operation-operationId': OperationOperationId, | ||
'operation-summary': OperationSummary, | ||
'operation-description': OperationDescription, | ||
'path-not-include-query': PathNotIncludeQuery, | ||
'path-params-defined': PathParamsDefined, | ||
'parameter-description': ParameterDescription, | ||
'operation-singular-tag': OperationSingularTag, | ||
'security-defined': SecurityDefined, | ||
'no-unresolved-refs': NoUnresolvedRefs, | ||
'no-identical-paths': NoIdenticalPaths, | ||
'no-ambiguous-paths': NoAmbiguousPaths, | ||
'path-http-verbs-order': PathHttpVerbsOrder, | ||
'no-http-verbs-in-paths': NoHttpVerbsInPaths, | ||
'path-excludes-patterns': PathExcludesPatterns, | ||
'request-mime-type': RequestMimeType, | ||
'response-mime-type': ResponseMimeType, | ||
'path-segment-plural': PathSegmentPlural, | ||
'response-contains-header': ResponseContainsHeader, | ||
'response-contains-property': ResponseContainsProperty, | ||
'scalar-property-missing-example': ScalarPropertyMissingExample, | ||
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength, | ||
'spec-strict-refs': SpecStrictRefs, | ||
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined, | ||
'no-schema-type-mismatch': NoSchemaTypeMismatch, | ||
}; | ||
exports.preprocessors = {}; | ||
export const preprocessors = {}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule } from '../../visitors'; | ||
import type { Oas2Rule } from '../../visitors.js'; | ||
export declare const RequestMimeType: Oas2Rule; | ||
//# sourceMappingURL=request-mime-type.d.ts.map |
@@ -1,13 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RequestMimeType = void 0; | ||
const utils_1 = require("../../utils"); | ||
const RequestMimeType = ({ allowedValues }) => { | ||
import { validateMimeType } from '../../utils.js'; | ||
export const RequestMimeType = ({ allowedValues }) => { | ||
return { | ||
Root(root, ctx) { | ||
(0, utils_1.validateMimeType)({ type: 'consumes', value: root }, ctx, allowedValues); | ||
validateMimeType({ type: 'consumes', value: root }, ctx, allowedValues); | ||
}, | ||
Operation: { | ||
leave(operation, ctx) { | ||
(0, utils_1.validateMimeType)({ type: 'consumes', value: operation }, ctx, allowedValues); | ||
validateMimeType({ type: 'consumes', value: operation }, ctx, allowedValues); | ||
}, | ||
@@ -17,2 +14,2 @@ }, | ||
}; | ||
exports.RequestMimeType = RequestMimeType; | ||
//# sourceMappingURL=request-mime-type.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule } from '../../visitors'; | ||
import type { Oas2Rule } from '../../visitors.js'; | ||
export declare const ResponseContainsProperty: Oas2Rule; | ||
//# sourceMappingURL=response-contains-property.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ResponseContainsProperty = void 0; | ||
const utils_1 = require("../../utils"); | ||
const ResponseContainsProperty = (options) => { | ||
import { getMatchingStatusCodeRange } from '../../utils.js'; | ||
export const ResponseContainsProperty = (options) => { | ||
const names = options.names || {}; | ||
@@ -21,4 +18,4 @@ let key; | ||
const expectedProperties = names[key] || | ||
names[(0, utils_1.getMatchingStatusCodeRange)(key)] || | ||
names[(0, utils_1.getMatchingStatusCodeRange)(key).toLowerCase()] || | ||
names[getMatchingStatusCodeRange(key)] || | ||
names[getMatchingStatusCodeRange(key).toLowerCase()] || | ||
[]; | ||
@@ -38,2 +35,2 @@ for (const expectedProperty of expectedProperties) { | ||
}; | ||
exports.ResponseContainsProperty = ResponseContainsProperty; | ||
//# sourceMappingURL=response-contains-property.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule } from '../../visitors'; | ||
import type { Oas2Rule } from '../../visitors.js'; | ||
export declare const ResponseMimeType: Oas2Rule; | ||
//# sourceMappingURL=response-mime-type.d.ts.map |
@@ -1,13 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ResponseMimeType = void 0; | ||
const utils_1 = require("../../utils"); | ||
const ResponseMimeType = ({ allowedValues }) => { | ||
import { validateMimeType } from '../../utils.js'; | ||
export const ResponseMimeType = ({ allowedValues }) => { | ||
return { | ||
Root(root, ctx) { | ||
(0, utils_1.validateMimeType)({ type: 'produces', value: root }, ctx, allowedValues); | ||
validateMimeType({ type: 'produces', value: root }, ctx, allowedValues); | ||
}, | ||
Operation: { | ||
leave(operation, ctx) { | ||
(0, utils_1.validateMimeType)({ type: 'produces', value: operation }, ctx, allowedValues); | ||
validateMimeType({ type: 'produces', value: operation }, ctx, allowedValues); | ||
}, | ||
@@ -17,2 +14,2 @@ }, | ||
}; | ||
exports.ResponseMimeType = ResponseMimeType; | ||
//# sourceMappingURL=response-mime-type.js.map |
@@ -1,2 +0,2 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export type ArrayParameterSerializationOptions = { | ||
@@ -6,1 +6,2 @@ in?: string[]; | ||
export declare const ArrayParameterSerialization: Oas3Rule; | ||
//# sourceMappingURL=array-parameter-serialization.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ArrayParameterSerialization = void 0; | ||
const ref_utils_1 = require("../../ref-utils"); | ||
const ArrayParameterSerialization = (options) => { | ||
import { isRef } from '../../ref-utils.js'; | ||
export const ArrayParameterSerialization = (options) => { | ||
return { | ||
@@ -12,3 +9,3 @@ Parameter: { | ||
} | ||
const schema = ((0, ref_utils_1.isRef)(node.schema) ? ctx.resolve(node.schema).node : node.schema); | ||
const schema = (isRef(node.schema) ? ctx.resolve(node.schema).node : node.schema); | ||
if (schema && | ||
@@ -25,3 +22,2 @@ shouldReportMissingStyleAndExplode(node, schema, options)) { | ||
}; | ||
exports.ArrayParameterSerialization = ArrayParameterSerialization; | ||
function shouldReportMissingStyleAndExplode(node, schema, options) { | ||
@@ -32,1 +28,2 @@ return ((schema.type === 'array' || schema.items || schema.prefixItems) && | ||
} | ||
//# sourceMappingURL=array-parameter-serialization.js.map |
@@ -1,2 +0,2 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export type BooleanParameterPrefixesOptions = { | ||
@@ -6,1 +6,2 @@ prefixes?: string[]; | ||
export declare const BooleanParameterPrefixes: Oas3Rule; | ||
//# sourceMappingURL=boolean-parameter-prefixes.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BooleanParameterPrefixes = void 0; | ||
const BooleanParameterPrefixes = (options) => { | ||
export const BooleanParameterPrefixes = (options) => { | ||
const prefixes = options.prefixes || ['is', 'has']; | ||
@@ -24,2 +21,2 @@ const regexp = new RegExp(`^(${prefixes.join('|')})[A-Z-_]`); | ||
}; | ||
exports.BooleanParameterPrefixes = BooleanParameterPrefixes; | ||
//# sourceMappingURL=boolean-parameter-prefixes.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors'; | ||
import type { Oas2Rule, Oas3Rule } from '../../visitors.js'; | ||
export declare const ComponentNameUnique: Oas3Rule | Oas2Rule; | ||
//# sourceMappingURL=component-name-unique.d.ts.map |
@@ -1,4 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ComponentNameUnique = void 0; | ||
const TYPE_NAME_SCHEMA = 'Schema'; | ||
@@ -14,3 +11,3 @@ const TYPE_NAME_PARAMETER = 'Parameter'; | ||
}; | ||
const ComponentNameUnique = (options) => { | ||
export const ComponentNameUnique = (options) => { | ||
const components = new Map(); | ||
@@ -124,3 +121,2 @@ const typeNames = []; | ||
}; | ||
exports.ComponentNameUnique = ComponentNameUnique; | ||
function getOptionComponentNameForTypeName(typeName) { | ||
@@ -136,1 +132,2 @@ return TYPE_NAME_TO_OPTION_COMPONENT_NAME[typeName] ?? null; | ||
} | ||
//# sourceMappingURL=component-name-unique.js.map |
@@ -1,3 +0,4 @@ | ||
import type { Oas3RuleSet } from '../../oas-types'; | ||
import type { Oas3RuleSet } from '../../oas-types.js'; | ||
export declare const rules: Oas3RuleSet<'built-in'>; | ||
export declare const preprocessors: {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,124 +0,119 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.preprocessors = exports.rules = void 0; | ||
const struct_1 = require("../common/struct"); | ||
const operation_2xx_response_1 = require("../common/operation-2xx-response"); | ||
const operation_4xx_response_1 = require("../common/operation-4xx-response"); | ||
const assertions_1 = require("../common/assertions"); | ||
const operation_operationId_unique_1 = require("../common/operation-operationId-unique"); | ||
const operation_parameters_unique_1 = require("../common/operation-parameters-unique"); | ||
const path_params_defined_1 = require("../common/path-params-defined"); | ||
const operation_tag_defined_1 = require("../common/operation-tag-defined"); | ||
const no_example_value_and_externalValue_1 = require("./no-example-value-and-externalValue"); | ||
const no_enum_type_mismatch_1 = require("../common/no-enum-type-mismatch"); | ||
const no_path_trailing_slash_1 = require("../common/no-path-trailing-slash"); | ||
const path_declaration_must_exist_1 = require("../common/path-declaration-must-exist"); | ||
const operation_operationId_url_safe_1 = require("../common/operation-operationId-url-safe"); | ||
const tags_alphabetical_1 = require("../common/tags-alphabetical"); | ||
const no_server_example_com_1 = require("./no-server-example.com"); | ||
const no_server_trailing_slash_1 = require("./no-server-trailing-slash"); | ||
const tag_description_1 = require("../common/tag-description"); | ||
const info_contact_1 = require("../common/info-contact"); | ||
const info_license_1 = require("../common/info-license"); | ||
const info_license_url_1 = require("../common/info-license-url"); | ||
const info_license_strict_1 = require("../common/info-license-strict"); | ||
const operation_description_1 = require("../common/operation-description"); | ||
const no_unused_components_1 = require("./no-unused-components"); | ||
const path_not_include_query_1 = require("../common/path-not-include-query"); | ||
const parameter_description_1 = require("../common/parameter-description"); | ||
const operation_singular_tag_1 = require("../common/operation-singular-tag"); | ||
const security_defined_1 = require("../common/security-defined"); | ||
const no_unresolved_refs_1 = require("../no-unresolved-refs"); | ||
const boolean_parameter_prefixes_1 = require("./boolean-parameter-prefixes"); | ||
const paths_kebab_case_1 = require("../common/paths-kebab-case"); | ||
const path_http_verbs_order_1 = require("../common/path-http-verbs-order"); | ||
const no_empty_servers_1 = require("./no-empty-servers"); | ||
const no_invalid_media_type_examples_1 = require("./no-invalid-media-type-examples"); | ||
const no_identical_paths_1 = require("../common/no-identical-paths"); | ||
const no_undefined_server_variable_1 = require("./no-undefined-server-variable"); | ||
const operation_operationId_1 = require("../common/operation-operationId"); | ||
const operation_summary_1 = require("../common/operation-summary"); | ||
const no_ambiguous_paths_1 = require("../common/no-ambiguous-paths"); | ||
const no_server_variables_empty_enum_1 = require("./no-server-variables-empty-enum"); | ||
const no_http_verbs_in_paths_1 = require("../common/no-http-verbs-in-paths"); | ||
const request_mime_type_1 = require("./request-mime-type"); | ||
const response_mime_type_1 = require("./response-mime-type"); | ||
const path_segment_plural_1 = require("../common/path-segment-plural"); | ||
const path_excludes_patterns_1 = require("../common/path-excludes-patterns"); | ||
const no_invalid_schema_examples_1 = require("../common/no-invalid-schema-examples"); | ||
const no_invalid_parameter_examples_1 = require("../common/no-invalid-parameter-examples"); | ||
const response_contains_header_1 = require("../common/response-contains-header"); | ||
const response_contains_property_1 = require("./response-contains-property"); | ||
const scalar_property_missing_example_1 = require("../common/scalar-property-missing-example"); | ||
const spec_components_invalid_map_name_1 = require("./spec-components-invalid-map-name"); | ||
const operation_4xx_problem_details_rfc7807_1 = require("./operation-4xx-problem-details-rfc7807"); | ||
const required_string_property_missing_min_length_1 = require("../common/required-string-property-missing-min-length"); | ||
const spec_strict_refs_1 = require("../common/spec-strict-refs"); | ||
const component_name_unique_1 = require("./component-name-unique"); | ||
const array_parameter_serialization_1 = require("./array-parameter-serialization"); | ||
const no_required_schema_properties_undefined_1 = require("../common/no-required-schema-properties-undefined"); | ||
const no_schema_type_mismatch_1 = require("../common/no-schema-type-mismatch"); | ||
exports.rules = { | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
//@ts-ignore TODO: This is depricated property `spec` and should be removed in the future | ||
spec: struct_1.Struct, | ||
struct: struct_1.Struct, | ||
'info-contact': info_contact_1.InfoContact, | ||
'info-license': info_license_1.InfoLicense, | ||
'info-license-url': info_license_url_1.InfoLicenseUrl, | ||
'info-license-strict': info_license_strict_1.InfoLicenseStrict, | ||
'operation-2xx-response': operation_2xx_response_1.Operation2xxResponse, | ||
'operation-4xx-response': operation_4xx_response_1.Operation4xxResponse, | ||
'operation-4xx-problem-details-rfc7807': operation_4xx_problem_details_rfc7807_1.Operation4xxProblemDetailsRfc7807, | ||
assertions: assertions_1.Assertions, | ||
'operation-operationId-unique': operation_operationId_unique_1.OperationIdUnique, | ||
'operation-parameters-unique': operation_parameters_unique_1.OperationParametersUnique, | ||
'operation-tag-defined': operation_tag_defined_1.OperationTagDefined, | ||
'no-example-value-and-externalValue': no_example_value_and_externalValue_1.NoExampleValueAndExternalValue, | ||
'no-enum-type-mismatch': no_enum_type_mismatch_1.NoEnumTypeMismatch, | ||
'no-path-trailing-slash': no_path_trailing_slash_1.NoPathTrailingSlash, | ||
'no-empty-servers': no_empty_servers_1.NoEmptyServers, | ||
'path-declaration-must-exist': path_declaration_must_exist_1.PathDeclarationMustExist, | ||
'operation-operationId-url-safe': operation_operationId_url_safe_1.OperationIdUrlSafe, | ||
'operation-operationId': operation_operationId_1.OperationOperationId, | ||
'operation-summary': operation_summary_1.OperationSummary, | ||
'tags-alphabetical': tags_alphabetical_1.TagsAlphabetical, | ||
'no-server-example.com': no_server_example_com_1.NoServerExample, | ||
'no-server-trailing-slash': no_server_trailing_slash_1.NoServerTrailingSlash, | ||
'tag-description': tag_description_1.TagDescription, | ||
'operation-description': operation_description_1.OperationDescription, | ||
'no-unused-components': no_unused_components_1.NoUnusedComponents, | ||
'path-not-include-query': path_not_include_query_1.PathNotIncludeQuery, | ||
'path-parameters-defined': path_params_defined_1.PathParamsDefined, | ||
'path-params-defined': path_params_defined_1.PathParamsDefined, | ||
'parameter-description': parameter_description_1.ParameterDescription, | ||
'operation-singular-tag': operation_singular_tag_1.OperationSingularTag, | ||
'security-defined': security_defined_1.SecurityDefined, | ||
'no-unresolved-refs': no_unresolved_refs_1.NoUnresolvedRefs, | ||
'paths-kebab-case': paths_kebab_case_1.PathsKebabCase, | ||
'boolean-parameter-prefixes': boolean_parameter_prefixes_1.BooleanParameterPrefixes, | ||
'path-http-verbs-order': path_http_verbs_order_1.PathHttpVerbsOrder, | ||
'no-invalid-media-type-examples': no_invalid_media_type_examples_1.ValidContentExamples, | ||
'no-identical-paths': no_identical_paths_1.NoIdenticalPaths, | ||
'no-ambiguous-paths': no_ambiguous_paths_1.NoAmbiguousPaths, | ||
'no-undefined-server-variable': no_undefined_server_variable_1.NoUndefinedServerVariable, | ||
'no-server-variables-empty-enum': no_server_variables_empty_enum_1.NoServerVariablesEmptyEnum, | ||
'no-http-verbs-in-paths': no_http_verbs_in_paths_1.NoHttpVerbsInPaths, | ||
'path-excludes-patterns': path_excludes_patterns_1.PathExcludesPatterns, | ||
'request-mime-type': request_mime_type_1.RequestMimeType, | ||
'response-mime-type': response_mime_type_1.ResponseMimeType, | ||
'path-segment-plural': path_segment_plural_1.PathSegmentPlural, | ||
'no-invalid-schema-examples': no_invalid_schema_examples_1.NoInvalidSchemaExamples, | ||
'no-invalid-parameter-examples': no_invalid_parameter_examples_1.NoInvalidParameterExamples, | ||
'response-contains-header': response_contains_header_1.ResponseContainsHeader, | ||
'response-contains-property': response_contains_property_1.ResponseContainsProperty, | ||
'scalar-property-missing-example': scalar_property_missing_example_1.ScalarPropertyMissingExample, | ||
'spec-components-invalid-map-name': spec_components_invalid_map_name_1.SpecComponentsInvalidMapName, | ||
'required-string-property-missing-min-length': required_string_property_missing_min_length_1.RequiredStringPropertyMissingMinLength, | ||
'spec-strict-refs': spec_strict_refs_1.SpecStrictRefs, | ||
'component-name-unique': component_name_unique_1.ComponentNameUnique, | ||
'array-parameter-serialization': array_parameter_serialization_1.ArrayParameterSerialization, | ||
'no-required-schema-properties-undefined': no_required_schema_properties_undefined_1.NoRequiredSchemaPropertiesUndefined, | ||
'no-schema-type-mismatch': no_schema_type_mismatch_1.NoSchemaTypeMismatch, | ||
import { Struct } from '../common/struct.js'; | ||
import { Operation2xxResponse } from '../common/operation-2xx-response.js'; | ||
import { Operation4xxResponse } from '../common/operation-4xx-response.js'; | ||
import { Assertions } from '../common/assertions/index.js'; | ||
import { OperationIdUnique } from '../common/operation-operationId-unique.js'; | ||
import { OperationParametersUnique } from '../common/operation-parameters-unique.js'; | ||
import { PathParamsDefined } from '../common/path-params-defined.js'; | ||
import { OperationTagDefined } from '../common/operation-tag-defined.js'; | ||
import { NoExampleValueAndExternalValue } from './no-example-value-and-externalValue.js'; | ||
import { NoEnumTypeMismatch } from '../common/no-enum-type-mismatch.js'; | ||
import { NoPathTrailingSlash } from '../common/no-path-trailing-slash.js'; | ||
import { PathDeclarationMustExist } from '../common/path-declaration-must-exist.js'; | ||
import { OperationIdUrlSafe } from '../common/operation-operationId-url-safe.js'; | ||
import { TagsAlphabetical } from '../common/tags-alphabetical.js'; | ||
import { NoServerExample } from './no-server-example.com.js'; | ||
import { NoServerTrailingSlash } from './no-server-trailing-slash.js'; | ||
import { TagDescription } from '../common/tag-description.js'; | ||
import { InfoContact } from '../common/info-contact.js'; | ||
import { InfoLicense } from '../common/info-license.js'; | ||
import { InfoLicenseUrl } from '../common/info-license-url.js'; | ||
import { InfoLicenseStrict } from '../common/info-license-strict.js'; | ||
import { OperationDescription } from '../common/operation-description.js'; | ||
import { NoUnusedComponents } from './no-unused-components.js'; | ||
import { PathNotIncludeQuery } from '../common/path-not-include-query.js'; | ||
import { ParameterDescription } from '../common/parameter-description.js'; | ||
import { OperationSingularTag } from '../common/operation-singular-tag.js'; | ||
import { SecurityDefined } from '../common/security-defined.js'; | ||
import { NoUnresolvedRefs } from '../no-unresolved-refs.js'; | ||
import { BooleanParameterPrefixes } from './boolean-parameter-prefixes.js'; | ||
import { PathsKebabCase } from '../common/paths-kebab-case.js'; | ||
import { PathHttpVerbsOrder } from '../common/path-http-verbs-order.js'; | ||
import { NoEmptyServers } from './no-empty-servers.js'; | ||
import { ValidContentExamples } from './no-invalid-media-type-examples.js'; | ||
import { NoIdenticalPaths } from '../common/no-identical-paths.js'; | ||
import { NoUndefinedServerVariable } from './no-undefined-server-variable.js'; | ||
import { OperationOperationId } from '../common/operation-operationId.js'; | ||
import { OperationSummary } from '../common/operation-summary.js'; | ||
import { NoAmbiguousPaths } from '../common/no-ambiguous-paths.js'; | ||
import { NoServerVariablesEmptyEnum } from './no-server-variables-empty-enum.js'; | ||
import { NoHttpVerbsInPaths } from '../common/no-http-verbs-in-paths.js'; | ||
import { RequestMimeType } from './request-mime-type.js'; | ||
import { ResponseMimeType } from './response-mime-type.js'; | ||
import { PathSegmentPlural } from '../common/path-segment-plural.js'; | ||
import { PathExcludesPatterns } from '../common/path-excludes-patterns.js'; | ||
import { NoInvalidSchemaExamples } from '../common/no-invalid-schema-examples.js'; | ||
import { NoInvalidParameterExamples } from '../common/no-invalid-parameter-examples.js'; | ||
import { ResponseContainsHeader } from '../common/response-contains-header.js'; | ||
import { ResponseContainsProperty } from './response-contains-property.js'; | ||
import { ScalarPropertyMissingExample } from '../common/scalar-property-missing-example.js'; | ||
import { SpecComponentsInvalidMapName } from './spec-components-invalid-map-name.js'; | ||
import { Operation4xxProblemDetailsRfc7807 } from './operation-4xx-problem-details-rfc7807.js'; | ||
import { RequiredStringPropertyMissingMinLength } from '../common/required-string-property-missing-min-length.js'; | ||
import { SpecStrictRefs } from '../common/spec-strict-refs.js'; | ||
import { ComponentNameUnique } from './component-name-unique.js'; | ||
import { ArrayParameterSerialization } from './array-parameter-serialization.js'; | ||
import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined.js'; | ||
import { NoSchemaTypeMismatch } from '../common/no-schema-type-mismatch.js'; | ||
export const rules = { | ||
struct: Struct, | ||
'info-contact': InfoContact, | ||
'info-license': InfoLicense, | ||
'info-license-url': InfoLicenseUrl, | ||
'info-license-strict': InfoLicenseStrict, | ||
'operation-2xx-response': Operation2xxResponse, | ||
'operation-4xx-response': Operation4xxResponse, | ||
'operation-4xx-problem-details-rfc7807': Operation4xxProblemDetailsRfc7807, | ||
assertions: Assertions, | ||
'operation-operationId-unique': OperationIdUnique, | ||
'operation-parameters-unique': OperationParametersUnique, | ||
'operation-tag-defined': OperationTagDefined, | ||
'no-example-value-and-externalValue': NoExampleValueAndExternalValue, | ||
'no-enum-type-mismatch': NoEnumTypeMismatch, | ||
'no-path-trailing-slash': NoPathTrailingSlash, | ||
'no-empty-servers': NoEmptyServers, | ||
'path-declaration-must-exist': PathDeclarationMustExist, | ||
'operation-operationId-url-safe': OperationIdUrlSafe, | ||
'operation-operationId': OperationOperationId, | ||
'operation-summary': OperationSummary, | ||
'tags-alphabetical': TagsAlphabetical, | ||
'no-server-example.com': NoServerExample, | ||
'no-server-trailing-slash': NoServerTrailingSlash, | ||
'tag-description': TagDescription, | ||
'operation-description': OperationDescription, | ||
'no-unused-components': NoUnusedComponents, | ||
'path-not-include-query': PathNotIncludeQuery, | ||
'path-parameters-defined': PathParamsDefined, | ||
'path-params-defined': PathParamsDefined, | ||
'parameter-description': ParameterDescription, | ||
'operation-singular-tag': OperationSingularTag, | ||
'security-defined': SecurityDefined, | ||
'no-unresolved-refs': NoUnresolvedRefs, | ||
'paths-kebab-case': PathsKebabCase, | ||
'boolean-parameter-prefixes': BooleanParameterPrefixes, | ||
'path-http-verbs-order': PathHttpVerbsOrder, | ||
'no-invalid-media-type-examples': ValidContentExamples, | ||
'no-identical-paths': NoIdenticalPaths, | ||
'no-ambiguous-paths': NoAmbiguousPaths, | ||
'no-undefined-server-variable': NoUndefinedServerVariable, | ||
'no-server-variables-empty-enum': NoServerVariablesEmptyEnum, | ||
'no-http-verbs-in-paths': NoHttpVerbsInPaths, | ||
'path-excludes-patterns': PathExcludesPatterns, | ||
'request-mime-type': RequestMimeType, | ||
'response-mime-type': ResponseMimeType, | ||
'path-segment-plural': PathSegmentPlural, | ||
'no-invalid-schema-examples': NoInvalidSchemaExamples, | ||
'no-invalid-parameter-examples': NoInvalidParameterExamples, | ||
'response-contains-header': ResponseContainsHeader, | ||
'response-contains-property': ResponseContainsProperty, | ||
'scalar-property-missing-example': ScalarPropertyMissingExample, | ||
'spec-components-invalid-map-name': SpecComponentsInvalidMapName, | ||
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength, | ||
'spec-strict-refs': SpecStrictRefs, | ||
'component-name-unique': ComponentNameUnique, | ||
'array-parameter-serialization': ArrayParameterSerialization, | ||
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined, | ||
'no-schema-type-mismatch': NoSchemaTypeMismatch, | ||
}; | ||
exports.preprocessors = {}; | ||
export const preprocessors = {}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const NoEmptyServers: Oas3Rule; | ||
//# sourceMappingURL=no-empty-servers.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoEmptyServers = void 0; | ||
const NoEmptyServers = () => { | ||
export const NoEmptyServers = () => { | ||
return { | ||
@@ -23,2 +20,2 @@ Root(root, { report, location }) { | ||
}; | ||
exports.NoEmptyServers = NoEmptyServers; | ||
//# sourceMappingURL=no-empty-servers.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const NoExampleValueAndExternalValue: Oas3Rule; | ||
//# sourceMappingURL=no-example-value-and-externalValue.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoExampleValueAndExternalValue = void 0; | ||
const NoExampleValueAndExternalValue = () => { | ||
export const NoExampleValueAndExternalValue = () => { | ||
return { | ||
@@ -16,2 +13,2 @@ Example(example, { report, location }) { | ||
}; | ||
exports.NoExampleValueAndExternalValue = NoExampleValueAndExternalValue; | ||
//# sourceMappingURL=no-example-value-and-externalValue.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const ValidContentExamples: Oas3Rule; | ||
//# sourceMappingURL=no-invalid-media-type-examples.d.ts.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ValidContentExamples = void 0; | ||
const ref_utils_1 = require("../../ref-utils"); | ||
const utils_1 = require("../utils"); | ||
const ValidContentExamples = (opts) => { | ||
const allowAdditionalProperties = (0, utils_1.getAdditionalPropertiesOption)(opts) ?? false; | ||
import { isRef } from '../../ref-utils.js'; | ||
import { getAdditionalPropertiesOption, validateExample } from '../utils.js'; | ||
export const ValidContentExamples = (opts) => { | ||
const allowAdditionalProperties = getAdditionalPropertiesOption(opts) ?? false; | ||
return { | ||
@@ -23,3 +20,3 @@ MediaType: { | ||
function resolveAndValidateExample(example, location, isMultiple) { | ||
if ((0, ref_utils_1.isRef)(example)) { | ||
if (isRef(example)) { | ||
const resolved = resolve(example); | ||
@@ -34,3 +31,3 @@ if (!resolved.location) | ||
} | ||
(0, utils_1.validateExample)(isMultiple ? example.value : example, mediaType.schema, location, ctx, allowAdditionalProperties); | ||
validateExample(isMultiple ? example.value : example, mediaType.schema, location, ctx, allowAdditionalProperties); | ||
} | ||
@@ -41,2 +38,2 @@ }, | ||
}; | ||
exports.ValidContentExamples = ValidContentExamples; | ||
//# sourceMappingURL=no-invalid-media-type-examples.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const NoServerExample: Oas3Rule; | ||
//# sourceMappingURL=no-server-example.com.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoServerExample = void 0; | ||
const NoServerExample = () => { | ||
export const NoServerExample = () => { | ||
return { | ||
@@ -18,2 +15,2 @@ Server(server, { report, location }) { | ||
}; | ||
exports.NoServerExample = NoServerExample; | ||
//# sourceMappingURL=no-server-example.com.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const NoServerTrailingSlash: Oas3Rule; | ||
//# sourceMappingURL=no-server-trailing-slash.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoServerTrailingSlash = void 0; | ||
const NoServerTrailingSlash = () => { | ||
export const NoServerTrailingSlash = () => { | ||
return { | ||
@@ -18,2 +15,2 @@ Server(server, { report, location }) { | ||
}; | ||
exports.NoServerTrailingSlash = NoServerTrailingSlash; | ||
//# sourceMappingURL=no-server-trailing-slash.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const NoServerVariablesEmptyEnum: Oas3Rule; | ||
//# sourceMappingURL=no-server-variables-empty-enum.d.ts.map |
@@ -1,4 +0,1 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoServerVariablesEmptyEnum = void 0; | ||
var enumError; | ||
@@ -9,3 +6,3 @@ (function (enumError) { | ||
})(enumError || (enumError = {})); | ||
const NoServerVariablesEmptyEnum = () => { | ||
export const NoServerVariablesEmptyEnum = () => { | ||
return { | ||
@@ -47,3 +44,2 @@ Root(root, { report, location }) { | ||
}; | ||
exports.NoServerVariablesEmptyEnum = NoServerVariablesEmptyEnum; | ||
function checkEnumVariables(server) { | ||
@@ -69,1 +65,2 @@ if (server.variables && Object.keys(server.variables).length === 0) | ||
} | ||
//# sourceMappingURL=no-server-variables-empty-enum.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const NoUndefinedServerVariable: Oas3Rule; | ||
//# sourceMappingURL=no-undefined-server-variable.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoUndefinedServerVariable = void 0; | ||
const NoUndefinedServerVariable = () => { | ||
export const NoUndefinedServerVariable = () => { | ||
return { | ||
@@ -31,2 +28,2 @@ Server(server, { report, location }) { | ||
}; | ||
exports.NoUndefinedServerVariable = NoUndefinedServerVariable; | ||
//# sourceMappingURL=no-undefined-server-variable.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const NoUnusedComponents: Oas3Rule; | ||
//# sourceMappingURL=no-unused-components.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoUnusedComponents = void 0; | ||
const NoUnusedComponents = () => { | ||
export const NoUnusedComponents = () => { | ||
const components = new Map(); | ||
@@ -73,2 +70,2 @@ function registerComponent(location, name) { | ||
}; | ||
exports.NoUnusedComponents = NoUnusedComponents; | ||
//# sourceMappingURL=no-unused-components.js.map |
@@ -1,2 +0,2 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
/** | ||
@@ -6,1 +6,2 @@ * Validation according to rfc7807 - https://datatracker.ietf.org/doc/html/rfc7807 | ||
export declare const Operation4xxProblemDetailsRfc7807: Oas3Rule; | ||
//# sourceMappingURL=operation-4xx-problem-details-rfc7807.d.ts.map |
@@ -1,9 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Operation4xxProblemDetailsRfc7807 = void 0; | ||
const utils_1 = require("../utils"); | ||
import { validateDefinedAndNonEmpty } from '../utils.js'; | ||
/** | ||
* Validation according to rfc7807 - https://datatracker.ietf.org/doc/html/rfc7807 | ||
*/ | ||
const Operation4xxProblemDetailsRfc7807 = () => { | ||
export const Operation4xxProblemDetailsRfc7807 = () => { | ||
return { | ||
@@ -26,7 +23,7 @@ Response: { | ||
enter(media, ctx) { | ||
(0, utils_1.validateDefinedAndNonEmpty)('schema', media, ctx); | ||
validateDefinedAndNonEmpty('schema', media, ctx); | ||
}, | ||
SchemaProperties(schema, ctx) { | ||
(0, utils_1.validateDefinedAndNonEmpty)('type', schema, ctx); | ||
(0, utils_1.validateDefinedAndNonEmpty)('title', schema, ctx); | ||
validateDefinedAndNonEmpty('type', schema, ctx); | ||
validateDefinedAndNonEmpty('title', schema, ctx); | ||
}, | ||
@@ -37,2 +34,2 @@ }, | ||
}; | ||
exports.Operation4xxProblemDetailsRfc7807 = Operation4xxProblemDetailsRfc7807; | ||
//# sourceMappingURL=operation-4xx-problem-details-rfc7807.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const RequestMimeType: Oas3Rule; | ||
//# sourceMappingURL=request-mime-type.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RequestMimeType = void 0; | ||
const utils_1 = require("../../utils"); | ||
const RequestMimeType = ({ allowedValues }) => { | ||
import { validateMimeTypeOAS3 } from '../../utils.js'; | ||
export const RequestMimeType = ({ allowedValues }) => { | ||
return { | ||
@@ -10,3 +7,3 @@ Paths: { | ||
leave(requestBody, ctx) { | ||
(0, utils_1.validateMimeTypeOAS3)({ type: 'consumes', value: requestBody }, ctx, allowedValues); | ||
validateMimeTypeOAS3({ type: 'consumes', value: requestBody }, ctx, allowedValues); | ||
}, | ||
@@ -18,3 +15,3 @@ }, | ||
leave(response, ctx) { | ||
(0, utils_1.validateMimeTypeOAS3)({ type: 'consumes', value: response }, ctx, allowedValues); | ||
validateMimeTypeOAS3({ type: 'consumes', value: response }, ctx, allowedValues); | ||
}, | ||
@@ -27,3 +24,3 @@ }, | ||
leave(response, ctx) { | ||
(0, utils_1.validateMimeTypeOAS3)({ type: 'consumes', value: response }, ctx, allowedValues); | ||
validateMimeTypeOAS3({ type: 'consumes', value: response }, ctx, allowedValues); | ||
}, | ||
@@ -34,2 +31,2 @@ }, | ||
}; | ||
exports.RequestMimeType = RequestMimeType; | ||
//# sourceMappingURL=request-mime-type.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const ResponseContainsProperty: Oas3Rule; | ||
//# sourceMappingURL=response-contains-property.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ResponseContainsProperty = void 0; | ||
const utils_1 = require("../../utils"); | ||
const ResponseContainsProperty = (options) => { | ||
import { getMatchingStatusCodeRange } from '../../utils.js'; | ||
export const ResponseContainsProperty = (options) => { | ||
const names = options.names || {}; | ||
@@ -22,4 +19,4 @@ let key; | ||
const expectedProperties = names[key] || | ||
names[(0, utils_1.getMatchingStatusCodeRange)(key)] || | ||
names[(0, utils_1.getMatchingStatusCodeRange)(key).toLowerCase()] || | ||
names[getMatchingStatusCodeRange(key)] || | ||
names[getMatchingStatusCodeRange(key).toLowerCase()] || | ||
[]; | ||
@@ -40,2 +37,2 @@ for (const expectedProperty of expectedProperties) { | ||
}; | ||
exports.ResponseContainsProperty = ResponseContainsProperty; | ||
//# sourceMappingURL=response-contains-property.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const ResponseMimeType: Oas3Rule; | ||
//# sourceMappingURL=response-mime-type.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ResponseMimeType = void 0; | ||
const utils_1 = require("../../utils"); | ||
const ResponseMimeType = ({ allowedValues }) => { | ||
import { validateMimeTypeOAS3 } from '../../utils.js'; | ||
export const ResponseMimeType = ({ allowedValues }) => { | ||
return { | ||
@@ -10,3 +7,3 @@ Paths: { | ||
leave(response, ctx) { | ||
(0, utils_1.validateMimeTypeOAS3)({ type: 'produces', value: response }, ctx, allowedValues); | ||
validateMimeTypeOAS3({ type: 'produces', value: response }, ctx, allowedValues); | ||
}, | ||
@@ -18,3 +15,3 @@ }, | ||
leave(requestBody, ctx) { | ||
(0, utils_1.validateMimeTypeOAS3)({ type: 'produces', value: requestBody }, ctx, allowedValues); | ||
validateMimeTypeOAS3({ type: 'produces', value: requestBody }, ctx, allowedValues); | ||
}, | ||
@@ -27,3 +24,3 @@ }, | ||
leave(requestBody, ctx) { | ||
(0, utils_1.validateMimeTypeOAS3)({ type: 'produces', value: requestBody }, ctx, allowedValues); | ||
validateMimeTypeOAS3({ type: 'produces', value: requestBody }, ctx, allowedValues); | ||
}, | ||
@@ -34,2 +31,2 @@ }, | ||
}; | ||
exports.ResponseMimeType = ResponseMimeType; | ||
//# sourceMappingURL=response-mime-type.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Oas3Rule } from '../../visitors'; | ||
import type { Oas3Rule } from '../../visitors.js'; | ||
export declare const SpecComponentsInvalidMapName: Oas3Rule; | ||
//# sourceMappingURL=spec-components-invalid-map-name.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SpecComponentsInvalidMapName = void 0; | ||
const SpecComponentsInvalidMapName = () => { | ||
export const SpecComponentsInvalidMapName = () => { | ||
const KEYS_REGEX = '^[a-zA-Z0-9\\.\\-_]+$'; | ||
@@ -62,2 +59,2 @@ function validateKey(key, report, location, component) { | ||
}; | ||
exports.SpecComponentsInvalidMapName = SpecComponentsInvalidMapName; | ||
//# sourceMappingURL=spec-components-invalid-map-name.js.map |
@@ -1,4 +0,4 @@ | ||
import type { Oas3Parameter, OasRef, Oas3Tag } from '../../typings/openapi'; | ||
import type { Oas2Parameter } from '../../typings/swagger'; | ||
import type { StatsAccumulator } from '../../typings/common'; | ||
import type { Oas3Parameter, OasRef, Oas3Tag } from '../../typings/openapi.js'; | ||
import type { Oas2Parameter } from '../../typings/swagger.js'; | ||
import type { StatsAccumulator } from '../../typings/common.js'; | ||
export declare const Stats: (statsAccumulator: StatsAccumulator) => { | ||
@@ -42,1 +42,2 @@ ExternalDocs: { | ||
}; | ||
//# sourceMappingURL=stats.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Stats = void 0; | ||
const Stats = (statsAccumulator) => { | ||
export const Stats = (statsAccumulator) => { | ||
return { | ||
@@ -75,2 +72,2 @@ ExternalDocs: { | ||
}; | ||
exports.Stats = Stats; | ||
//# sourceMappingURL=stats.js.map |
@@ -1,3 +0,4 @@ | ||
import type { Overlay1RuleSet } from '../../oas-types'; | ||
import type { Overlay1RuleSet } from '../../oas-types.js'; | ||
export declare const rules: Overlay1RuleSet<'built-in'>; | ||
export declare const preprocessors: {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,12 +0,10 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.preprocessors = exports.rules = void 0; | ||
const assertions_1 = require("../common/assertions"); | ||
const info_contact_1 = require("../common/info-contact"); | ||
const struct_1 = require("../common/struct"); | ||
exports.rules = { | ||
'info-contact': info_contact_1.InfoContact, | ||
struct: struct_1.Struct, | ||
assertions: assertions_1.Assertions, | ||
import { Assertions } from '../common/assertions/index.js'; | ||
import { InfoContact } from '../common/info-contact.js'; | ||
import { Struct } from '../common/struct.js'; | ||
export const rules = { | ||
'info-contact': InfoContact, | ||
struct: Struct, | ||
assertions: Assertions, | ||
}; | ||
exports.preprocessors = {}; | ||
export const preprocessors = {}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const NoCriteriaXpath: Arazzo1Rule; | ||
//# sourceMappingURL=no-criteria-xpath.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NoCriteriaXpath = void 0; | ||
const NoCriteriaXpath = () => { | ||
export const NoCriteriaXpath = () => { | ||
return { | ||
@@ -21,2 +18,2 @@ CriterionObject: { | ||
}; | ||
exports.NoCriteriaXpath = NoCriteriaXpath; | ||
//# sourceMappingURL=no-criteria-xpath.js.map |
@@ -1,2 +0,3 @@ | ||
import type { Arazzo1Rule } from '../../visitors'; | ||
import type { Arazzo1Rule } from '../../visitors.js'; | ||
export declare const RespectSupportedVersions: Arazzo1Rule; | ||
//# sourceMappingURL=respect-supported-versions.d.ts.map |
@@ -1,14 +0,11 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RespectSupportedVersions = void 0; | ||
const arazzo_1 = require("../../typings/arazzo"); | ||
const utils_1 = require("../../utils"); | ||
const RespectSupportedVersions = () => { | ||
const supportedVersions = arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.join(', '); | ||
import { ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT } from '../../typings/arazzo.js'; | ||
import { pluralize } from '../../utils.js'; | ||
export const RespectSupportedVersions = () => { | ||
const supportedVersions = ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.join(', '); | ||
return { | ||
Root: { | ||
enter(root, { report, location }) { | ||
if (!arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.includes(root.arazzo)) { | ||
if (!ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.includes(root.arazzo)) { | ||
report({ | ||
message: `Only ${supportedVersions} Arazzo ${(0, utils_1.pluralize)('version is', arazzo_1.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.length)} fully supported by Respect.`, | ||
message: `Only ${supportedVersions} Arazzo ${pluralize('version is', ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT.length)} fully supported by Respect.`, | ||
location: location.child('arazzo'), | ||
@@ -21,2 +18,2 @@ }); | ||
}; | ||
exports.RespectSupportedVersions = RespectSupportedVersions; | ||
//# sourceMappingURL=respect-supported-versions.js.map |
@@ -1,4 +0,4 @@ | ||
import { Location } from '../ref-utils'; | ||
import type { Oas3Schema, Oas3_1Schema, Referenced } from '../typings/openapi'; | ||
import type { UserContext } from '../walk'; | ||
import { Location } from '../ref-utils.js'; | ||
import type { Oas3Schema, Oas3_1Schema, Referenced } from '../typings/openapi.js'; | ||
import type { UserContext } from '../walk.js'; | ||
export declare function oasTypeOf(value: unknown): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "integer" | "array" | "null"; | ||
@@ -23,1 +23,2 @@ /** | ||
export declare function validateResponseCodes(responseCodes: string[], codeRange: string, { report }: UserContext): void; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -1,20 +0,6 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.oasTypeOf = oasTypeOf; | ||
exports.matchesJsonSchemaType = matchesJsonSchemaType; | ||
exports.missingRequiredField = missingRequiredField; | ||
exports.missingRequiredOneOfFields = missingRequiredOneOfFields; | ||
exports.fieldNonEmpty = fieldNonEmpty; | ||
exports.validateDefinedAndNonEmpty = validateDefinedAndNonEmpty; | ||
exports.validateOneOfDefinedAndNonEmpty = validateOneOfDefinedAndNonEmpty; | ||
exports.getSuggest = getSuggest; | ||
exports.validateExample = validateExample; | ||
exports.getAdditionalPropertiesOption = getAdditionalPropertiesOption; | ||
exports.validateSchemaEnumType = validateSchemaEnumType; | ||
exports.validateResponseCodes = validateResponseCodes; | ||
const levenshtein = require("js-levenshtein"); | ||
const ref_utils_1 = require("../ref-utils"); | ||
const ajv_1 = require("./ajv"); | ||
const utils_1 = require("../utils"); | ||
function oasTypeOf(value) { | ||
import { default as levenshtein } from 'js-levenshtein'; | ||
import { Location } from '../ref-utils.js'; | ||
import { validateJsonSchema } from './ajv.js'; | ||
import { isPlainObject, showErrorForDeprecatedField, showWarningForDeprecatedField, } from '../utils.js'; | ||
export function oasTypeOf(value) { | ||
if (Array.isArray(value)) { | ||
@@ -40,3 +26,3 @@ return 'array'; | ||
*/ | ||
function matchesJsonSchemaType(value, type, nullable) { | ||
export function matchesJsonSchemaType(value, type, nullable) { | ||
if (nullable && value === null) { | ||
@@ -58,6 +44,6 @@ return true; | ||
} | ||
function missingRequiredField(type, field) { | ||
export function missingRequiredField(type, field) { | ||
return `${type} object should contain \`${field}\` field.`; | ||
} | ||
function missingRequiredOneOfFields(type, fields) { | ||
export function missingRequiredOneOfFields(type, fields) { | ||
return `${type} object should contain one of the fields: ${fields | ||
@@ -67,7 +53,7 @@ .map((field) => `\`${field}\``) | ||
} | ||
function fieldNonEmpty(type, field) { | ||
export function fieldNonEmpty(type, field) { | ||
return `${type} object \`${field}\` must be non-empty string.`; | ||
} | ||
function validateDefinedAndNonEmpty(fieldName, value, ctx) { | ||
if (!(0, utils_1.isPlainObject)(value)) { | ||
export function validateDefinedAndNonEmpty(fieldName, value, ctx) { | ||
if (!isPlainObject(value)) { | ||
return; | ||
@@ -88,4 +74,4 @@ } | ||
} | ||
function validateOneOfDefinedAndNonEmpty(fieldNames, value, ctx) { | ||
if (!(0, utils_1.isPlainObject)(value)) { | ||
export function validateOneOfDefinedAndNonEmpty(fieldNames, value, ctx) { | ||
if (!isPlainObject(value)) { | ||
return; | ||
@@ -108,3 +94,3 @@ } | ||
} | ||
function getSuggest(given, variants) { | ||
export function getSuggest(given, variants) { | ||
if (given === null) | ||
@@ -125,5 +111,5 @@ return variants; | ||
} | ||
function validateExample(example, schema, dataLoc, { resolve, location, report }, allowAdditionalProperties) { | ||
export function validateExample(example, schema, dataLoc, { resolve, location, report }, allowAdditionalProperties) { | ||
try { | ||
const { valid, errors } = (0, ajv_1.validateJsonSchema)(example, schema, location.child('schema'), dataLoc.pointer, resolve, allowAdditionalProperties); | ||
const { valid, errors } = validateJsonSchema(example, schema, location.child('schema'), dataLoc.pointer, resolve, allowAdditionalProperties); | ||
if (!valid) { | ||
@@ -134,3 +120,3 @@ for (const error of errors) { | ||
location: { | ||
...new ref_utils_1.Location(dataLoc.source, error.instancePath), | ||
...new Location(dataLoc.source, error.instancePath), | ||
reportOnKey: error.keyword === 'unevaluatedProperties' || error.keyword === 'additionalProperties', | ||
@@ -155,3 +141,3 @@ }, | ||
} | ||
function getAdditionalPropertiesOption(opts) { | ||
export function getAdditionalPropertiesOption(opts) { | ||
if (opts.disallowAdditionalProperties === undefined) { | ||
@@ -161,8 +147,8 @@ return opts.allowAdditionalProperties; | ||
if (opts.allowAdditionalProperties !== undefined) { | ||
(0, utils_1.showErrorForDeprecatedField)('disallowAdditionalProperties', 'allowAdditionalProperties', undefined); | ||
showErrorForDeprecatedField('disallowAdditionalProperties', 'allowAdditionalProperties', undefined); | ||
} | ||
(0, utils_1.showWarningForDeprecatedField)('disallowAdditionalProperties', 'allowAdditionalProperties'); | ||
showWarningForDeprecatedField('disallowAdditionalProperties', 'allowAdditionalProperties'); | ||
return !opts.disallowAdditionalProperties; | ||
} | ||
function validateSchemaEnumType(schemaEnum, propertyValue, propName, refLocation, { report, location }) { | ||
export function validateSchemaEnumType(schemaEnum, propertyValue, propName, refLocation, { report, location }) { | ||
if (!schemaEnum) { | ||
@@ -182,3 +168,3 @@ return; | ||
} | ||
function validateResponseCodes(responseCodes, codeRange, { report }) { | ||
export function validateResponseCodes(responseCodes, codeRange, { report }) { | ||
const responseCodeRegexp = new RegExp(`^${codeRange[0]}[0-9Xx]{2}$`); | ||
@@ -194,1 +180,2 @@ const containsNeededCode = responseCodes.some((code) => (codeRange === '2XX' && code === 'default') || // It's OK to replace 2xx codes with the default | ||
} | ||
//# sourceMappingURL=utils.js.map |
@@ -1,2 +0,3 @@ | ||
import { type NodeType } from '.'; | ||
import { type NodeType } from './index.js'; | ||
export declare const Arazzo1Types: Record<string, NodeType>; | ||
//# sourceMappingURL=arazzo.d.ts.map |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Arazzo1Types = void 0; | ||
const _1 = require("."); | ||
const oas3_1_1 = require("./oas3_1"); | ||
const oas3_1 = require("./oas3"); | ||
import { mapOf, listOf } from './index.js'; | ||
import { DependentRequired, Schema, SchemaProperties } from './oas3_1.js'; | ||
import { Discriminator, DiscriminatorMapping, ExternalDocs, Xml } from './oas3.js'; | ||
const Root = { | ||
@@ -39,3 +36,3 @@ properties: { | ||
}; | ||
const NamedInputs = (0, _1.mapOf)('Schema'); | ||
const NamedInputs = mapOf('Schema'); | ||
const Info = { | ||
@@ -125,4 +122,4 @@ properties: { | ||
}; | ||
const Workflows = (0, _1.listOf)('Workflow'); | ||
const Steps = (0, _1.listOf)('Step'); | ||
const Workflows = listOf('Workflow'); | ||
const Steps = listOf('Step'); | ||
const Step = { | ||
@@ -136,3 +133,3 @@ properties: { | ||
parameters: 'Parameters', | ||
successCriteria: (0, _1.listOf)('CriterionObject'), | ||
successCriteria: listOf('CriterionObject'), | ||
onSuccess: 'OnSuccessActionList', | ||
@@ -158,3 +155,3 @@ onFailure: 'OnFailureActionList', | ||
payload: {}, | ||
replacements: (0, _1.listOf)('Replacement'), | ||
replacements: listOf('Replacement'), | ||
}, | ||
@@ -241,3 +238,3 @@ required: ['payload'], | ||
workflowId: { type: 'string' }, | ||
criteria: (0, _1.listOf)('CriterionObject'), | ||
criteria: listOf('CriterionObject'), | ||
}, | ||
@@ -265,3 +262,3 @@ required: ['type', 'name'], | ||
retryLimit: { type: 'number' }, | ||
criteria: (0, _1.listOf)('CriterionObject'), | ||
criteria: listOf('CriterionObject'), | ||
}, | ||
@@ -281,3 +278,3 @@ required: ['type', 'name'], | ||
}; | ||
exports.Arazzo1Types = { | ||
export const Arazzo1Types = { | ||
Root, | ||
@@ -306,10 +303,10 @@ Info, | ||
OnFailureActionList, | ||
Schema: oas3_1_1.Schema, | ||
NamedSchemas: (0, _1.mapOf)('Schema'), | ||
ExternalDocs: oas3_1.ExternalDocs, | ||
DiscriminatorMapping: oas3_1.DiscriminatorMapping, | ||
Discriminator: oas3_1.Discriminator, | ||
DependentRequired: oas3_1_1.DependentRequired, | ||
SchemaProperties: oas3_1_1.SchemaProperties, | ||
PatternProperties: oas3_1_1.SchemaProperties, | ||
Schema, | ||
NamedSchemas: mapOf('Schema'), | ||
ExternalDocs, | ||
DiscriminatorMapping, | ||
Discriminator, | ||
DependentRequired, | ||
SchemaProperties, | ||
PatternProperties: SchemaProperties, | ||
Components, | ||
@@ -320,3 +317,4 @@ NamedInputs, | ||
NamedFailureActions, | ||
Xml: oas3_1.Xml, | ||
Xml, | ||
}; | ||
//# sourceMappingURL=arazzo.js.map |
@@ -1,2 +0,2 @@ | ||
import type { NodeType } from '.'; | ||
import type { NodeType } from './index.js'; | ||
export declare const Tag: NodeType; | ||
@@ -18,1 +18,2 @@ export declare const ExternalDocs: NodeType; | ||
export declare const AsyncApi2Types: Record<string, NodeType>; | ||
//# sourceMappingURL=asyncapi2.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AsyncApi2Types = exports.AsyncApi2Bindings = exports.Dependencies = exports.SecuritySchemeFlows = exports.Discriminator = exports.DiscriminatorMapping = exports.SchemaProperties = exports.Schema = exports.MessageExample = exports.CorrelationId = exports.License = exports.Contact = exports.ServerVariable = exports.ServerMap = exports.ExternalDocs = exports.Tag = void 0; | ||
const _1 = require("."); | ||
const ref_utils_1 = require("../ref-utils"); | ||
import { listOf, mapOf } from './index.js'; | ||
import { isMappingRef } from '../ref-utils.js'; | ||
const Root = { | ||
@@ -62,3 +59,3 @@ properties: { | ||
}; | ||
exports.Tag = { | ||
export const Tag = { | ||
properties: { | ||
@@ -71,3 +68,3 @@ name: { type: 'string' }, | ||
}; | ||
exports.ExternalDocs = { | ||
export const ExternalDocs = { | ||
properties: { | ||
@@ -124,3 +121,3 @@ description: { type: 'string' }, | ||
}; | ||
exports.ServerMap = { | ||
export const ServerMap = { | ||
properties: {}, | ||
@@ -131,3 +128,3 @@ additionalProperties: (_value, key) => | ||
}; | ||
exports.ServerVariable = { | ||
export const ServerVariable = { | ||
properties: { | ||
@@ -158,3 +155,3 @@ enum: { | ||
}; | ||
exports.Contact = { | ||
export const Contact = { | ||
properties: { | ||
@@ -166,3 +163,3 @@ name: { type: 'string' }, | ||
}; | ||
exports.License = { | ||
export const License = { | ||
properties: { | ||
@@ -181,3 +178,3 @@ name: { type: 'string' }, | ||
}; | ||
exports.CorrelationId = { | ||
export const CorrelationId = { | ||
properties: { | ||
@@ -309,3 +306,3 @@ description: { type: 'string' }, | ||
}; | ||
exports.MessageExample = { | ||
export const MessageExample = { | ||
properties: { | ||
@@ -318,3 +315,3 @@ payload: { isExample: true }, | ||
}; | ||
exports.Schema = { | ||
export const Schema = { | ||
properties: { | ||
@@ -353,5 +350,5 @@ $id: { type: 'string' }, | ||
}, | ||
allOf: (0, _1.listOf)('Schema'), | ||
anyOf: (0, _1.listOf)('Schema'), | ||
oneOf: (0, _1.listOf)('Schema'), | ||
allOf: listOf('Schema'), | ||
anyOf: listOf('Schema'), | ||
oneOf: listOf('Schema'), | ||
not: 'Schema', | ||
@@ -366,3 +363,3 @@ if: 'Schema', | ||
items: (value) => { | ||
return Array.isArray(value) ? (0, _1.listOf)('Schema') : 'Schema'; | ||
return Array.isArray(value) ? listOf('Schema') : 'Schema'; | ||
}, | ||
@@ -390,3 +387,3 @@ additionalProperties: (value) => { | ||
}; | ||
exports.SchemaProperties = { | ||
export const SchemaProperties = { | ||
properties: {}, | ||
@@ -397,6 +394,6 @@ additionalProperties: (value) => { | ||
}; | ||
exports.DiscriminatorMapping = { | ||
export const DiscriminatorMapping = { | ||
properties: {}, | ||
additionalProperties: (value) => { | ||
if ((0, ref_utils_1.isMappingRef)(value)) { | ||
if (isMappingRef(value)) { | ||
return { type: 'string', directResolveAs: 'Schema' }; | ||
@@ -409,3 +406,3 @@ } | ||
}; | ||
exports.Discriminator = { | ||
export const Discriminator = { | ||
properties: { | ||
@@ -468,3 +465,3 @@ propertyName: { type: 'string' }, | ||
}; | ||
exports.SecuritySchemeFlows = { | ||
export const SecuritySchemeFlows = { | ||
properties: { | ||
@@ -538,3 +535,3 @@ implicit: 'ImplicitFlow', | ||
}; | ||
exports.Dependencies = { | ||
export const Dependencies = { | ||
properties: {}, | ||
@@ -850,3 +847,3 @@ additionalProperties: (value) => { | ||
bindingVersion: { type: 'string' }, | ||
destinations: (0, _1.listOf)('SolaceDestination'), | ||
destinations: listOf('SolaceDestination'), | ||
}, | ||
@@ -911,3 +908,3 @@ }; | ||
// --- End per-protocol node types | ||
exports.AsyncApi2Bindings = { | ||
export const AsyncApi2Bindings = { | ||
HttpServerBinding, | ||
@@ -977,35 +974,35 @@ HttpChannelBinding, | ||
}; | ||
exports.AsyncApi2Types = { | ||
...exports.AsyncApi2Bindings, | ||
export const AsyncApi2Types = { | ||
...AsyncApi2Bindings, | ||
Root, | ||
Tag: exports.Tag, | ||
TagList: (0, _1.listOf)('Tag'), | ||
ServerMap: exports.ServerMap, | ||
ExternalDocs: exports.ExternalDocs, | ||
Tag, | ||
TagList: listOf('Tag'), | ||
ServerMap, | ||
ExternalDocs, | ||
Server, | ||
ServerVariable: exports.ServerVariable, | ||
ServerVariablesMap: (0, _1.mapOf)('ServerVariable'), | ||
ServerVariable, | ||
ServerVariablesMap: mapOf('ServerVariable'), | ||
SecurityRequirement, | ||
SecurityRequirementList: (0, _1.listOf)('SecurityRequirement'), | ||
SecurityRequirementList: listOf('SecurityRequirement'), | ||
Info, | ||
Contact: exports.Contact, | ||
License: exports.License, | ||
Contact, | ||
License, | ||
ChannelMap, | ||
Channel, | ||
Parameter, | ||
ParametersMap: (0, _1.mapOf)('Parameter'), | ||
ParametersMap: mapOf('Parameter'), | ||
Operation, | ||
Schema: exports.Schema, | ||
MessageExample: exports.MessageExample, | ||
SchemaProperties: exports.SchemaProperties, | ||
DiscriminatorMapping: exports.DiscriminatorMapping, | ||
Discriminator: exports.Discriminator, | ||
Schema, | ||
MessageExample, | ||
SchemaProperties, | ||
DiscriminatorMapping, | ||
Discriminator, | ||
Components, | ||
NamedSchemas: (0, _1.mapOf)('Schema'), | ||
NamedMessages: (0, _1.mapOf)('Message'), | ||
NamedMessageTraits: (0, _1.mapOf)('MessageTrait'), | ||
NamedOperationTraits: (0, _1.mapOf)('OperationTrait'), | ||
NamedParameters: (0, _1.mapOf)('Parameter'), | ||
NamedSecuritySchemes: (0, _1.mapOf)('SecurityScheme'), | ||
NamedCorrelationIds: (0, _1.mapOf)('CorrelationId'), | ||
NamedSchemas: mapOf('Schema'), | ||
NamedMessages: mapOf('Message'), | ||
NamedMessageTraits: mapOf('MessageTrait'), | ||
NamedOperationTraits: mapOf('OperationTrait'), | ||
NamedParameters: mapOf('Parameter'), | ||
NamedSecuritySchemes: mapOf('SecurityScheme'), | ||
NamedCorrelationIds: mapOf('CorrelationId'), | ||
ImplicitFlow, | ||
@@ -1015,3 +1012,3 @@ PasswordFlow, | ||
AuthorizationCode, | ||
SecuritySchemeFlows: exports.SecuritySchemeFlows, | ||
SecuritySchemeFlows, | ||
SecurityScheme, | ||
@@ -1022,8 +1019,9 @@ Message, | ||
OperationTrait, | ||
OperationTraitList: (0, _1.listOf)('OperationTrait'), | ||
OperationTraitList: listOf('OperationTrait'), | ||
MessageTrait, | ||
MessageTraitList: (0, _1.listOf)('MessageTrait'), | ||
MessageExampleList: (0, _1.listOf)('MessageExample'), | ||
CorrelationId: exports.CorrelationId, | ||
Dependencies: exports.Dependencies, | ||
MessageTraitList: listOf('MessageTrait'), | ||
MessageExampleList: listOf('MessageExample'), | ||
CorrelationId, | ||
Dependencies, | ||
}; | ||
//# sourceMappingURL=asyncapi2.js.map |
@@ -1,2 +0,3 @@ | ||
import type { NodeType } from '.'; | ||
import type { NodeType } from './index.js'; | ||
export declare const AsyncApi3Types: Record<string, NodeType>; | ||
//# sourceMappingURL=asyncapi3.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AsyncApi3Types = void 0; | ||
const _1 = require("."); | ||
const asyncapi2_1 = require("./asyncapi2"); | ||
import { listOf, mapOf } from './index.js'; | ||
import { AsyncApi2Bindings, Schema, Dependencies, Discriminator, DiscriminatorMapping, SchemaProperties, CorrelationId, Tag, ServerMap, ExternalDocs, SecuritySchemeFlows, ServerVariable, Contact, License, MessageExample, } from './asyncapi2.js'; | ||
const Root = { | ||
@@ -291,19 +288,19 @@ properties: { | ||
}; | ||
exports.AsyncApi3Types = { | ||
export const AsyncApi3Types = { | ||
// from asyncapi2 | ||
...asyncapi2_1.AsyncApi2Bindings, | ||
CorrelationId: asyncapi2_1.CorrelationId, | ||
SecuritySchemeFlows: asyncapi2_1.SecuritySchemeFlows, | ||
ServerVariable: asyncapi2_1.ServerVariable, | ||
Contact: asyncapi2_1.Contact, | ||
License: asyncapi2_1.License, | ||
MessageExample: asyncapi2_1.MessageExample, | ||
Tag: asyncapi2_1.Tag, | ||
Dependencies: asyncapi2_1.Dependencies, | ||
Schema: asyncapi2_1.Schema, | ||
Discriminator: asyncapi2_1.Discriminator, | ||
DiscriminatorMapping: asyncapi2_1.DiscriminatorMapping, | ||
SchemaProperties: asyncapi2_1.SchemaProperties, | ||
ServerMap: asyncapi2_1.ServerMap, | ||
ExternalDocs: asyncapi2_1.ExternalDocs, | ||
...AsyncApi2Bindings, | ||
CorrelationId, | ||
SecuritySchemeFlows, | ||
ServerVariable, | ||
Contact, | ||
License, | ||
MessageExample, | ||
Tag, | ||
Dependencies, | ||
Schema, | ||
Discriminator, | ||
DiscriminatorMapping, | ||
SchemaProperties, | ||
ServerMap, | ||
ExternalDocs, | ||
Root, | ||
@@ -326,24 +323,25 @@ Channel, | ||
OperationTrait, | ||
ServerVariablesMap: (0, _1.mapOf)('ServerVariable'), | ||
NamedTags: (0, _1.mapOf)('Tag'), | ||
NamedExternalDocs: (0, _1.mapOf)('ExternalDocs'), | ||
NamedChannels: (0, _1.mapOf)('Channel'), | ||
ParametersMap: (0, _1.mapOf)('Parameter'), | ||
NamedOperations: (0, _1.mapOf)('Operation'), | ||
NamedOperationReplies: (0, _1.mapOf)('OperationReply'), | ||
NamedOperationRelyAddresses: (0, _1.mapOf)('OperationReplyAddress'), | ||
NamedSchemas: (0, _1.mapOf)('Schema'), | ||
NamedMessages: (0, _1.mapOf)('Message'), | ||
NamedMessageTraits: (0, _1.mapOf)('MessageTrait'), | ||
NamedOperationTraits: (0, _1.mapOf)('OperationTrait'), | ||
NamedParameters: (0, _1.mapOf)('Parameter'), | ||
NamedSecuritySchemes: (0, _1.mapOf)('SecurityScheme'), | ||
NamedCorrelationIds: (0, _1.mapOf)('CorrelationId'), | ||
ServerList: (0, _1.listOf)('Server'), | ||
SecuritySchemeList: (0, _1.listOf)('SecurityScheme'), | ||
MessageList: (0, _1.listOf)('Message'), | ||
OperationTraitList: (0, _1.listOf)('OperationTrait'), | ||
MessageTraitList: (0, _1.listOf)('MessageTrait'), | ||
MessageExampleList: (0, _1.listOf)('MessageExample'), | ||
TagList: (0, _1.listOf)('Tag'), | ||
ServerVariablesMap: mapOf('ServerVariable'), | ||
NamedTags: mapOf('Tag'), | ||
NamedExternalDocs: mapOf('ExternalDocs'), | ||
NamedChannels: mapOf('Channel'), | ||
ParametersMap: mapOf('Parameter'), | ||
NamedOperations: mapOf('Operation'), | ||
NamedOperationReplies: mapOf('OperationReply'), | ||
NamedOperationRelyAddresses: mapOf('OperationReplyAddress'), | ||
NamedSchemas: mapOf('Schema'), | ||
NamedMessages: mapOf('Message'), | ||
NamedMessageTraits: mapOf('MessageTrait'), | ||
NamedOperationTraits: mapOf('OperationTrait'), | ||
NamedParameters: mapOf('Parameter'), | ||
NamedSecuritySchemes: mapOf('SecurityScheme'), | ||
NamedCorrelationIds: mapOf('CorrelationId'), | ||
ServerList: listOf('Server'), | ||
SecuritySchemeList: listOf('SecurityScheme'), | ||
MessageList: listOf('Message'), | ||
OperationTraitList: listOf('OperationTrait'), | ||
MessageTraitList: listOf('MessageTrait'), | ||
MessageExampleList: listOf('MessageExample'), | ||
TagList: listOf('Tag'), | ||
}; | ||
//# sourceMappingURL=asyncapi3.js.map |
@@ -58,1 +58,2 @@ export type ScalarSchema = { | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,9 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SpecExtension = void 0; | ||
exports.listOf = listOf; | ||
exports.mapOf = mapOf; | ||
exports.normalizeTypes = normalizeTypes; | ||
exports.isNamedType = isNamedType; | ||
function listOf(typeName) { | ||
export function listOf(typeName) { | ||
return { | ||
@@ -15,3 +8,3 @@ name: `${typeName}List`, | ||
} | ||
function mapOf(typeName) { | ||
export function mapOf(typeName) { | ||
return { | ||
@@ -23,3 +16,3 @@ name: `${typeName}Map`, | ||
} | ||
exports.SpecExtension = { | ||
export const SpecExtension = { | ||
name: 'SpecExtension', | ||
@@ -30,3 +23,3 @@ properties: {}, | ||
}; | ||
function normalizeTypes(types, options = {}) { | ||
export function normalizeTypes(types, options = {}) { | ||
const normalizedTypes = {}; | ||
@@ -43,3 +36,3 @@ for (const typeName of Object.keys(types)) { | ||
// all type trees have a SpecExtension type by default | ||
normalizedTypes['SpecExtension'] = exports.SpecExtension; | ||
normalizedTypes['SpecExtension'] = SpecExtension; | ||
return normalizedTypes; | ||
@@ -96,4 +89,5 @@ function normalizeType(type) { | ||
} | ||
function isNamedType(t) { | ||
export function isNamedType(t) { | ||
return typeof t?.name === 'string'; | ||
} | ||
//# sourceMappingURL=index.js.map |
import type { JSONSchema } from 'json-schema-to-ts'; | ||
import type { NodeType } from '.'; | ||
import type { NodeType } from './index.js'; | ||
export declare function getNodeTypesFromJSONSchema(schemaName: string, entrySchema: JSONSchema): Record<string, NodeType>; | ||
//# sourceMappingURL=json-schema-adapter.d.ts.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
// For internal usage only | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getNodeTypesFromJSONSchema = getNodeTypesFromJSONSchema; | ||
const _2020_1 = require("@redocly/ajv/dist/2020"); | ||
const utils_1 = require("../utils"); | ||
const ajv = new _2020_1.default({ | ||
import Ajv from '@redocly/ajv/dist/2020.js'; | ||
import { isPlainObject } from '../utils.js'; | ||
const ajv = new Ajv({ | ||
strictSchema: false, | ||
@@ -62,7 +59,7 @@ allowUnionTypes: true, | ||
} | ||
if ((0, utils_1.isPlainObject)(schema.properties) || | ||
(0, utils_1.isPlainObject)(schema.additionalProperties) || | ||
((0, utils_1.isPlainObject)(schema.items) && | ||
((0, utils_1.isPlainObject)(schema.items.properties) || | ||
(0, utils_1.isPlainObject)(schema.items.additionalProperties) || | ||
if (isPlainObject(schema.properties) || | ||
isPlainObject(schema.additionalProperties) || | ||
(isPlainObject(schema.items) && | ||
(isPlainObject(schema.items.properties) || | ||
isPlainObject(schema.items.additionalProperties) || | ||
schema.items.oneOf)) // exclude scalar array types | ||
@@ -90,3 +87,3 @@ ) { | ||
return (value, key) => { | ||
if ((0, utils_1.isPlainObject)(value)) { | ||
if (isPlainObject(value)) { | ||
const discriminatedTypeName = value[discriminatedPropertyName]; | ||
@@ -125,3 +122,3 @@ if (typeof discriminatedTypeName === 'string' && ctx[discriminatedTypeName]) { | ||
let additionalProperties; | ||
if ((0, utils_1.isPlainObject)(schema.additionalProperties)) { | ||
if (isPlainObject(schema.additionalProperties)) { | ||
additionalProperties = transformJSONSchemaToNodeType(propertyName + '_additionalProperties', schema.additionalProperties, ctx); | ||
@@ -133,5 +130,5 @@ } | ||
let items; | ||
if ((0, utils_1.isPlainObject)(schema.items) && | ||
((0, utils_1.isPlainObject)(schema.items.properties) || | ||
(0, utils_1.isPlainObject)(schema.items.additionalProperties) || | ||
if (isPlainObject(schema.items) && | ||
(isPlainObject(schema.items.properties) || | ||
isPlainObject(schema.items.additionalProperties) || | ||
schema.items.oneOf) // exclude scalar array types | ||
@@ -159,3 +156,3 @@ ) { | ||
} | ||
function getNodeTypesFromJSONSchema(schemaName, entrySchema) { | ||
export function getNodeTypesFromJSONSchema(schemaName, entrySchema) { | ||
const ctx = {}; | ||
@@ -165,1 +162,2 @@ transformJSONSchemaToNodeType(schemaName, entrySchema, ctx); | ||
} | ||
//# sourceMappingURL=json-schema-adapter.js.map |
@@ -1,3 +0,4 @@ | ||
import type { NodeType } from '.'; | ||
import type { Oas2NodeType } from './redocly-yaml'; | ||
import type { NodeType } from './index.js'; | ||
import type { Oas2NodeType } from './redocly-yaml.js'; | ||
export declare const Oas2Types: Record<Oas2NodeType, NodeType>; | ||
//# sourceMappingURL=oas2.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Oas2Types = void 0; | ||
const _1 = require("."); | ||
import { listOf, mapOf } from './index.js'; | ||
const responseCodeRegexp = /^[0-9][0-9Xx]{2}$/; | ||
@@ -215,3 +212,3 @@ const Root = { | ||
schema: 'Schema', | ||
headers: (0, _1.mapOf)('Header'), | ||
headers: mapOf('Header'), | ||
examples: 'Examples', | ||
@@ -302,3 +299,3 @@ 'x-summary': { type: 'string' }, | ||
if (Array.isArray(value)) { | ||
return (0, _1.listOf)('Schema'); | ||
return listOf('Schema'); | ||
} | ||
@@ -309,3 +306,3 @@ else { | ||
}, | ||
allOf: (0, _1.listOf)('Schema'), | ||
allOf: listOf('Schema'), | ||
properties: 'SchemaProperties', | ||
@@ -421,14 +418,14 @@ additionalProperties: (value) => { | ||
}; | ||
exports.Oas2Types = { | ||
export const Oas2Types = { | ||
Root, | ||
Tag, | ||
TagList: (0, _1.listOf)('Tag'), | ||
TagGroups: (0, _1.listOf)('TagGroup'), | ||
TagList: listOf('Tag'), | ||
TagGroups: listOf('TagGroup'), | ||
TagGroup, | ||
ExternalDocs, | ||
Example, | ||
ExamplesMap: (0, _1.mapOf)('Example'), | ||
ExamplesMap: mapOf('Example'), | ||
EnumDescriptions, | ||
SecurityRequirement, | ||
SecurityRequirementList: (0, _1.listOf)('SecurityRequirement'), | ||
SecurityRequirementList: listOf('SecurityRequirement'), | ||
Info, | ||
@@ -442,3 +439,3 @@ Contact, | ||
ParameterItems, | ||
ParameterList: (0, _1.listOf)('Parameter'), | ||
ParameterList: listOf('Parameter'), | ||
Operation, | ||
@@ -452,11 +449,12 @@ Examples, | ||
SchemaProperties, | ||
NamedSchemas: (0, _1.mapOf)('Schema'), | ||
NamedResponses: (0, _1.mapOf)('Response'), | ||
NamedParameters: (0, _1.mapOf)('Parameter'), | ||
NamedSecuritySchemes: (0, _1.mapOf)('SecurityScheme'), | ||
NamedSchemas: mapOf('Schema'), | ||
NamedResponses: mapOf('Response'), | ||
NamedParameters: mapOf('Parameter'), | ||
NamedSecuritySchemes: mapOf('SecurityScheme'), | ||
SecurityScheme, | ||
XCodeSample, | ||
XCodeSampleList: (0, _1.listOf)('XCodeSample'), | ||
XServerList: (0, _1.listOf)('XServer'), | ||
XCodeSampleList: listOf('XCodeSample'), | ||
XServerList: listOf('XServer'), | ||
XServer, | ||
}; | ||
//# sourceMappingURL=oas2.js.map |
@@ -1,3 +0,3 @@ | ||
import type { NodeType } from '.'; | ||
import type { Oas3_1NodeType } from './redocly-yaml'; | ||
import type { NodeType } from './index.js'; | ||
import type { Oas3_1NodeType } from './redocly-yaml.js'; | ||
export declare const Schema: NodeType; | ||
@@ -7,1 +7,2 @@ export declare const SchemaProperties: NodeType; | ||
export declare const Oas3_1Types: Record<Oas3_1NodeType, NodeType>; | ||
//# sourceMappingURL=oas3_1.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Oas3_1Types = exports.DependentRequired = exports.SchemaProperties = exports.Schema = void 0; | ||
const _1 = require("."); | ||
const oas3_1 = require("./oas3"); | ||
import { listOf, mapOf } from './index.js'; | ||
import { Oas3Types } from './oas3.js'; | ||
const Root = { | ||
@@ -84,3 +81,3 @@ properties: { | ||
}; | ||
exports.Schema = { | ||
export const Schema = { | ||
properties: { | ||
@@ -125,5 +122,5 @@ $id: { type: 'string' }, | ||
}, | ||
allOf: (0, _1.listOf)('Schema'), | ||
anyOf: (0, _1.listOf)('Schema'), | ||
oneOf: (0, _1.listOf)('Schema'), | ||
allOf: listOf('Schema'), | ||
anyOf: listOf('Schema'), | ||
oneOf: listOf('Schema'), | ||
not: 'Schema', | ||
@@ -133,5 +130,5 @@ if: 'Schema', | ||
else: 'Schema', | ||
dependentSchemas: (0, _1.mapOf)('Schema'), | ||
dependentSchemas: mapOf('Schema'), | ||
dependentRequired: 'DependentRequired', | ||
prefixItems: (0, _1.listOf)('Schema'), | ||
prefixItems: listOf('Schema'), | ||
contains: 'Schema', | ||
@@ -191,3 +188,3 @@ minContains: { type: 'integer', minimum: 0 }, | ||
}; | ||
exports.SchemaProperties = { | ||
export const SchemaProperties = { | ||
properties: {}, | ||
@@ -272,19 +269,20 @@ additionalProperties: (value) => { | ||
}; | ||
exports.DependentRequired = { | ||
export const DependentRequired = { | ||
properties: {}, | ||
additionalProperties: { type: 'array', items: { type: 'string' } }, | ||
}; | ||
exports.Oas3_1Types = { | ||
...oas3_1.Oas3Types, | ||
export const Oas3_1Types = { | ||
...Oas3Types, | ||
Info, | ||
Root, | ||
Schema: exports.Schema, | ||
SchemaProperties: exports.SchemaProperties, | ||
PatternProperties: exports.SchemaProperties, | ||
Schema, | ||
SchemaProperties, | ||
PatternProperties: SchemaProperties, | ||
License, | ||
Components, | ||
NamedPathItems: (0, _1.mapOf)('PathItem'), | ||
NamedPathItems: mapOf('PathItem'), | ||
SecurityScheme, | ||
Operation, | ||
DependentRequired: exports.DependentRequired, | ||
DependentRequired, | ||
}; | ||
//# sourceMappingURL=oas3_1.js.map |
@@ -1,3 +0,3 @@ | ||
import type { NodeType } from '.'; | ||
import type { Oas3NodeType } from './redocly-yaml'; | ||
import type { NodeType } from './index.js'; | ||
import type { Oas3NodeType } from './redocly-yaml.js'; | ||
export declare const ExternalDocs: NodeType; | ||
@@ -8,1 +8,2 @@ export declare const Xml: NodeType; | ||
export declare const Oas3Types: Record<Oas3NodeType, NodeType>; | ||
//# sourceMappingURL=oas3.d.ts.map |
@@ -1,6 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Oas3Types = exports.Discriminator = exports.DiscriminatorMapping = exports.Xml = exports.ExternalDocs = void 0; | ||
const _1 = require("."); | ||
const ref_utils_1 = require("../ref-utils"); | ||
import { listOf, mapOf } from './index.js'; | ||
import { isMappingRef } from '../ref-utils.js'; | ||
const responseCodeRegexp = /^[0-9][0-9Xx]{2}$/; | ||
@@ -42,3 +39,3 @@ const Root = { | ||
}; | ||
exports.ExternalDocs = { | ||
export const ExternalDocs = { | ||
properties: { | ||
@@ -307,5 +304,5 @@ description: { type: 'string' }, | ||
}, | ||
allOf: (0, _1.listOf)('Schema'), | ||
anyOf: (0, _1.listOf)('Schema'), | ||
oneOf: (0, _1.listOf)('Schema'), | ||
allOf: listOf('Schema'), | ||
anyOf: listOf('Schema'), | ||
oneOf: listOf('Schema'), | ||
not: 'Schema', | ||
@@ -315,3 +312,3 @@ properties: 'SchemaProperties', | ||
if (Array.isArray(value)) { | ||
return (0, _1.listOf)('Schema'); | ||
return listOf('Schema'); | ||
} | ||
@@ -345,3 +342,3 @@ else { | ||
}; | ||
exports.Xml = { | ||
export const Xml = { | ||
properties: { | ||
@@ -360,6 +357,6 @@ name: { type: 'string' }, | ||
}; | ||
exports.DiscriminatorMapping = { | ||
export const DiscriminatorMapping = { | ||
properties: {}, | ||
additionalProperties: (value) => { | ||
if ((0, ref_utils_1.isMappingRef)(value)) { | ||
if (isMappingRef(value)) { | ||
return { type: 'string', directResolveAs: 'Schema' }; | ||
@@ -372,3 +369,3 @@ } | ||
}; | ||
exports.Discriminator = { | ||
export const Discriminator = { | ||
properties: { | ||
@@ -497,15 +494,15 @@ propertyName: { type: 'string' }, | ||
}; | ||
exports.Oas3Types = { | ||
export const Oas3Types = { | ||
Root, | ||
Tag, | ||
TagList: (0, _1.listOf)('Tag'), | ||
TagGroups: (0, _1.listOf)('TagGroup'), | ||
TagList: listOf('Tag'), | ||
TagGroups: listOf('TagGroup'), | ||
TagGroup, | ||
ExternalDocs: exports.ExternalDocs, | ||
ExternalDocs, | ||
Server, | ||
ServerList: (0, _1.listOf)('Server'), | ||
ServerList: listOf('Server'), | ||
ServerVariable, | ||
ServerVariablesMap: (0, _1.mapOf)('ServerVariable'), | ||
ServerVariablesMap: mapOf('ServerVariable'), | ||
SecurityRequirement, | ||
SecurityRequirementList: (0, _1.listOf)('SecurityRequirement'), | ||
SecurityRequirementList: listOf('SecurityRequirement'), | ||
Info, | ||
@@ -517,6 +514,6 @@ Contact, | ||
Parameter, | ||
ParameterList: (0, _1.listOf)('Parameter'), | ||
ParameterList: listOf('Parameter'), | ||
Operation, | ||
Callback: (0, _1.mapOf)('PathItem'), | ||
CallbacksMap: (0, _1.mapOf)('Callback'), | ||
Callback: mapOf('PathItem'), | ||
CallbacksMap: mapOf('Callback'), | ||
RequestBody, | ||
@@ -526,8 +523,8 @@ MediaTypesMap, | ||
Example, | ||
ExamplesMap: (0, _1.mapOf)('Example'), | ||
ExamplesMap: mapOf('Example'), | ||
Encoding, | ||
EncodingMap: (0, _1.mapOf)('Encoding'), | ||
EncodingMap: mapOf('Encoding'), | ||
EnumDescriptions, | ||
Header, | ||
HeadersMap: (0, _1.mapOf)('Header'), | ||
HeadersMap: mapOf('Header'), | ||
Responses, | ||
@@ -538,17 +535,17 @@ Response, | ||
Schema, | ||
Xml: exports.Xml, | ||
Xml, | ||
SchemaProperties, | ||
DiscriminatorMapping: exports.DiscriminatorMapping, | ||
Discriminator: exports.Discriminator, | ||
DiscriminatorMapping, | ||
Discriminator, | ||
Components, | ||
LinksMap: (0, _1.mapOf)('Link'), | ||
NamedSchemas: (0, _1.mapOf)('Schema'), | ||
NamedResponses: (0, _1.mapOf)('Response'), | ||
NamedParameters: (0, _1.mapOf)('Parameter'), | ||
NamedExamples: (0, _1.mapOf)('Example'), | ||
NamedRequestBodies: (0, _1.mapOf)('RequestBody'), | ||
NamedHeaders: (0, _1.mapOf)('Header'), | ||
NamedSecuritySchemes: (0, _1.mapOf)('SecurityScheme'), | ||
NamedLinks: (0, _1.mapOf)('Link'), | ||
NamedCallbacks: (0, _1.mapOf)('Callback'), | ||
LinksMap: mapOf('Link'), | ||
NamedSchemas: mapOf('Schema'), | ||
NamedResponses: mapOf('Response'), | ||
NamedParameters: mapOf('Parameter'), | ||
NamedExamples: mapOf('Example'), | ||
NamedRequestBodies: mapOf('RequestBody'), | ||
NamedHeaders: mapOf('Header'), | ||
NamedSecuritySchemes: mapOf('SecurityScheme'), | ||
NamedLinks: mapOf('Link'), | ||
NamedCallbacks: mapOf('Callback'), | ||
ImplicitFlow, | ||
@@ -561,5 +558,6 @@ PasswordFlow, | ||
XCodeSample, | ||
XCodeSampleList: (0, _1.listOf)('XCodeSample'), | ||
XCodeSampleList: listOf('XCodeSample'), | ||
XUsePkce, | ||
WebhooksMap, | ||
}; | ||
//# sourceMappingURL=oas3.js.map |
@@ -1,2 +0,3 @@ | ||
import { type NodeType } from '.'; | ||
import { type NodeType } from './index.js'; | ||
export declare const Overlay1Types: Record<string, NodeType>; | ||
//# sourceMappingURL=overlay.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Overlay1Types = void 0; | ||
const _1 = require("."); | ||
import { listOf } from './index.js'; | ||
const Root = { | ||
@@ -23,3 +20,3 @@ properties: { | ||
}; | ||
const Actions = (0, _1.listOf)('Action'); | ||
const Actions = listOf('Action'); | ||
const Action = { | ||
@@ -35,3 +32,3 @@ properties: { | ||
}; | ||
exports.Overlay1Types = { | ||
export const Overlay1Types = { | ||
Root, | ||
@@ -42,1 +39,2 @@ Info, | ||
}; | ||
//# sourceMappingURL=overlay.js.map |
import type { JSONSchema } from 'json-schema-to-ts'; | ||
import type { NodeType } from '.'; | ||
import type { Config } from '../config'; | ||
import type { NodeType } from './index.js'; | ||
import type { Config } from '../config/index.js'; | ||
declare const builtInOAS2Rules: readonly ["info-contact", "operation-operationId", "tag-description", "tags-alphabetical", "info-license-url", "info-license-strict", "info-license", "no-ambiguous-paths", "no-enum-type-mismatch", "no-http-verbs-in-paths", "no-identical-paths", "no-invalid-parameter-examples", "no-invalid-schema-examples", "no-path-trailing-slash", "operation-2xx-response", "operation-4xx-response", "operation-description", "operation-operationId-unique", "operation-operationId-url-safe", "operation-parameters-unique", "operation-singular-tag", "operation-summary", "operation-tag-defined", "parameter-description", "path-declaration-must-exist", "path-excludes-patterns", "path-http-verbs-order", "path-not-include-query", "path-params-defined", "path-parameters-defined", "path-segment-plural", "paths-kebab-case", "required-string-property-missing-min-length", "response-contains-header", "scalar-property-missing-example", "security-defined", "spec-strict-refs", "no-unresolved-refs", "no-required-schema-properties-undefined", "no-schema-type-mismatch", "boolean-parameter-prefixes", "request-mime-type", "response-contains-property", "response-mime-type"]; | ||
@@ -28,3 +28,4 @@ export type BuiltInOAS2RuleId = typeof builtInOAS2Rules[number]; | ||
export declare const ConfigTypes: Record<string, NodeType>; | ||
export declare const NormalizedConfigTypes: Record<string, import(".").NormalizedNodeType>; | ||
export declare const NormalizedConfigTypes: Record<string, import("./index.js").NormalizedNodeType>; | ||
export {}; | ||
//# sourceMappingURL=redocly-yaml.d.ts.map |
@@ -1,11 +0,7 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.NormalizedConfigTypes = exports.ConfigTypes = void 0; | ||
exports.createConfigTypes = createConfigTypes; | ||
const config_1 = require("@redocly/config"); | ||
const _1 = require("."); | ||
const oas_types_1 = require("../oas-types"); | ||
const utils_1 = require("../utils"); | ||
const json_schema_adapter_1 = require("./json-schema-adapter"); | ||
const types_1 = require("../types"); | ||
import { rootRedoclyConfigSchema } from '@redocly/config'; | ||
import { listOf } from './index.js'; | ||
import { SpecVersion, getTypes } from '../oas-types.js'; | ||
import { isCustomRuleId, omitObjectProps, pickObjectProps } from '../utils.js'; | ||
import { getNodeTypesFromJSONSchema } from './json-schema-adapter.js'; | ||
import { normalizeTypes } from '../types/index.js'; | ||
const builtInOAS2Rules = [ | ||
@@ -311,4 +307,2 @@ 'info-contact', | ||
'features.mockServer': 'ConfigMockServer', // deprecated | ||
organization: { type: 'string' }, | ||
region: { enum: ['us', 'eu'] }, | ||
telemetry: { enum: ['on', 'off'] }, | ||
@@ -321,8 +315,2 @@ resolve: { | ||
}, | ||
files: { | ||
type: 'array', | ||
items: { | ||
type: 'string', | ||
}, | ||
}, | ||
}, | ||
@@ -347,8 +335,2 @@ }); | ||
'features.mockServer': 'ConfigMockServer', // deprecated | ||
files: { | ||
type: 'array', | ||
items: { | ||
type: 'string', | ||
}, | ||
}, | ||
}, | ||
@@ -377,4 +359,3 @@ }); | ||
} | ||
else if (key.startsWith('assert/')) { | ||
// keep the old assert/ prefix as an alias | ||
else if (builtInRules.includes(key) || isCustomRuleId(key)) { | ||
if (typeof value === 'string') { | ||
@@ -384,10 +365,2 @@ return { enum: ['error', 'warn', 'off'] }; | ||
else { | ||
return 'Assert'; | ||
} | ||
} | ||
else if (builtInRules.includes(key) || (0, utils_1.isCustomRuleId)(key)) { | ||
if (typeof value === 'string') { | ||
return { enum: ['error', 'warn', 'off'] }; | ||
} | ||
else { | ||
return 'ObjectRule'; | ||
@@ -483,3 +456,3 @@ } | ||
if (/^\w+\/\w+$/.test(key)) | ||
return { type: 'object' }; | ||
return {}; | ||
return; | ||
@@ -499,3 +472,3 @@ }, | ||
assertions: 'AssertionDefinitionAssertions', | ||
where: (0, _1.listOf)('AssertDefinition'), | ||
where: listOf('AssertDefinition'), | ||
message: { type: 'string' }, | ||
@@ -548,4 +521,4 @@ suggest: { type: 'array', items: { type: 'string' } }, | ||
properties: { | ||
beforeInfo: (0, _1.listOf)('CommonConfigSidebarLinks'), | ||
end: (0, _1.listOf)('CommonConfigSidebarLinks'), | ||
beforeInfo: listOf('CommonConfigSidebarLinks'), | ||
end: listOf('CommonConfigSidebarLinks'), | ||
}, | ||
@@ -578,3 +551,3 @@ }; | ||
const BorderThemeColors = { | ||
properties: (0, utils_1.pickObjectProps)(CommonThemeColors.properties, ['light', 'dark']), | ||
properties: pickObjectProps(CommonThemeColors.properties, ['light', 'dark']), | ||
}; | ||
@@ -603,3 +576,3 @@ const HttpColors = { | ||
const SecondaryColors = { | ||
properties: (0, utils_1.omitObjectProps)(CommonThemeColors.properties, ['dark']), | ||
properties: omitObjectProps(CommonThemeColors.properties, ['dark']), | ||
}; | ||
@@ -653,3 +626,3 @@ const TextThemeColors = { | ||
properties: { | ||
...(0, utils_1.omitObjectProps)(FontConfig.properties, ['fontSize', 'lineHeight']), | ||
...omitObjectProps(FontConfig.properties, ['fontSize', 'lineHeight']), | ||
borderRadius: { type: 'string' }, | ||
@@ -663,3 +636,3 @@ hoverStyle: { type: 'string' }, | ||
const BadgeFontConfig = { | ||
properties: (0, utils_1.pickObjectProps)(FontConfig.properties, ['fontSize', 'lineHeight']), | ||
properties: pickObjectProps(FontConfig.properties, ['fontSize', 'lineHeight']), | ||
}; | ||
@@ -674,3 +647,3 @@ const BadgeSizes = { | ||
properties: { | ||
...(0, utils_1.omitObjectProps)(FontConfig.properties, ['fontSize', 'lineHeight']), | ||
...omitObjectProps(FontConfig.properties, ['fontSize', 'lineHeight']), | ||
borderRadius: { type: 'string' }, | ||
@@ -765,3 +738,3 @@ color: { type: 'string' }, | ||
const Level1Items = { | ||
properties: (0, utils_1.pickObjectProps)(GroupItemsConfig.properties, ['textTransform']), | ||
properties: pickObjectProps(GroupItemsConfig.properties, ['textTransform']), | ||
}; | ||
@@ -780,3 +753,3 @@ const SpacingConfig = { | ||
properties: { | ||
...(0, utils_1.omitObjectProps)(FontConfig.properties, ['fontWeight', 'lineHeight']), | ||
...omitObjectProps(FontConfig.properties, ['fontWeight', 'lineHeight']), | ||
activeBgColor: { type: 'string' }, | ||
@@ -827,3 +800,3 @@ activeTextColor: { type: 'string' }, | ||
const HeadingsConfig = { | ||
properties: (0, utils_1.omitObjectProps)(FontConfig.properties, ['fontSize']), | ||
properties: omitObjectProps(FontConfig.properties, ['fontSize']), | ||
}; | ||
@@ -843,3 +816,3 @@ const LinksConfig = { | ||
fieldName: 'FontConfig', | ||
...(0, utils_1.pickObjectProps)(FontConfig.properties, ['fontSize', 'fontFamily']), | ||
...pickObjectProps(FontConfig.properties, ['fontSize', 'fontFamily']), | ||
fontWeightBold: { type: 'string' }, | ||
@@ -862,3 +835,3 @@ fontWeightLight: { type: 'string' }, | ||
color: { type: 'string' }, | ||
...(0, utils_1.omitObjectProps)(FontConfig.properties, ['fontWeight']), | ||
...omitObjectProps(FontConfig.properties, ['fontWeight']), | ||
}, | ||
@@ -940,3 +913,3 @@ }; | ||
skipOptionalParameters: { type: 'boolean' }, | ||
languages: (0, _1.listOf)('ConfigLanguage'), | ||
languages: listOf('ConfigLanguage'), | ||
}, | ||
@@ -948,3 +921,3 @@ required: ['languages'], | ||
properties: { | ||
theme: 'ConfigTheme', | ||
theme: 'ConfigTheme', // FIXME: theme is deprecated (2.0) | ||
corsProxyUrl: { type: 'string' }, | ||
@@ -1082,11 +1055,11 @@ ctrlFHijack: { type: 'boolean' }, | ||
}; | ||
function createConfigTypes(extraSchemas, config) { | ||
const nodeNames = Object.values(oas_types_1.SpecVersion).flatMap((version) => { | ||
export function createConfigTypes(extraSchemas, config) { | ||
const nodeNames = Object.values(SpecVersion).flatMap((version) => { | ||
const types = config?.styleguide | ||
? config.styleguide.extendTypes((0, oas_types_1.getTypes)(version), version) | ||
: (0, oas_types_1.getTypes)(version); | ||
? config.styleguide.extendTypes(getTypes(version), version) | ||
: getTypes(version); | ||
return Object.keys(types); | ||
}); | ||
// Create types based on external schemas | ||
const nodeTypes = (0, json_schema_adapter_1.getNodeTypesFromJSONSchema)('rootRedoclyConfigSchema', extraSchemas); | ||
const nodeTypes = getNodeTypesFromJSONSchema('rootRedoclyConfigSchema', extraSchemas); | ||
return { | ||
@@ -1162,3 +1135,4 @@ ...CoreConfigTypes, | ||
}; | ||
exports.ConfigTypes = createConfigTypes(config_1.rootRedoclyConfigSchema); | ||
exports.NormalizedConfigTypes = (0, types_1.normalizeTypes)(exports.ConfigTypes); | ||
export const ConfigTypes = createConfigTypes(rootRedoclyConfigSchema); | ||
export const NormalizedConfigTypes = normalizeTypes(ConfigTypes); | ||
//# sourceMappingURL=redocly-yaml.js.map |
@@ -132,1 +132,2 @@ export interface InfoObject { | ||
export declare const ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT: string[]; | ||
//# sourceMappingURL=arazzo.d.ts.map |
@@ -1,5 +0,3 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT = exports.VERSION_PATTERN = void 0; | ||
exports.VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/; | ||
exports.ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT = ['1.0.1']; | ||
export const VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/; | ||
export const ARAZZO_VERSIONS_SUPPORTED_BY_RESPECT = ['1.0.1']; | ||
//# sourceMappingURL=arazzo.js.map |
@@ -22,1 +22,2 @@ export interface Async2Definition { | ||
} | ||
//# sourceMappingURL=asyncapi.d.ts.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=asyncapi.js.map |
@@ -54,1 +54,2 @@ export interface Async3Definition { | ||
} | ||
//# sourceMappingURL=asyncapi3.d.ts.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=asyncapi3.js.map |
@@ -9,1 +9,2 @@ export interface StatsRow { | ||
export type StatsAccumulator = Record<StatsName, StatsRow>; | ||
//# sourceMappingURL=common.d.ts.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=common.js.map |
@@ -356,1 +356,2 @@ interface Oas3DefinitionBase<T extends Oas3Schema | Oas3_1Schema> { | ||
export {}; | ||
//# sourceMappingURL=openapi.d.ts.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=openapi.js.map |
@@ -18,1 +18,2 @@ export interface InfoObject { | ||
export declare const VERSION_PATTERN: RegExp; | ||
//# sourceMappingURL=overlay.d.ts.map |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VERSION_PATTERN = void 0; | ||
exports.VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/; | ||
export const VERSION_PATTERN = /^1\.0\.\d+(-.+)?$/; | ||
//# sourceMappingURL=overlay.js.map |
import type { Schema } from 'js-yaml'; | ||
import type { Referenced } from './openapi'; | ||
import type { Referenced } from './openapi.js'; | ||
export interface Oas2Definition { | ||
@@ -218,1 +218,2 @@ swagger: '2.0'; | ||
} | ||
//# sourceMappingURL=swagger.d.ts.map |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
export {}; | ||
//# sourceMappingURL=swagger.js.map |
@@ -1,5 +0,4 @@ | ||
import { HttpsProxyAgent } from 'https-proxy-agent'; | ||
import type { HttpResolveConfig } from './config'; | ||
import type { UserContext } from './walk'; | ||
export { parseYaml, stringifyYaml } from './js-yaml'; | ||
import type { HttpResolveConfig } from './config/index.js'; | ||
import type { UserContext } from './walk.js'; | ||
export { parseYaml, stringifyYaml } from './js-yaml/index.js'; | ||
export type StackFrame<T> = { | ||
@@ -61,3 +60,2 @@ prev: StackFrame<T> | null; | ||
export declare function pause(ms: number): Promise<void>; | ||
export declare function getProxyAgent(): HttpsProxyAgent<string> | undefined; | ||
/** | ||
@@ -72,1 +70,2 @@ * Checks if two objects are deeply equal. | ||
}; | ||
//# sourceMappingURL=utils.d.ts.map |
151
lib/utils.js
@@ -1,55 +0,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.assignConfig = exports.stringifyYaml = exports.parseYaml = void 0; | ||
exports.pushStack = pushStack; | ||
exports.pluralize = pluralize; | ||
exports.popStack = popStack; | ||
exports.loadYaml = loadYaml; | ||
exports.isDefined = isDefined; | ||
exports.isPlainObject = isPlainObject; | ||
exports.isEmptyObject = isEmptyObject; | ||
exports.isNotEmptyObject = isNotEmptyObject; | ||
exports.isEmptyArray = isEmptyArray; | ||
exports.isNotEmptyArray = isNotEmptyArray; | ||
exports.readFileFromUrl = readFileFromUrl; | ||
exports.pickObjectProps = pickObjectProps; | ||
exports.omitObjectProps = omitObjectProps; | ||
exports.splitCamelCaseIntoWords = splitCamelCaseIntoWords; | ||
exports.validateMimeType = validateMimeType; | ||
exports.validateMimeTypeOAS3 = validateMimeTypeOAS3; | ||
exports.readFileAsStringSync = readFileAsStringSync; | ||
exports.yamlAndJsonSyncReader = yamlAndJsonSyncReader; | ||
exports.isPathParameter = isPathParameter; | ||
exports.slash = slash; | ||
exports.isString = isString; | ||
exports.isNotString = isNotString; | ||
exports.assignOnlyExistingConfig = assignOnlyExistingConfig; | ||
exports.getMatchingStatusCodeRange = getMatchingStatusCodeRange; | ||
exports.isCustomRuleId = isCustomRuleId; | ||
exports.doesYamlFileExist = doesYamlFileExist; | ||
exports.showWarningForDeprecatedField = showWarningForDeprecatedField; | ||
exports.showErrorForDeprecatedField = showErrorForDeprecatedField; | ||
exports.isTruthy = isTruthy; | ||
exports.identity = identity; | ||
exports.keysOf = keysOf; | ||
exports.pickDefined = pickDefined; | ||
exports.nextTick = nextTick; | ||
exports.pause = pause; | ||
exports.getProxyAgent = getProxyAgent; | ||
exports.dequal = dequal; | ||
const fs = require("fs"); | ||
const path_1 = require("path"); | ||
const minimatch = require("minimatch"); | ||
const js_yaml_1 = require("./js-yaml"); | ||
const env_1 = require("./env"); | ||
const logger_1 = require("./logger"); | ||
const https_proxy_agent_1 = require("https-proxy-agent"); | ||
const pluralizeOne = require("pluralize"); | ||
var js_yaml_2 = require("./js-yaml"); | ||
Object.defineProperty(exports, "parseYaml", { enumerable: true, get: function () { return js_yaml_2.parseYaml; } }); | ||
Object.defineProperty(exports, "stringifyYaml", { enumerable: true, get: function () { return js_yaml_2.stringifyYaml; } }); | ||
function pushStack(head, value) { | ||
import * as fs from 'node:fs'; | ||
import * as path from 'node:path'; | ||
import { minimatch } from 'minimatch'; | ||
import pluralizeOne from 'pluralize'; | ||
import { parseYaml } from './js-yaml/index.js'; | ||
import { env } from './env.js'; | ||
import { logger, colorize } from './logger.js'; | ||
export { parseYaml, stringifyYaml } from './js-yaml/index.js'; | ||
export function pushStack(head, value) { | ||
return { prev: head, value }; | ||
} | ||
function pluralize(sentence, count, inclusive) { | ||
export function pluralize(sentence, count, inclusive) { | ||
return sentence | ||
@@ -60,28 +18,28 @@ .split(' ') | ||
} | ||
function popStack(head) { | ||
export function popStack(head) { | ||
return head?.prev ?? null; | ||
} | ||
async function loadYaml(filename) { | ||
export async function loadYaml(filename) { | ||
const contents = await fs.promises.readFile(filename, 'utf-8'); | ||
return (0, js_yaml_1.parseYaml)(contents); | ||
return parseYaml(contents); | ||
} | ||
function isDefined(x) { | ||
export function isDefined(x) { | ||
return x !== undefined; | ||
} | ||
function isPlainObject(value) { | ||
export function isPlainObject(value) { | ||
return value !== null && typeof value === 'object' && !Array.isArray(value); | ||
} | ||
function isEmptyObject(value) { | ||
export function isEmptyObject(value) { | ||
return isPlainObject(value) && Object.keys(value).length === 0; | ||
} | ||
function isNotEmptyObject(obj) { | ||
export function isNotEmptyObject(obj) { | ||
return isPlainObject(obj) && !isEmptyObject(obj); | ||
} | ||
function isEmptyArray(value) { | ||
export function isEmptyArray(value) { | ||
return Array.isArray(value) && value.length === 0; | ||
} | ||
function isNotEmptyArray(args) { | ||
export function isNotEmptyArray(args) { | ||
return !!args && Array.isArray(args) && !!args.length; | ||
} | ||
async function readFileFromUrl(url, config) { | ||
export async function readFileFromUrl(url, config) { | ||
const headers = {}; | ||
@@ -91,3 +49,3 @@ for (const header of config.headers) { | ||
headers[header.name] = | ||
header.envVariable !== undefined ? env_1.env[header.envVariable] || '' : header.value; | ||
header.envVariable !== undefined ? env[header.envVariable] || '' : header.value; | ||
} | ||
@@ -110,9 +68,9 @@ } | ||
} | ||
function pickObjectProps(object, keys) { | ||
export function pickObjectProps(object, keys) { | ||
return Object.fromEntries(keys.filter((key) => key in object).map((key) => [key, object[key]])); | ||
} | ||
function omitObjectProps(object, keys) { | ||
export function omitObjectProps(object, keys) { | ||
return Object.fromEntries(Object.entries(object).filter(([key]) => !keys.includes(key))); | ||
} | ||
function splitCamelCaseIntoWords(str) { | ||
export function splitCamelCaseIntoWords(str) { | ||
const camel = str | ||
@@ -128,3 +86,3 @@ .split(/(?:[-._])|([A-Z][a-z]+)/) | ||
} | ||
function validateMimeType({ type, value }, { report, location }, allowedValues) { | ||
export function validateMimeType({ type, value }, { report, location }, allowedValues) { | ||
const ruleType = type === 'consumes' ? 'request' : 'response'; | ||
@@ -144,3 +102,3 @@ if (!allowedValues) | ||
} | ||
function validateMimeTypeOAS3({ type, value }, { report, location }, allowedValues) { | ||
export function validateMimeTypeOAS3({ type, value }, { report, location }, allowedValues) { | ||
const ruleType = type === 'consumes' ? 'request' : 'response'; | ||
@@ -160,10 +118,10 @@ if (!allowedValues) | ||
} | ||
function readFileAsStringSync(filePath) { | ||
export function readFileAsStringSync(filePath) { | ||
return fs.readFileSync(filePath, 'utf-8'); | ||
} | ||
function yamlAndJsonSyncReader(filePath) { | ||
export function yamlAndJsonSyncReader(filePath) { | ||
const content = fs.readFileSync(filePath, 'utf-8'); | ||
return (0, js_yaml_1.parseYaml)(content); | ||
return parseYaml(content); | ||
} | ||
function isPathParameter(pathSegment) { | ||
export function isPathParameter(pathSegment) { | ||
return pathSegment.startsWith('{') && pathSegment.endsWith('}'); | ||
@@ -174,3 +132,3 @@ } | ||
*/ | ||
function slash(path) { | ||
export function slash(path) { | ||
const isExtendedLengthPath = /^\\\\\?\\/.test(path); | ||
@@ -183,9 +141,9 @@ if (isExtendedLengthPath) { | ||
// TODO: use it everywhere | ||
function isString(value) { | ||
export function isString(value) { | ||
return typeof value === 'string'; | ||
} | ||
function isNotString(value) { | ||
export function isNotString(value) { | ||
return !isString(value); | ||
} | ||
const assignConfig = (target, obj) => { | ||
export const assignConfig = (target, obj) => { | ||
if (!obj) | ||
@@ -202,4 +160,3 @@ return; | ||
}; | ||
exports.assignConfig = assignConfig; | ||
function assignOnlyExistingConfig(target, obj) { | ||
export function assignOnlyExistingConfig(target, obj) { | ||
if (!obj) | ||
@@ -218,29 +175,28 @@ return; | ||
} | ||
function getMatchingStatusCodeRange(code) { | ||
export function getMatchingStatusCodeRange(code) { | ||
return `${code}`.replace(/^(\d)\d\d$/, (_, firstDigit) => `${firstDigit}XX`); | ||
} | ||
function isCustomRuleId(id) { | ||
export function isCustomRuleId(id) { | ||
return id.includes('/'); | ||
} | ||
function doesYamlFileExist(filePath) { | ||
return (((0, path_1.extname)(filePath) === '.yaml' || (0, path_1.extname)(filePath) === '.yml') && | ||
fs?.hasOwnProperty?.('existsSync') && | ||
fs.existsSync(filePath)); | ||
export function doesYamlFileExist(filePath) { | ||
return ((path.extname(filePath) === '.yaml' || path.extname(filePath) === '.yml') && | ||
!!fs?.existsSync?.(filePath)); | ||
} | ||
function showWarningForDeprecatedField(deprecatedField, updatedField, updatedObject, link) { | ||
export function showWarningForDeprecatedField(deprecatedField, updatedField, updatedObject, link) { | ||
const readMoreText = link ? `Read more about this change: ${link}` : ''; | ||
logger_1.logger.warn(`The '${logger_1.colorize.red(deprecatedField)}' field is deprecated. ${updatedField | ||
? `Use ${logger_1.colorize.green(getUpdatedFieldName(updatedField, updatedObject))} instead. ` | ||
logger.warn(`The '${colorize.red(deprecatedField)}' field is deprecated. ${updatedField | ||
? `Use ${colorize.green(getUpdatedFieldName(updatedField, updatedObject))} instead. ` | ||
: ''}${readMoreText}\n`); | ||
} | ||
function showErrorForDeprecatedField(deprecatedField, updatedField, updatedObject) { | ||
export function showErrorForDeprecatedField(deprecatedField, updatedField, updatedObject) { | ||
throw new Error(`Do not use '${deprecatedField}' field. ${updatedField ? `Use '${getUpdatedFieldName(updatedField, updatedObject)}' instead. ` : ''}\n`); | ||
} | ||
function isTruthy(value) { | ||
export function isTruthy(value) { | ||
return !!value; | ||
} | ||
function identity(value) { | ||
export function identity(value) { | ||
return value; | ||
} | ||
function keysOf(obj) { | ||
export function keysOf(obj) { | ||
if (!obj) | ||
@@ -250,3 +206,3 @@ return []; | ||
} | ||
function pickDefined(obj) { | ||
export function pickDefined(obj) { | ||
if (!obj) | ||
@@ -262,3 +218,3 @@ return undefined; | ||
} | ||
function nextTick() { | ||
export function nextTick() { | ||
return new Promise((resolve) => { | ||
@@ -268,3 +224,3 @@ setTimeout(resolve); | ||
} | ||
async function pause(ms) { | ||
export async function pause(ms) { | ||
return new Promise((resolve) => setTimeout(resolve, ms)); | ||
@@ -275,6 +231,2 @@ } | ||
} | ||
function getProxyAgent() { | ||
const proxy = process.env.HTTPS_PROXY || process.env.HTTP_PROXY; | ||
return proxy ? new https_proxy_agent_1.HttpsProxyAgent(proxy) : undefined; | ||
} | ||
/** | ||
@@ -284,3 +236,3 @@ * Checks if two objects are deeply equal. | ||
*/ | ||
function dequal(foo, bar) { | ||
export function dequal(foo, bar) { | ||
let ctor, len; | ||
@@ -316,1 +268,2 @@ if (foo === bar) | ||
} | ||
//# sourceMappingURL=utils.js.map |
@@ -1,11 +0,11 @@ | ||
import type { NormalizedNodeType } from './types'; | ||
import type { Stack } from './utils'; | ||
import type { UserContext, ResolveResult, ProblemSeverity } from './walk'; | ||
import type { Location } from './ref-utils'; | ||
import type { Oas3Definition, Oas3_1Definition, Oas3ExternalDocs, Oas3Info, Oas3Contact, Oas3Components, Oas3_1Components, Oas3License, Oas3Schema, Oas3_1Schema, Oas3Header, Oas3Parameter, Oas3Operation, Oas3PathItem, Oas3ServerVariable, Oas3Server, Oas3MediaType, Oas3Response, Oas3Example, Oas3RequestBody, Oas3Tag, OasRef, Oas3SecurityScheme, Oas3SecurityRequirement, Oas3Encoding, Oas3Link, Oas3Xml, Oas3Discriminator, Oas3Callback } from './typings/openapi'; | ||
import type { Oas2Definition, Oas2Tag, Oas2ExternalDocs, Oas2SecurityRequirement, Oas2Info, Oas2Contact, Oas2License, Oas2PathItem, Oas2Operation, Oas2Header, Oas2Response, Oas2Schema, Oas2Xml, Oas2Parameter, Oas2SecurityScheme } from './typings/swagger'; | ||
import type { Async2Definition } from './typings/asyncapi'; | ||
import type { Async3Definition } from './typings/asyncapi3'; | ||
import type { ArazzoDefinition, ArazzoSourceDescription, CriteriaObject, ExtendedOperation, InfoObject, OnFailureObject, OnSuccessObject, OpenAPISourceDescription, Parameter, Replacement, RequestBody, SourceDescription, Step, Workflow } from './typings/arazzo'; | ||
import type { Overlay1Definition } from './typings/overlay'; | ||
import type { NormalizedNodeType } from './types/index.js'; | ||
import type { Stack } from './utils.js'; | ||
import type { UserContext, ResolveResult, ProblemSeverity } from './walk.js'; | ||
import type { Location } from './ref-utils.js'; | ||
import type { Oas3Definition, Oas3_1Definition, Oas3ExternalDocs, Oas3Info, Oas3Contact, Oas3Components, Oas3_1Components, Oas3License, Oas3Schema, Oas3_1Schema, Oas3Header, Oas3Parameter, Oas3Operation, Oas3PathItem, Oas3ServerVariable, Oas3Server, Oas3MediaType, Oas3Response, Oas3Example, Oas3RequestBody, Oas3Tag, OasRef, Oas3SecurityScheme, Oas3SecurityRequirement, Oas3Encoding, Oas3Link, Oas3Xml, Oas3Discriminator, Oas3Callback } from './typings/openapi.js'; | ||
import type { Oas2Definition, Oas2Tag, Oas2ExternalDocs, Oas2SecurityRequirement, Oas2Info, Oas2Contact, Oas2License, Oas2PathItem, Oas2Operation, Oas2Header, Oas2Response, Oas2Schema, Oas2Xml, Oas2Parameter, Oas2SecurityScheme } from './typings/swagger.js'; | ||
import type { Async2Definition } from './typings/asyncapi.js'; | ||
import type { Async3Definition } from './typings/asyncapi3.js'; | ||
import type { ArazzoDefinition, ArazzoSourceDescription, CriteriaObject, ExtendedOperation, InfoObject, OnFailureObject, OnSuccessObject, OpenAPISourceDescription, Parameter, Replacement, RequestBody, SourceDescription, Step, Workflow } from './typings/arazzo.js'; | ||
import type { Overlay1Definition } from './typings/overlay.js'; | ||
export type SkipFunctionContext = Pick<UserContext, 'location' | 'rawNode' | 'resolve' | 'rawLocation'>; | ||
@@ -241,1 +241,2 @@ export type VisitFunction<T> = (node: T, ctx: UserContext & { | ||
export {}; | ||
//# sourceMappingURL=visitors.d.ts.map |
@@ -1,5 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.normalizeVisitors = normalizeVisitors; | ||
const types_1 = require("./types"); | ||
import { SpecExtension } from './types/index.js'; | ||
const legacyTypesMap = { | ||
@@ -18,3 +15,3 @@ Root: 'DefinitionRoot', | ||
}; | ||
function normalizeVisitors(visitorsConfig, types) { | ||
export function normalizeVisitors(visitorsConfig, types) { | ||
const normalizedVisitors = {}; | ||
@@ -74,3 +71,3 @@ normalizedVisitors.any = { | ||
if (from.extensionsPrefix) { | ||
possibleChildren.add(types_1.SpecExtension); | ||
possibleChildren.add(SpecExtension); | ||
} | ||
@@ -179,1 +176,2 @@ for (const fromType of Array.from(possibleChildren.values())) { | ||
} | ||
//# sourceMappingURL=visitors.js.map |
@@ -1,9 +0,9 @@ | ||
import { Location } from './ref-utils'; | ||
import { YamlParseError } from './resolve'; | ||
import type { SpecVersion } from './oas-types'; | ||
import type { ResolveError, Source, ResolvedRefMap, Document } from './resolve'; | ||
import type { Referenced } from './typings/openapi'; | ||
import type { NormalizedOasVisitors, BaseVisitor } from './visitors'; | ||
import type { NormalizedNodeType } from './types'; | ||
import type { RuleSeverity } from './config'; | ||
import { Location } from './ref-utils.js'; | ||
import { YamlParseError } from './resolve.js'; | ||
import type { SpecVersion } from './oas-types.js'; | ||
import type { ResolveError, Source, ResolvedRefMap, Document } from './resolve.js'; | ||
import type { Referenced } from './typings/openapi.js'; | ||
import type { NormalizedOasVisitors, BaseVisitor } from './visitors.js'; | ||
import type { NormalizedNodeType } from './types/index.js'; | ||
import type { RuleSeverity } from './config/index.js'; | ||
export type NonUndefined = string | number | boolean | symbol | bigint | object | Record<string, any>; | ||
@@ -79,1 +79,2 @@ export type ResolveResult<T extends NonUndefined> = { | ||
}): void; | ||
//# sourceMappingURL=walk.d.ts.map |
@@ -1,8 +0,5 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.walkDocument = walkDocument; | ||
const ref_utils_1 = require("./ref-utils"); | ||
const utils_1 = require("./utils"); | ||
const resolve_1 = require("./resolve"); | ||
const types_1 = require("./types"); | ||
import { Location, isRef } from './ref-utils.js'; | ||
import { pushStack, popStack } from './utils.js'; | ||
import { YamlParseError, makeRefId } from './resolve.js'; | ||
import { isNamedType, SpecExtension } from './types/index.js'; | ||
function collectParents(ctx) { | ||
@@ -26,12 +23,12 @@ const parents = {}; | ||
} | ||
function walkDocument(opts) { | ||
export function walkDocument(opts) { | ||
const { document, rootType, normalizedVisitors, resolvedRefMap, ctx } = opts; | ||
const seenNodesPerType = {}; | ||
const ignoredNodes = new Set(); | ||
walkNode(document.parsed, rootType, new ref_utils_1.Location(document.source, '#/'), undefined, ''); | ||
walkNode(document.parsed, rootType, new Location(document.source, '#/'), undefined, ''); | ||
function walkNode(node, type, location, parent, key) { | ||
const resolve = (ref, from = currentLocation.source.absoluteRef) => { | ||
if (!(0, ref_utils_1.isRef)(ref)) | ||
if (!isRef(ref)) | ||
return { location, node: ref }; | ||
const refId = (0, resolve_1.makeRefId)(from, ref.$ref); | ||
const refId = makeRefId(from, ref.$ref); | ||
const resolvedRef = resolvedRefMap.get(refId); | ||
@@ -46,5 +43,5 @@ if (!resolvedRef) { | ||
const newLocation = resolved | ||
? new ref_utils_1.Location(document.source, nodePointer) | ||
: error instanceof resolve_1.YamlParseError | ||
? new ref_utils_1.Location(error.source, '') | ||
? new Location(document.source, nodePointer) | ||
: error instanceof YamlParseError | ||
? new Location(error.source, '') | ||
: undefined; | ||
@@ -57,3 +54,3 @@ return { location: newLocation, node, error }; | ||
const enteredContexts = new Set(); | ||
if ((0, ref_utils_1.isRef)(node)) { | ||
if (isRef(node)) { | ||
const refEnterVisitors = normalizedVisitors.ref.enter; | ||
@@ -124,6 +121,6 @@ for (const { visit: visitor, ruleId, severity, message, context } of refEnterVisitors) { | ||
}; | ||
context.activatedOn = (0, utils_1.pushStack)(context.activatedOn, activatedOn); | ||
context.activatedOn = pushStack(context.activatedOn, activatedOn); | ||
let ctx = context.parent; | ||
while (ctx) { | ||
ctx.activatedOn.value.nextLevelTypeActivated = (0, utils_1.pushStack)(ctx.activatedOn.value.nextLevelTypeActivated, type); | ||
ctx.activatedOn.value.nextLevelTypeActivated = pushStack(ctx.activatedOn.value.nextLevelTypeActivated, type); | ||
ctx = ctx.parent; | ||
@@ -150,3 +147,3 @@ } | ||
: itemsType; | ||
if ((0, types_1.isNamedType)(itemType)) { | ||
if (isNamedType(itemType)) { | ||
walkNode(resolvedNode[i], itemType, resolvedLocation.child([i]), resolvedNode, i); | ||
@@ -166,3 +163,3 @@ } | ||
} | ||
if ((0, ref_utils_1.isRef)(node)) { | ||
if (isRef(node)) { | ||
props.push(...Object.keys(node).filter((k) => k !== '$ref' && !props.includes(k))); // properties on the same level as $ref | ||
@@ -185,5 +182,5 @@ } | ||
propName.startsWith(type.extensionsPrefix)) { | ||
propType = types_1.SpecExtension; | ||
propType = SpecExtension; | ||
} | ||
if (!(0, types_1.isNamedType)(propType) && propType?.directResolveAs) { | ||
if (!isNamedType(propType) && propType?.directResolveAs) { | ||
propType = propType.directResolveAs; | ||
@@ -195,3 +192,3 @@ value = { $ref: value }; | ||
} | ||
if (!(0, types_1.isNamedType)(propType) || (propType.name === 'scalar' && !(0, ref_utils_1.isRef)(value))) { | ||
if (!isNamedType(propType) || (propType.name === 'scalar' && !isRef(value))) { | ||
continue; | ||
@@ -210,7 +207,7 @@ } | ||
else { | ||
context.activatedOn = (0, utils_1.popStack)(context.activatedOn); | ||
context.activatedOn = popStack(context.activatedOn); | ||
if (context.parent) { | ||
let ctx = context.parent; | ||
while (ctx) { | ||
ctx.activatedOn.value.nextLevelTypeActivated = (0, utils_1.popStack)(ctx.activatedOn.value.nextLevelTypeActivated); | ||
ctx.activatedOn.value.nextLevelTypeActivated = popStack(ctx.activatedOn.value.nextLevelTypeActivated); | ||
ctx = ctx.parent; | ||
@@ -228,3 +225,3 @@ } | ||
currentLocation = location; | ||
if ((0, ref_utils_1.isRef)(node)) { | ||
if (isRef(node)) { | ||
const refLeaveVisitors = normalizedVisitors.ref.leave; | ||
@@ -301,1 +298,2 @@ for (const { visit: visitor, ruleId, severity, context, message } of refLeaveVisitors) { | ||
} | ||
//# sourceMappingURL=walk.js.map |
{ | ||
"name": "@redocly/openapi-core", | ||
"version": "0.0.0-snapshot.1744801622", | ||
"version": "0.0.0-snapshot.1747225307", | ||
"description": "", | ||
"main": "lib/index.js", | ||
"type": "module", | ||
"types": "lib/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./lib/index.js", | ||
"require": "./lib/index.js", | ||
"types": "./lib/index.d.ts" | ||
}, | ||
"./lib/config/config": { | ||
"import": "./lib/config/index.js", | ||
"require": "./lib/config/index.js", | ||
"types": "./lib/config/index.d.ts" | ||
}, | ||
"./lib/bundle": { | ||
"import": "./lib/bundle.js", | ||
"require": "./lib/bundle.js", | ||
"types": "./lib/bundle.d.ts" | ||
} | ||
}, | ||
"engines": { | ||
"node": ">=18.17.0", | ||
"npm": ">=9.5.0" | ||
"node": ">=22.12.0 || >=20.19.0 <21.0.0", | ||
"npm": ">=10" | ||
}, | ||
@@ -20,4 +38,8 @@ "engineStrict": true, | ||
"os": false, | ||
"colorette": false, | ||
"https-proxy-agent": false | ||
"node:fs": false, | ||
"node:path": "path-browserify", | ||
"node:os": false, | ||
"node:url": false, | ||
"node:module": false, | ||
"colorette": false | ||
}, | ||
@@ -40,8 +62,7 @@ "homepage": "https://github.com/Redocly/redocly-cli", | ||
"@redocly/ajv": "^8.11.2", | ||
"@redocly/config": "^0.22.0", | ||
"@redocly/config": "^0.24.1", | ||
"colorette": "^1.2.0", | ||
"https-proxy-agent": "^7.0.5", | ||
"js-levenshtein": "^1.1.6", | ||
"js-yaml": "^4.1.0", | ||
"minimatch": "^5.0.1", | ||
"minimatch": "^10.0.1", | ||
"pluralize": "^8.0.0", | ||
@@ -53,3 +74,3 @@ "yaml-ast-parser": "0.0.43" | ||
"@types/js-yaml": "^4.0.3", | ||
"@types/minimatch": "^3.0.5", | ||
"@types/minimatch": "^5.1.2", | ||
"@types/pluralize": "^0.0.29", | ||
@@ -56,0 +77,0 @@ "json-schema-to-ts": "^3.1.0", |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 4 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
1146418
74.4%8
-11.11%638
92.17%7
-63.16%1
-66.67%Yes
NaN15205
-8.05%+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated