@redocly/openapi-core
Advanced tools
Comparing version 1.0.0-beta.37 to 1.0.0-beta.38
@@ -11,2 +11,5 @@ "use strict"; | ||
all: all_1.default, | ||
'redocly-registry': { | ||
decorators: { 'registry-dependencies': 'on' } | ||
} | ||
}; |
import { NormalizedProblem } from '../walk'; | ||
declare type Totals = { | ||
export declare type Totals = { | ||
errors: number; | ||
@@ -8,2 +8,5 @@ warnings: number; | ||
export declare type OutputFormat = 'codeframe' | 'stylish' | 'json'; | ||
export declare function getTotals(problems: (NormalizedProblem & { | ||
ignored?: boolean; | ||
})[]): Totals; | ||
export declare function formatProblems(problems: (NormalizedProblem & { | ||
@@ -19,2 +22,1 @@ ignored?: boolean; | ||
}): void; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.formatProblems = void 0; | ||
exports.formatProblems = exports.getTotals = void 0; | ||
const path = require("path"); | ||
const colorette_1 = require("colorette"); | ||
const coreVersion = require('../../package.json').version; | ||
const codeframes_1 = require("./codeframes"); | ||
@@ -26,4 +27,25 @@ const ERROR_MESSAGE = { | ||
} | ||
function getTotals(problems) { | ||
let errors = 0; | ||
let warnings = 0; | ||
let ignored = 0; | ||
for (const m of problems) { | ||
if (m.ignored) { | ||
ignored++; | ||
continue; | ||
} | ||
if (m.severity === 'error') | ||
errors++; | ||
if (m.severity === 'warn') | ||
warnings++; | ||
} | ||
return { | ||
errors, | ||
warnings, | ||
ignored, | ||
}; | ||
} | ||
exports.getTotals = getTotals; | ||
function formatProblems(problems, opts) { | ||
const { maxProblems = 100, cwd = process.cwd(), format = 'codeframe', color = colorette_1.options.enabled, totals, version } = opts; | ||
const { maxProblems = 100, cwd = process.cwd(), format = 'codeframe', color = colorette_1.options.enabled, totals = getTotals(problems), version = coreVersion, } = opts; | ||
colorette_1.options.enabled = color; // force colors if specified | ||
@@ -30,0 +52,0 @@ const totalProblems = problems.length; |
@@ -16,4 +16,4 @@ export type { BundleOutputFormat } from './utils'; | ||
export { WalkContext, walkDocument, NormalizedProblem, ProblemSeverity, LineColLocationObject, LocationObject, Loc } from './walk'; | ||
export { formatProblems, OutputFormat } from './format/format'; | ||
export { formatProblems, OutputFormat, getTotals, Totals } from './format/format'; | ||
export { OasVersion, lint, lint as validate, lintDocument } from './lint'; | ||
export { bundle } from './bundle'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bundle = exports.lintDocument = exports.validate = exports.lint = exports.OasVersion = exports.formatProblems = exports.walkDocument = exports.normalizeVisitors = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.unescapePointer = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.RedoclyClient = exports.IGNORE_FILE = exports.LintConfig = exports.Config = exports.loadConfig = exports.Stats = exports.normalizeTypes = exports.Oas2Types = exports.Oas3Types = void 0; | ||
exports.bundle = exports.lintDocument = exports.validate = exports.lint = exports.OasVersion = exports.getTotals = exports.formatProblems = exports.walkDocument = exports.normalizeVisitors = exports.openAPIMajor = exports.OasMajorVersion = exports.detectOpenAPI = exports.unescapePointer = exports.YamlParseError = exports.ResolveError = exports.resolveDocument = exports.BaseResolver = exports.Source = exports.RedoclyClient = exports.IGNORE_FILE = exports.LintConfig = exports.Config = exports.loadConfig = exports.Stats = exports.normalizeTypes = exports.Oas2Types = exports.Oas3Types = void 0; | ||
var oas3_1 = require("./types/oas3"); | ||
@@ -37,2 +37,3 @@ Object.defineProperty(exports, "Oas3Types", { enumerable: true, get: function () { return oas3_1.Oas3Types; } }); | ||
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_2 = require("./lint"); | ||
@@ -39,0 +40,0 @@ Object.defineProperty(exports, "OasVersion", { enumerable: true, get: function () { return lint_2.OasVersion; } }); |
@@ -8,4 +8,8 @@ import { CustomRulesConfig } from '../config/config'; | ||
export declare const decorators: { | ||
oas3: {}; | ||
oas2: {}; | ||
oas3: { | ||
'registry-dependencies': import("../visitors").Oas3Decorator; | ||
}; | ||
oas2: { | ||
'registry-dependencies': import("../visitors").Oas2Decorator; | ||
}; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
export declare const RegistryDependencies: Oas3Rule | Oas2Rule; | ||
import { Oas3Decorator, Oas2Decorator } from '../../visitors'; | ||
export declare const RegistryDependencies: Oas3Decorator | Oas2Decorator; |
@@ -1,2 +0,2 @@ | ||
import { Oas2Rule } from '../../visitors'; | ||
import { Oas2Decorator, Oas2Rule } from '../../visitors'; | ||
export declare const rules: { | ||
@@ -32,6 +32,7 @@ 'info-description': Oas2Rule; | ||
'path-http-verbs-order': Oas2Rule; | ||
'registry-dependencies': Oas2Rule; | ||
spec: Oas2Rule; | ||
}; | ||
export declare const preprocessors: {}; | ||
export declare const decorators: {}; | ||
export declare const decorators: { | ||
'registry-dependencies': Oas2Decorator; | ||
}; |
@@ -64,6 +64,7 @@ "use strict"; | ||
'path-http-verbs-order': path_http_verbs_order_1.PathHttpVerbsOrder, | ||
'registry-dependencies': registry_dependencies_1.RegistryDependencies, | ||
spec: spec_1.OasSpec, | ||
}; | ||
exports.preprocessors = {}; | ||
exports.decorators = {}; | ||
exports.decorators = { | ||
'registry-dependencies': registry_dependencies_1.RegistryDependencies, | ||
}; |
@@ -0,3 +1,6 @@ | ||
import { Oas3Decorator } from '../../visitors'; | ||
export declare const rules: Record<string, import("../../visitors").Oas3Rule>; | ||
export declare const preprocessors: {}; | ||
export declare const decorators: {}; | ||
export declare const decorators: { | ||
'registry-dependencies': Oas3Decorator; | ||
}; |
@@ -75,3 +75,2 @@ "use strict"; | ||
'no-invalid-media-type-examples': no_invalid_media_type_examples_1.ValidContentExamples, | ||
'registry-dependencies': registry_dependencies_1.RegistryDependencies, | ||
'no-identical-paths': no_identical_paths_1.NoIdenticalPaths, | ||
@@ -83,2 +82,4 @@ 'no-ambiguous-paths': no_ambiguous_paths_1.NoAmbiguousPaths, | ||
exports.preprocessors = {}; | ||
exports.decorators = {}; | ||
exports.decorators = { | ||
'registry-dependencies': registry_dependencies_1.RegistryDependencies, | ||
}; |
{ | ||
"name": "@redocly/openapi-core", | ||
"version": "1.0.0-beta.37", | ||
"version": "1.0.0-beta.38", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -10,2 +10,5 @@ import recommended from './recommended'; | ||
all, | ||
'redocly-registry': { | ||
decorators: { 'registry-dependencies': 'on' } | ||
} | ||
}; |
@@ -13,6 +13,8 @@ import * as path from 'path'; | ||
const coreVersion = require('../../package.json').version; | ||
import { NormalizedProblem, ProblemSeverity, LineColLocationObject, LocationObject } from '../walk'; | ||
import { getCodeframe, getLineColLocation } from './codeframes'; | ||
type Totals = { | ||
export type Totals = { | ||
errors: number; | ||
@@ -23,3 +25,2 @@ warnings: number; | ||
const ERROR_MESSAGE = { | ||
@@ -52,2 +53,23 @@ INVALID_SEVERITY_LEVEL: 'Invalid severity level; accepted values: error or warn', | ||
export function getTotals(problems: (NormalizedProblem & { ignored?: boolean })[]): Totals { | ||
let errors = 0; | ||
let warnings = 0; | ||
let ignored = 0; | ||
for (const m of problems) { | ||
if (m.ignored) { | ||
ignored++; | ||
continue; | ||
} | ||
if (m.severity === 'error') errors++; | ||
if (m.severity === 'warn') warnings++; | ||
} | ||
return { | ||
errors, | ||
warnings, | ||
ignored, | ||
}; | ||
} | ||
export function formatProblems( | ||
@@ -60,3 +82,3 @@ problems: (NormalizedProblem & { ignored?: boolean })[], | ||
color?: boolean; | ||
totals: Totals; | ||
totals: Totals | ||
version: string; | ||
@@ -70,4 +92,4 @@ }, | ||
color = colorOptions.enabled, | ||
totals, | ||
version | ||
totals = getTotals(problems), | ||
version = coreVersion, | ||
} = opts; | ||
@@ -74,0 +96,0 @@ |
@@ -18,4 +18,4 @@ export type { BundleOutputFormat } from './utils'; | ||
export { formatProblems, OutputFormat } from './format/format'; | ||
export { formatProblems, OutputFormat, getTotals, Totals } from './format/format'; | ||
export { OasVersion, lint, lint as validate, lintDocument } from './lint'; | ||
export { bundle } from './bundle'; |
import { RedoclyClient } from '../../redocly'; | ||
import { Oas3Rule, Oas2Rule } from '../../visitors'; | ||
import { Oas3Decorator, Oas2Decorator } from '../../visitors'; | ||
export const RegistryDependencies: Oas3Rule | Oas2Rule = () => { | ||
export const RegistryDependencies: Oas3Decorator | Oas2Decorator = () => { | ||
let redoclyClient: RedoclyClient; | ||
@@ -7,0 +7,0 @@ let registryDependencies = new Set<string>(); |
@@ -27,3 +27,3 @@ import { OasSpec } from '../common/spec'; | ||
import { PathHttpVerbsOrder } from '../common/path-http-verbs-order'; | ||
import { Oas2Rule } from '../../visitors'; | ||
import { Oas2Decorator, Oas2Rule } from '../../visitors'; | ||
import { RegistryDependencies } from '../common/registry-dependencies'; | ||
@@ -73,3 +73,2 @@ import { NoIdenticalPaths } from '../common/no-identical-paths'; | ||
'registry-dependencies': RegistryDependencies as Oas2Rule, | ||
spec: OasSpec as Oas2Rule, | ||
@@ -79,2 +78,4 @@ }; | ||
export const preprocessors = {}; | ||
export const decorators = {}; | ||
export const decorators = { | ||
'registry-dependencies': RegistryDependencies as Oas2Decorator, | ||
}; |
@@ -41,2 +41,4 @@ import { Oas3RuleSet } from '../../lint'; | ||
import { Oas3Decorator } from '../../visitors'; | ||
export const rules = { | ||
@@ -76,3 +78,2 @@ 'info-description': InfoDescription, | ||
'no-invalid-media-type-examples': ValidContentExamples, | ||
'registry-dependencies': RegistryDependencies, | ||
'no-identical-paths': NoIdenticalPaths, | ||
@@ -86,2 +87,4 @@ 'no-ambiguous-paths': NoAmbiguousPaths, | ||
export const decorators = {}; | ||
export const decorators = { | ||
'registry-dependencies': RegistryDependencies as Oas3Decorator, | ||
}; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1879510
19950