mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 12:47:48 +00:00
chore: update typescript to v5.5.3 (#1640)
* chore: fix the docker smoke test and update typescript to v5.5.3 * revert Dockerfile changes * run audit fix * update async3 types
This commit is contained in:
@@ -13,13 +13,13 @@ module.exports = {
|
|||||||
coverageThreshold: {
|
coverageThreshold: {
|
||||||
'packages/core/': {
|
'packages/core/': {
|
||||||
statements: 80,
|
statements: 80,
|
||||||
branches: 72,
|
branches: 71,
|
||||||
functions: 73,
|
functions: 73,
|
||||||
lines: 80,
|
lines: 80,
|
||||||
},
|
},
|
||||||
'packages/cli/': {
|
'packages/cli/': {
|
||||||
statements: 60,
|
statements: 60,
|
||||||
branches: 52,
|
branches: 50,
|
||||||
functions: 60,
|
functions: 60,
|
||||||
lines: 60,
|
lines: 60,
|
||||||
},
|
},
|
||||||
|
|||||||
46
package-lock.json
generated
46
package-lock.json
generated
@@ -30,7 +30,7 @@
|
|||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.1.1",
|
||||||
"ts-loader": "^8.0.2",
|
"ts-loader": "^8.0.2",
|
||||||
"ts-node": "^9.0.0",
|
"ts-node": "^9.0.0",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "5.5.3",
|
||||||
"webpack": "^5.76.0",
|
"webpack": "^5.76.0",
|
||||||
"webpack-cli": "^4.10.0"
|
"webpack-cli": "^4.10.0"
|
||||||
},
|
},
|
||||||
@@ -8865,9 +8865,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/jsdom/node_modules/ws": {
|
"node_modules/jsdom/node_modules/ws": {
|
||||||
"version": "8.14.2",
|
"version": "8.18.0",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
|
||||||
"integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==",
|
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=10.0.0"
|
"node": ">=10.0.0"
|
||||||
@@ -12651,9 +12651,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/typescript": {
|
"node_modules/typescript": {
|
||||||
"version": "5.2.2",
|
"version": "5.5.3",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz",
|
||||||
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
|
"integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"tsc": "bin/tsc",
|
"tsc": "bin/tsc",
|
||||||
@@ -13374,9 +13374,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ws": {
|
"node_modules/ws": {
|
||||||
"version": "7.5.9",
|
"version": "7.5.10",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
|
||||||
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
|
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.3.0"
|
"node": ">=8.3.0"
|
||||||
},
|
},
|
||||||
@@ -13527,7 +13527,7 @@
|
|||||||
"@types/react-dom": "^17.0.0 || ^18.2.7",
|
"@types/react-dom": "^17.0.0 || ^18.2.7",
|
||||||
"@types/semver": "^7.5.0",
|
"@types/semver": "^7.5.0",
|
||||||
"@types/yargs": "17.0.32",
|
"@types/yargs": "17.0.32",
|
||||||
"typescript": "^5.2.2"
|
"typescript": "5.5.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.19.0",
|
"node": ">=14.19.0",
|
||||||
@@ -13573,7 +13573,7 @@
|
|||||||
"@types/node-fetch": "^2.5.7",
|
"@types/node-fetch": "^2.5.7",
|
||||||
"@types/pluralize": "^0.0.29",
|
"@types/pluralize": "^0.0.29",
|
||||||
"json-schema-to-ts": "^3.1.0",
|
"json-schema-to-ts": "^3.1.0",
|
||||||
"typescript": "^5.2.2"
|
"typescript": "5.5.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=14.19.0",
|
"node": ">=14.19.0",
|
||||||
@@ -16238,7 +16238,7 @@
|
|||||||
"semver": "^7.5.2",
|
"semver": "^7.5.2",
|
||||||
"simple-websocket": "^9.0.0",
|
"simple-websocket": "^9.0.0",
|
||||||
"styled-components": "^6.0.7",
|
"styled-components": "^6.0.7",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "5.5.3",
|
||||||
"yargs": "17.0.1"
|
"yargs": "17.0.1"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -16280,7 +16280,7 @@
|
|||||||
"minimatch": "^5.0.1",
|
"minimatch": "^5.0.1",
|
||||||
"node-fetch": "^2.6.1",
|
"node-fetch": "^2.6.1",
|
||||||
"pluralize": "^8.0.0",
|
"pluralize": "^8.0.0",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "5.5.3",
|
||||||
"yaml-ast-parser": "0.0.43"
|
"yaml-ast-parser": "0.0.43"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -20334,9 +20334,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ws": {
|
"ws": {
|
||||||
"version": "8.14.2",
|
"version": "8.18.0",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-8.14.2.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
|
||||||
"integrity": "sha512-wEBG1ftX4jcglPxgFCMJmZ2PLtSbJ2Peg6TmpJFTbe9GZYOQCDPdMYu/Tm0/bGZkw8paZnJY45J4K2PZrLYq8g==",
|
"integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {}
|
"requires": {}
|
||||||
}
|
}
|
||||||
@@ -23101,9 +23101,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"typescript": {
|
"typescript": {
|
||||||
"version": "5.2.2",
|
"version": "5.5.3",
|
||||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz",
|
||||||
"integrity": "sha512-mI4WrpHsbCIcwT9cF4FZvr80QUeKvsUsUvKDoR+X/7XHQH98xYD8YHZg7ANtz2GtZt/CBq2QJ0thkGJMHfqc1w==",
|
"integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"uglify-js": {
|
"uglify-js": {
|
||||||
@@ -23609,9 +23609,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ws": {
|
"ws": {
|
||||||
"version": "7.5.9",
|
"version": "7.5.10",
|
||||||
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
|
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz",
|
||||||
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
|
"integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==",
|
||||||
"requires": {}
|
"requires": {}
|
||||||
},
|
},
|
||||||
"xml-name-validator": {
|
"xml-name-validator": {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
"ts-jest": "^29.1.1",
|
"ts-jest": "^29.1.1",
|
||||||
"ts-loader": "^8.0.2",
|
"ts-loader": "^8.0.2",
|
||||||
"ts-node": "^9.0.0",
|
"ts-node": "^9.0.0",
|
||||||
"typescript": "^5.2.2",
|
"typescript": "5.5.3",
|
||||||
"webpack": "^5.76.0",
|
"webpack": "^5.76.0",
|
||||||
"webpack-cli": "^4.10.0"
|
"webpack-cli": "^4.10.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,6 @@
|
|||||||
"@types/react-dom": "^17.0.0 || ^18.2.7",
|
"@types/react-dom": "^17.0.0 || ^18.2.7",
|
||||||
"@types/semver": "^7.5.0",
|
"@types/semver": "^7.5.0",
|
||||||
"@types/yargs": "17.0.32",
|
"@types/yargs": "17.0.32",
|
||||||
"typescript": "^5.2.2"
|
"typescript": "5.5.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,6 +56,6 @@
|
|||||||
"@types/node-fetch": "^2.5.7",
|
"@types/node-fetch": "^2.5.7",
|
||||||
"@types/pluralize": "^0.0.29",
|
"@types/pluralize": "^0.0.29",
|
||||||
"json-schema-to-ts": "^3.1.0",
|
"json-schema-to-ts": "^3.1.0",
|
||||||
"typescript": "^5.2.2"
|
"typescript": "5.5.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,15 +18,13 @@ import { RemoveUnusedComponents as RemoveUnusedComponentsOas2 } from './decorato
|
|||||||
import { RemoveUnusedComponents as RemoveUnusedComponentsOas3 } from './decorators/oas3/remove-unused-components';
|
import { RemoveUnusedComponents as RemoveUnusedComponentsOas3 } from './decorators/oas3/remove-unused-components';
|
||||||
import { ConfigTypes } from './types/redocly-yaml';
|
import { ConfigTypes } from './types/redocly-yaml';
|
||||||
|
|
||||||
import type { Oas3Rule, Oas3Visitor, Oas2Visitor } from './visitors';
|
import type { Oas3Visitor, Oas2Visitor } from './visitors';
|
||||||
import type { NormalizedNodeType, NodeType } from './types';
|
import type { NormalizedNodeType, NodeType } from './types';
|
||||||
import type { WalkContext, UserContext, ResolveResult, NormalizedProblem } from './walk';
|
import type { WalkContext, UserContext, ResolveResult, NormalizedProblem } from './walk';
|
||||||
import type { Config, StyleguideConfig } from './config';
|
import type { Config, StyleguideConfig } from './config';
|
||||||
import type { OasRef } from './typings/openapi';
|
import type { OasRef } from './typings/openapi';
|
||||||
import type { Document, ResolvedRefMap } from './resolve';
|
import type { Document, ResolvedRefMap } from './resolve';
|
||||||
|
|
||||||
export type Oas3RuleSet = Record<string, Oas3Rule>;
|
|
||||||
|
|
||||||
export enum OasVersion {
|
export enum OasVersion {
|
||||||
Version2 = 'oas2',
|
Version2 = 'oas2',
|
||||||
Version3_0 = 'oas3_0',
|
Version3_0 = 'oas3_0',
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
import { RuleSet, SpecVersion } from '../oas-types';
|
|
||||||
import { StyleguideConfig } from './config';
|
|
||||||
import { isDefined } from '../utils';
|
import { isDefined } from '../utils';
|
||||||
|
|
||||||
|
import type {
|
||||||
|
ArazzoRuleSet,
|
||||||
|
Async2RuleSet,
|
||||||
|
Async3RuleSet,
|
||||||
|
Oas2RuleSet,
|
||||||
|
Oas3RuleSet,
|
||||||
|
SpecVersion,
|
||||||
|
} from '../oas-types';
|
||||||
|
import type { StyleguideConfig } from './config';
|
||||||
import type { ProblemSeverity } from '../walk';
|
import type { ProblemSeverity } from '../walk';
|
||||||
|
|
||||||
type InitializedRule = {
|
type InitializedRule = {
|
||||||
@@ -9,8 +17,8 @@ type InitializedRule = {
|
|||||||
visitor: any;
|
visitor: any;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function initRules<T extends Function, P extends RuleSet<T>>(
|
export function initRules(
|
||||||
rules: P[],
|
rules: (Oas3RuleSet | Oas2RuleSet | Async2RuleSet | Async3RuleSet | ArazzoRuleSet)[],
|
||||||
config: StyleguideConfig,
|
config: StyleguideConfig,
|
||||||
type: 'rules' | 'preprocessors' | 'decorators',
|
type: 'rules' | 'preprocessors' | 'decorators',
|
||||||
oasVersion: SpecVersion
|
oasVersion: SpecVersion
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { isRef } from '../../ref-utils';
|
|||||||
const DEFAULT_INTERNAL_PROPERTY_NAME = 'x-internal';
|
const DEFAULT_INTERNAL_PROPERTY_NAME = 'x-internal';
|
||||||
|
|
||||||
export const RemoveXInternal: Oas3Decorator | Oas2Decorator = ({ internalFlagProperty }) => {
|
export const RemoveXInternal: Oas3Decorator | Oas2Decorator = ({ internalFlagProperty }) => {
|
||||||
const hiddenTag = internalFlagProperty || DEFAULT_INTERNAL_PROPERTY_NAME;
|
const hiddenTag: string = internalFlagProperty || DEFAULT_INTERNAL_PROPERTY_NAME;
|
||||||
|
|
||||||
function removeInternal(node: any, ctx: UserContext) {
|
function removeInternal(node: any, ctx: UserContext) {
|
||||||
const { parent, key } = ctx;
|
const { parent, key } = ctx;
|
||||||
@@ -31,7 +31,7 @@ export const RemoveXInternal: Oas3Decorator | Oas2Decorator = ({ internalFlagPro
|
|||||||
for (const key of Object.keys(node)) {
|
for (const key of Object.keys(node)) {
|
||||||
node = node as any;
|
node = node as any;
|
||||||
if (isRef(node[key])) {
|
if (isRef(node[key])) {
|
||||||
const resolved = ctx.resolve(node[key]);
|
const resolved = ctx.resolve<any>(node[key]);
|
||||||
if (resolved.node?.[hiddenTag]) {
|
if (resolved.node?.[hiddenTag]) {
|
||||||
delete node[key];
|
delete node[key];
|
||||||
didDelete = true;
|
didDelete = true;
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import { rootRedoclyConfigSchema } from '@redocly/config';
|
||||||
import { BaseResolver, resolveDocument, makeDocumentFromString } from './resolve';
|
import { BaseResolver, resolveDocument, makeDocumentFromString } from './resolve';
|
||||||
import { normalizeVisitors } from './visitors';
|
import { normalizeVisitors } from './visitors';
|
||||||
import { walkDocument } from './walk';
|
import { walkDocument } from './walk';
|
||||||
@@ -12,8 +13,15 @@ import { NoUnresolvedRefs } from './rules/no-unresolved-refs';
|
|||||||
import type { Document, ResolvedRefMap } from './resolve';
|
import type { Document, ResolvedRefMap } from './resolve';
|
||||||
import type { ProblemSeverity, WalkContext } from './walk';
|
import type { ProblemSeverity, WalkContext } from './walk';
|
||||||
import type { NodeType } from './types';
|
import type { NodeType } from './types';
|
||||||
import type { NestedVisitObject, Oas3Visitor, RuleInstanceConfig } from './visitors';
|
import type {
|
||||||
import { rootRedoclyConfigSchema } from '@redocly/config';
|
ArazzoVisitor,
|
||||||
|
Async2Visitor,
|
||||||
|
Async3Visitor,
|
||||||
|
NestedVisitObject,
|
||||||
|
Oas2Visitor,
|
||||||
|
Oas3Visitor,
|
||||||
|
RuleInstanceConfig,
|
||||||
|
} from './visitors';
|
||||||
|
|
||||||
export async function lint(opts: {
|
export async function lint(opts: {
|
||||||
ref: string;
|
ref: string;
|
||||||
@@ -130,7 +138,19 @@ export async function lintConfig(opts: {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const rules: (RuleInstanceConfig & {
|
const rules: (RuleInstanceConfig & {
|
||||||
visitor: NestedVisitObject<unknown, Oas3Visitor | Oas3Visitor[]>;
|
visitor: NestedVisitObject<
|
||||||
|
unknown,
|
||||||
|
| Oas3Visitor
|
||||||
|
| Oas3Visitor[]
|
||||||
|
| Oas2Visitor
|
||||||
|
| Oas2Visitor[]
|
||||||
|
| Async2Visitor
|
||||||
|
| Async2Visitor[]
|
||||||
|
| Async3Visitor
|
||||||
|
| Async3Visitor[]
|
||||||
|
| ArazzoVisitor
|
||||||
|
| ArazzoVisitor[]
|
||||||
|
>;
|
||||||
})[] = [
|
})[] = [
|
||||||
{
|
{
|
||||||
severity: severity || 'error',
|
severity: severity || 'error',
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ import {
|
|||||||
BuiltInOAS3RuleId,
|
BuiltInOAS3RuleId,
|
||||||
} from './types/redocly-yaml';
|
} from './types/redocly-yaml';
|
||||||
|
|
||||||
export type RuleSet<T> = Record<string, T>;
|
|
||||||
|
|
||||||
export enum SpecVersion {
|
export enum SpecVersion {
|
||||||
OAS2 = 'oas2',
|
OAS2 = 'oas2',
|
||||||
OAS3_0 = 'oas3_0',
|
OAS3_0 = 'oas3_0',
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { Assertions } from '../common/assertions';
|
|||||||
|
|
||||||
export const rules: ArazzoRuleSet<'built-in'> = {
|
export const rules: ArazzoRuleSet<'built-in'> = {
|
||||||
spec: Spec as ArazzoRule,
|
spec: Spec as ArazzoRule,
|
||||||
assertions: Assertions,
|
assertions: Assertions as ArazzoRule,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const preprocessors = {};
|
export const preprocessors = {};
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import type { Async2RuleSet } from '../../oas-types';
|
|||||||
|
|
||||||
export const rules: Async2RuleSet<'built-in'> = {
|
export const rules: Async2RuleSet<'built-in'> = {
|
||||||
spec: Spec as Async2Rule,
|
spec: Spec as Async2Rule,
|
||||||
assertions: Assertions,
|
assertions: Assertions as Async2Rule,
|
||||||
'info-contact': InfoContact,
|
'info-contact': InfoContact as Async2Rule,
|
||||||
'operation-operationId': OperationOperationId,
|
'operation-operationId': OperationOperationId as Async2Rule,
|
||||||
'channels-kebab-case': ChannelsKebabCase,
|
'channels-kebab-case': ChannelsKebabCase,
|
||||||
'no-channel-trailing-slash': NoChannelTrailingSlash,
|
'no-channel-trailing-slash': NoChannelTrailingSlash,
|
||||||
'tag-description': TagDescription,
|
'tag-description': TagDescription as Async2Rule,
|
||||||
'tags-alphabetical': TagsAlphabetical,
|
'tags-alphabetical': TagsAlphabetical as Async2Rule,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const preprocessors = {};
|
export const preprocessors = {};
|
||||||
|
|||||||
@@ -11,13 +11,13 @@ import type { Async3RuleSet } from '../../oas-types';
|
|||||||
|
|
||||||
export const rules: Async3RuleSet<'built-in'> = {
|
export const rules: Async3RuleSet<'built-in'> = {
|
||||||
spec: Spec as Async3Rule,
|
spec: Spec as Async3Rule,
|
||||||
assertions: Assertions,
|
assertions: Assertions as Async3Rule,
|
||||||
'info-contact': InfoContact,
|
'info-contact': InfoContact as Async3Rule,
|
||||||
'operation-operationId': OperationOperationId,
|
'operation-operationId': OperationOperationId as Async3Rule,
|
||||||
'channels-kebab-case': ChannelsKebabCase,
|
'channels-kebab-case': ChannelsKebabCase,
|
||||||
'no-channel-trailing-slash': NoChannelTrailingSlash,
|
'no-channel-trailing-slash': NoChannelTrailingSlash,
|
||||||
'tag-description': TagDescription,
|
'tag-description': TagDescription as Async3Rule,
|
||||||
'tags-alphabetical': TagsAlphabetical,
|
'tags-alphabetical': TagsAlphabetical as Async3Rule,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const preprocessors = {};
|
export const preprocessors = {};
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
import { asserts, AssertionFn } from './asserts';
|
import { asserts } from './asserts';
|
||||||
import { buildSubjectVisitor, buildVisitorObject } from './utils';
|
import { buildSubjectVisitor, buildVisitorObject } from './utils';
|
||||||
import { Async2Visitor, Async3Visitor, Oas2Visitor, Oas3Visitor } from '../../../visitors';
|
|
||||||
import { RuleSeverity } from '../../../config';
|
|
||||||
import { isString } from '../../../utils';
|
import { isString } from '../../../utils';
|
||||||
|
|
||||||
|
import type { AssertionFn } from './asserts';
|
||||||
|
import type {
|
||||||
|
ArazzoVisitor,
|
||||||
|
Async2Visitor,
|
||||||
|
Async3Visitor,
|
||||||
|
Oas2Visitor,
|
||||||
|
Oas3Visitor,
|
||||||
|
} from '../../../visitors';
|
||||||
|
import type { RuleSeverity } from '../../../config';
|
||||||
|
|
||||||
export type AssertionLocators = {
|
export type AssertionLocators = {
|
||||||
filterInParentKeys?: (string | number)[];
|
filterInParentKeys?: (string | number)[];
|
||||||
filterOutParentKeys?: (string | number)[];
|
filterOutParentKeys?: (string | number)[];
|
||||||
@@ -28,7 +36,8 @@ export type RawAssertion = AssertionDefinition & {
|
|||||||
export type Assertion = RawAssertion & { assertionId: string };
|
export type Assertion = RawAssertion & { assertionId: string };
|
||||||
|
|
||||||
export const Assertions = (opts: Record<string, Assertion>) => {
|
export const Assertions = (opts: Record<string, Assertion>) => {
|
||||||
const visitors: (Oas2Visitor | Oas3Visitor | Async2Visitor | Async3Visitor)[] = [];
|
const visitors: (Oas2Visitor | Oas3Visitor | Async2Visitor | Async3Visitor | ArazzoVisitor)[] =
|
||||||
|
[];
|
||||||
|
|
||||||
// As 'Assertions' has an array of asserts,
|
// As 'Assertions' has an array of asserts,
|
||||||
// that array spreads into an 'opts' object on init rules phase here
|
// that array spreads into an 'opts' object on init rules phase here
|
||||||
|
|||||||
@@ -86,10 +86,10 @@ export const rules: Oas2RuleSet<'built-in'> = {
|
|||||||
'path-segment-plural': PathSegmentPlural as Oas2Rule,
|
'path-segment-plural': PathSegmentPlural as Oas2Rule,
|
||||||
'response-contains-header': ResponseContainsHeader as Oas2Rule,
|
'response-contains-header': ResponseContainsHeader as Oas2Rule,
|
||||||
'response-contains-property': ResponseContainsProperty as Oas2Rule,
|
'response-contains-property': ResponseContainsProperty as Oas2Rule,
|
||||||
'scalar-property-missing-example': ScalarPropertyMissingExample,
|
'scalar-property-missing-example': ScalarPropertyMissingExample as Oas2Rule,
|
||||||
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength,
|
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength as Oas2Rule,
|
||||||
'spec-strict-refs': SpecStrictRefs,
|
'spec-strict-refs': SpecStrictRefs as Oas2Rule,
|
||||||
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined,
|
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined as Oas2Rule,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const preprocessors = {};
|
export const preprocessors = {};
|
||||||
|
|||||||
@@ -55,63 +55,65 @@ import { ComponentNameUnique } from './component-name-unique';
|
|||||||
import { ArrayParameterSerialization } from './array-parameter-serialization';
|
import { ArrayParameterSerialization } from './array-parameter-serialization';
|
||||||
import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined';
|
import { NoRequiredSchemaPropertiesUndefined } from '../common/no-required-schema-properties-undefined';
|
||||||
|
|
||||||
|
import type { Oas3Rule } from '../../visitors';
|
||||||
|
|
||||||
export const rules: Oas3RuleSet<'built-in'> = {
|
export const rules: Oas3RuleSet<'built-in'> = {
|
||||||
spec: Spec,
|
spec: Spec as Oas3Rule,
|
||||||
'info-contact': InfoContact,
|
'info-contact': InfoContact as Oas3Rule,
|
||||||
'info-license': InfoLicense,
|
'info-license': InfoLicense as Oas3Rule,
|
||||||
'info-license-url': InfoLicenseUrl,
|
'info-license-url': InfoLicenseUrl as Oas3Rule,
|
||||||
'operation-2xx-response': Operation2xxResponse,
|
'operation-2xx-response': Operation2xxResponse as Oas3Rule,
|
||||||
'operation-4xx-response': Operation4xxResponse,
|
'operation-4xx-response': Operation4xxResponse as Oas3Rule,
|
||||||
'operation-4xx-problem-details-rfc7807': Operation4xxProblemDetailsRfc7807,
|
'operation-4xx-problem-details-rfc7807': Operation4xxProblemDetailsRfc7807,
|
||||||
assertions: Assertions,
|
assertions: Assertions as Oas3Rule,
|
||||||
'operation-operationId-unique': OperationIdUnique,
|
'operation-operationId-unique': OperationIdUnique as Oas3Rule,
|
||||||
'operation-parameters-unique': OperationParametersUnique,
|
'operation-parameters-unique': OperationParametersUnique as Oas3Rule,
|
||||||
'operation-tag-defined': OperationTagDefined,
|
'operation-tag-defined': OperationTagDefined as Oas3Rule,
|
||||||
'no-example-value-and-externalValue': NoExampleValueAndExternalValue,
|
'no-example-value-and-externalValue': NoExampleValueAndExternalValue,
|
||||||
'no-enum-type-mismatch': NoEnumTypeMismatch,
|
'no-enum-type-mismatch': NoEnumTypeMismatch as Oas3Rule,
|
||||||
'no-path-trailing-slash': NoPathTrailingSlash,
|
'no-path-trailing-slash': NoPathTrailingSlash as Oas3Rule,
|
||||||
'no-empty-servers': NoEmptyServers,
|
'no-empty-servers': NoEmptyServers,
|
||||||
'path-declaration-must-exist': PathDeclarationMustExist,
|
'path-declaration-must-exist': PathDeclarationMustExist as Oas3Rule,
|
||||||
'operation-operationId-url-safe': OperationIdUrlSafe,
|
'operation-operationId-url-safe': OperationIdUrlSafe as Oas3Rule,
|
||||||
'operation-operationId': OperationOperationId,
|
'operation-operationId': OperationOperationId as Oas3Rule,
|
||||||
'operation-summary': OperationSummary,
|
'operation-summary': OperationSummary as Oas3Rule,
|
||||||
'tags-alphabetical': TagsAlphabetical,
|
'tags-alphabetical': TagsAlphabetical as Oas3Rule,
|
||||||
'no-server-example.com': NoServerExample,
|
'no-server-example.com': NoServerExample,
|
||||||
'no-server-trailing-slash': NoServerTrailingSlash,
|
'no-server-trailing-slash': NoServerTrailingSlash,
|
||||||
'tag-description': TagDescription,
|
'tag-description': TagDescription as Oas3Rule,
|
||||||
'operation-description': OperationDescription,
|
'operation-description': OperationDescription as Oas3Rule,
|
||||||
'no-unused-components': NoUnusedComponents,
|
'no-unused-components': NoUnusedComponents,
|
||||||
'path-not-include-query': PathNotIncludeQuery,
|
'path-not-include-query': PathNotIncludeQuery as Oas3Rule,
|
||||||
'path-parameters-defined': PathParamsDefined,
|
'path-parameters-defined': PathParamsDefined as Oas3Rule,
|
||||||
'path-params-defined': PathParamsDefined,
|
'path-params-defined': PathParamsDefined as Oas3Rule,
|
||||||
'parameter-description': ParameterDescription,
|
'parameter-description': ParameterDescription as Oas3Rule,
|
||||||
'operation-singular-tag': OperationSingularTag,
|
'operation-singular-tag': OperationSingularTag as Oas3Rule,
|
||||||
'security-defined': SecurityDefined,
|
'security-defined': SecurityDefined as Oas3Rule,
|
||||||
'no-unresolved-refs': NoUnresolvedRefs,
|
'no-unresolved-refs': NoUnresolvedRefs,
|
||||||
'paths-kebab-case': PathsKebabCase,
|
'paths-kebab-case': PathsKebabCase as Oas3Rule,
|
||||||
'boolean-parameter-prefixes': BooleanParameterPrefixes,
|
'boolean-parameter-prefixes': BooleanParameterPrefixes,
|
||||||
'path-http-verbs-order': PathHttpVerbsOrder,
|
'path-http-verbs-order': PathHttpVerbsOrder as Oas3Rule,
|
||||||
'no-invalid-media-type-examples': ValidContentExamples,
|
'no-invalid-media-type-examples': ValidContentExamples,
|
||||||
'no-identical-paths': NoIdenticalPaths,
|
'no-identical-paths': NoIdenticalPaths as Oas3Rule,
|
||||||
'no-ambiguous-paths': NoAmbiguousPaths,
|
'no-ambiguous-paths': NoAmbiguousPaths as Oas3Rule,
|
||||||
'no-undefined-server-variable': NoUndefinedServerVariable,
|
'no-undefined-server-variable': NoUndefinedServerVariable,
|
||||||
'no-server-variables-empty-enum': NoServerVariablesEmptyEnum,
|
'no-server-variables-empty-enum': NoServerVariablesEmptyEnum,
|
||||||
'no-http-verbs-in-paths': NoHttpVerbsInPaths,
|
'no-http-verbs-in-paths': NoHttpVerbsInPaths as Oas3Rule,
|
||||||
'path-excludes-patterns': PathExcludesPatterns,
|
'path-excludes-patterns': PathExcludesPatterns as Oas3Rule,
|
||||||
'request-mime-type': RequestMimeType,
|
'request-mime-type': RequestMimeType,
|
||||||
'response-mime-type': ResponseMimeType,
|
'response-mime-type': ResponseMimeType,
|
||||||
'path-segment-plural': PathSegmentPlural,
|
'path-segment-plural': PathSegmentPlural as Oas3Rule,
|
||||||
'no-invalid-schema-examples': NoInvalidSchemaExamples,
|
'no-invalid-schema-examples': NoInvalidSchemaExamples,
|
||||||
'no-invalid-parameter-examples': NoInvalidParameterExamples,
|
'no-invalid-parameter-examples': NoInvalidParameterExamples,
|
||||||
'response-contains-header': ResponseContainsHeader,
|
'response-contains-header': ResponseContainsHeader as Oas3Rule,
|
||||||
'response-contains-property': ResponseContainsProperty,
|
'response-contains-property': ResponseContainsProperty,
|
||||||
'scalar-property-missing-example': ScalarPropertyMissingExample,
|
'scalar-property-missing-example': ScalarPropertyMissingExample as Oas3Rule,
|
||||||
'spec-components-invalid-map-name': SpecComponentsInvalidMapName,
|
'spec-components-invalid-map-name': SpecComponentsInvalidMapName,
|
||||||
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength,
|
'required-string-property-missing-min-length': RequiredStringPropertyMissingMinLength,
|
||||||
'spec-strict-refs': SpecStrictRefs,
|
'spec-strict-refs': SpecStrictRefs as Oas3Rule,
|
||||||
'component-name-unique': ComponentNameUnique,
|
'component-name-unique': ComponentNameUnique as Oas3Rule,
|
||||||
'array-parameter-serialization': ArrayParameterSerialization,
|
'array-parameter-serialization': ArrayParameterSerialization,
|
||||||
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined,
|
'no-required-schema-properties-undefined': NoRequiredSchemaPropertiesUndefined as Oas3Rule,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const preprocessors = {};
|
export const preprocessors = {};
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"composite": true,
|
"composite": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"target": "ES2016",
|
"target": "ES2020",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
"noImplicitThis": true,
|
"noImplicitThis": true,
|
||||||
|
|||||||
Reference in New Issue
Block a user