Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

exegesis

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exegesis - npm Package Compare versions

Comparing version 2.5.5 to 2.5.6

2

lib/controllers/invoke.js

@@ -9,3 +9,3 @@ "use strict";

function invokeController(controllerModule, controller, context) {
return promise_breaker_1.default.apply(controller, controllerModule, [context]).then(result => {
return promise_breaker_1.default.apply(controller, controllerModule, [context]).then((result) => {
if (!context.res.ended) {

@@ -12,0 +12,0 @@ if (result === undefined || result === null) {

@@ -27,8 +27,8 @@ "use strict";

constructor(apiDoc, plugins) {
this._plugins = plugins.map(plugin => plugin.makeExegesisPlugin({ apiDoc }));
this._preRoutingPlugins = this._plugins.filter(p => !!p.preRouting);
this._postRoutingPlugins = this._plugins.filter(p => !!p.postRouting);
this._postSecurityPlugins = this._plugins.filter(p => !!p.postSecurity);
this._postControllerPlugins = this._plugins.filter(p => !!p.postController);
this._postResponseValidation = this._plugins.filter(p => !!p.postResponseValidation);
this._plugins = plugins.map((plugin) => plugin.makeExegesisPlugin({ apiDoc }));
this._preRoutingPlugins = this._plugins.filter((p) => !!p.preRouting);
this._postRoutingPlugins = this._plugins.filter((p) => !!p.postRouting);
this._postSecurityPlugins = this._plugins.filter((p) => !!p.postSecurity);
this._postControllerPlugins = this._plugins.filter((p) => !!p.postController);
this._postResponseValidation = this._plugins.filter((p) => !!p.postResponseValidation);
}

@@ -35,0 +35,0 @@ preCompile(data) {

@@ -20,3 +20,3 @@ "use strict";

const pump_1 = __importDefault(require("pump"));
const json_schema_ref_parser_1 = __importDefault(require("json-schema-ref-parser"));
const json_schema_ref_parser_1 = __importDefault(require("@apidevtools/json-schema-ref-parser"));
const options_1 = require("./options");

@@ -74,3 +74,3 @@ const oas3_1 = require("./oas3");

return promise_breaker_1.default.addCallback(done, () => __awaiter(this, void 0, void 0, function* () {
Object.keys(httpResult.headers).forEach(header => res.setHeader(header, httpResult.headers[header]));
Object.keys(httpResult.headers).forEach((header) => res.setHeader(header, httpResult.headers[header]));
res.statusCode = httpResult.status;

@@ -91,3 +91,3 @@ if (httpResult.body) {

runner(req, res)
.then(result => {
.then((result) => {
let answer;

@@ -112,3 +112,3 @@ if (!result) {

})
.catch(err => {
.catch((err) => {
if (next) {

@@ -115,0 +115,0 @@ next(err);

@@ -7,2 +7,3 @@ import * as oas3 from 'openapi3-ts';

export declare type JsonPath = string[];
export declare type ReadOnlyJsonPath = readonly string[];
/**

@@ -25,6 +26,6 @@ * This has common stuff that we want to pass all the way down through the OAS

*/
constructor(openApiDoc: oas3.OpenAPIObject, path: JsonPath, options: ExegesisCompiledOptions);
constructor(parent: Oas3CompileContext, relativePath: JsonPath);
constructor(openApiDoc: oas3.OpenAPIObject, path: ReadOnlyJsonPath, options: ExegesisCompiledOptions);
constructor(parent: Oas3CompileContext, relativePath: ReadOnlyJsonPath);
childContext(relativePath: JsonPath | string): Oas3CompileContext;
resolveRef(ref: string | any): any;
}

@@ -28,3 +28,3 @@ "use strict";

else if (options) {
this.path = path;
this.path = path.slice();
this.openApiDoc = a;

@@ -31,0 +31,0 @@ this.options = options;

@@ -94,3 +94,3 @@ "use strict";

};
const validateParameters = parameterValues => operation.validateParameters(parameterValues);
const validateParameters = (parameterValues) => operation.validateParameters(parameterValues);
const bodyParser = mediaType && mediaType.parser;

@@ -97,0 +97,0 @@ const validateBody = mediaType && mediaType.validator;

@@ -34,3 +34,3 @@ "use strict";

else {
return required.filter(r => !have.includes(r));
return required.filter((r) => !have.includes(r));
}

@@ -307,3 +307,3 @@ }

else {
const authSchemes = this.securityRequirements.map(requirement => {
const authSchemes = this.securityRequirements.map((requirement) => {
const schemes = Object.keys(requirement);

@@ -316,3 +316,3 @@ return schemes.length === 1 ? schemes[0] : `(${schemes.join(' + ')})`;

.map((schemeName) => challenges[schemeName] || this._securitySchemes.getChallenge(schemeName))
.filter(challenge => challenge !== undefined)
.filter((challenge) => challenge !== undefined)
.value();

@@ -319,0 +319,0 @@ const message = (firstFailureResult && firstFailureResult.message) ||

@@ -52,3 +52,3 @@ "use strict";

this.oaParameter = resOaParameter;
this.validate = value => ({ errors: null, value });
this.validate = (value) => ({ errors: null, value });
// Find the schema for this parameter.

@@ -55,0 +55,0 @@ if (resOaParameter.schema) {

@@ -25,3 +25,3 @@ "use strict";

function removeSimpleTypes(allowedTypes) {
return lodash_1.default.uniq(allowedTypes.map(t => {
return lodash_1.default.uniq(allowedTypes.map((t) => {
if (t === 'object') {

@@ -28,0 +28,0 @@ return 'object';

@@ -45,3 +45,3 @@ "use strict";

if (Array.isArray(value)) {
return value.map(v => parameterDescriptor.parser.parseString(v));
return value.map((v) => parameterDescriptor.parser.parseString(v));
}

@@ -48,0 +48,0 @@ else {

@@ -29,3 +29,3 @@ "use strict";

// crazy path like "/foo/{bar}/{bar}".
answer = value.map(v => parsePathParameter(location, v, structuredParser));
answer = value.map((v) => parsePathParameter(location, v, structuredParser));
}

@@ -32,0 +32,0 @@ else {

@@ -97,3 +97,3 @@ "use strict";

function explodedKeysStructuredParser(values) {
return lodash_1.default.mapValues(values, v => {
return lodash_1.default.mapValues(values, (v) => {
if (Array.isArray(v)) {

@@ -100,0 +100,0 @@ return v.map(decodeURIComponent);

@@ -22,4 +22,4 @@ "use strict";

exegesisController = oaPath[extensions_1.EXEGESIS_CONTROLLER] || exegesisController;
this._operations = HTTP_METHODS.map(method => method.toLowerCase())
.filter(method => oaPath[method])
this._operations = HTTP_METHODS.map((method) => method.toLowerCase())
.filter((method) => oaPath[method])
.reduce((result, method) => {

@@ -26,0 +26,0 @@ result[method] = new Operation_1.default(context.childContext(method), oaPath[method], oaPath, method, exegesisController, parameters);

@@ -65,3 +65,3 @@ "use strict";

else {
this.validator = value => ({ errors: null, value });
this.validator = (value) => ({ errors: null, value });
}

@@ -68,0 +68,0 @@ }

import { ParameterLocation, ValidatorFunction } from '../../types';
import Oas3CompileContext from '../Oas3CompileContext';
export declare function _fixNullables(schema: any): void;
export declare function _fixNullables(schema: any): any;
export declare function _filterRequiredProperties(schema: any, propNameToFilter: string): void;
export declare function generateRequestValidator(schemaContext: Oas3CompileContext, parameterLocation: ParameterLocation, parameterRequired: boolean, mediaType: string): ValidatorFunction;
export declare function generateResponseValidator(schemaContext: Oas3CompileContext, parameterLocation: ParameterLocation, parameterRequired: boolean): ValidatorFunction;

@@ -81,27 +81,27 @@ "use strict";

function _fixNullables(schema) {
json_schema_traverse_1.default(schema, (childSchema) => {
if (schema.properties) {
for (const propName of Object.keys(childSchema.properties)) {
const prop = childSchema.properties[propName];
const resolvedProp = json_schema_resolve_ref_1.resolveRef(schema, prop);
if (resolvedProp.nullable) {
childSchema.properties[propName] = { anyOf: [{ type: 'null' }, prop] };
json_schema_traverse_1.default(schema, {
cb: {
post: (childSchema, _jsonPtr, rootSchema, _parentJsonPtr, parentKeyword, _parentSchema, keyIndex) => {
if (childSchema.nullable) {
let ref = rootSchema;
let key = parentKeyword;
if (key && keyIndex) {
ref = ref[key];
key = `${keyIndex}`;
}
if (ref && key) {
ref[key] = {
anyOf: [{ type: 'null' }, childSchema],
};
}
else if (childSchema === schema) {
schema = {
anyOf: [{ type: 'null' }, schema],
};
}
}
}
}
if (childSchema.additionalProperties) {
const resolvedProp = json_schema_resolve_ref_1.resolveRef(schema, childSchema.additionalProperties);
if (resolvedProp.nullable) {
childSchema.additionalProperties = {
anyOf: [{ type: 'null' }, childSchema.additionalProperties],
};
}
}
if (childSchema.items) {
const resolvedItems = json_schema_resolve_ref_1.resolveRef(schema, childSchema.items);
if (resolvedItems.nullable) {
childSchema.items = { anyOf: [{ type: 'null' }, childSchema.items] };
}
}
},
},
});
return schema;
}

@@ -147,3 +147,3 @@ exports._fixNullables = _fixNullables;

if (ajvValidate.errors) {
errors = ajvValidate.errors.map(err => {
errors = ajvValidate.errors.map((err) => {
let pathPtr = err.dataPath || '';

@@ -175,5 +175,5 @@ if (pathPtr.startsWith('/value')) {

// TODO: Should we do this? Or should we rely on the schema being correct in the first place?
// _fixNullables(schema);
// schema = _fixNullables(schema);
// So that we can replace the "root" value of the schema using ajv's type coercion...
json_schema_traverse_1.default(schema, node => {
json_schema_traverse_1.default(schema, (node) => {
if (node.$ref) {

@@ -180,0 +180,0 @@ if (node.$ref.startsWith('#')) {

@@ -14,3 +14,3 @@ "use strict";

: securitySchemes;
this._challenges = lodash_1.default.mapValues(this._securitySchemes, scheme => {
this._challenges = lodash_1.default.mapValues(this._securitySchemes, (scheme) => {
if (scheme.type === 'http') {

@@ -24,3 +24,3 @@ return scheme.scheme || 'Basic';

});
this._infos = lodash_1.default.mapValues(this._securitySchemes, scheme => {
this._infos = lodash_1.default.mapValues(this._securitySchemes, (scheme) => {
if (scheme.type === 'apiKey') {

@@ -27,0 +27,0 @@ return {

@@ -81,3 +81,3 @@ "use strict";

servers = servers || [{ url: '/' }];
this._servers = servers.map(server => generateServerParser(server));
this._servers = servers.map((server) => generateServerParser(server));
}

@@ -84,0 +84,0 @@ /**

@@ -45,3 +45,3 @@ "use strict";

function intersection(a, b) {
return new Set([...a].filter(x => b.has(x)));
return new Set([...a].filter((x) => b.has(x)));
}

@@ -48,0 +48,0 @@ function inferTypesOneOf(rootSchema, oneOf, stack) {

@@ -15,3 +15,3 @@ "use strict";

}
const path = jsonPtr.decode(ref);
const path = jsonPtr.JsonPointer.decode(ref).slice();
let currentDoc = document;

@@ -18,0 +18,0 @@ while (path.length > 0) {

@@ -12,6 +12,6 @@ "use strict";

function normalize(path) {
return jsonPtr.encodePointer(jsonPtr.decode(path));
return jsonPtr.encodePointer(jsonPtr.JsonPointer.decode(path));
}
function toUriFragment(path) {
return jsonPtr.encodeUriFragmentIdentifier(jsonPtr.decode(path));
return jsonPtr.encodeUriFragmentIdentifier(jsonPtr.JsonPointer.decode(path));
}

@@ -18,0 +18,0 @@ exports.toUriFragment = toUriFragment;

@@ -58,4 +58,4 @@ "use strict";

const origRef = schema.$ref;
const jsonPath = jsonPtr.decode(schema.$ref);
let newRefSuffix = jsonPath.length > 0 ? jsonPath[jsonPath.length - 1] : undefined;
const jsonPath = jsonPtr.JsonPointer.decode(schema.$ref);
let newRefSuffix = jsonPath.length > 0 ? `${jsonPath[jsonPath.length - 1]}` : undefined;
while (!newRefSuffix ||

@@ -62,0 +62,0 @@ ctx.result.definitions[newRefSuffix] ||

@@ -63,3 +63,3 @@ "use strict";

getRegisteredTypes() {
const answer = Object.keys(this._staticMimeTypes).concat(Object.keys(this._wildcardSubtypes).map(type => `${type}/*`));
const answer = Object.keys(this._staticMimeTypes).concat(Object.keys(this._wildcardSubtypes).map((type) => `${type}/*`));
if (this._defaultMimeType) {

@@ -66,0 +66,0 @@ answer.push('*/*');

{
"name": "exegesis",
"version": "2.5.5",
"version": "2.5.6",
"description": "Parses OpenAPI documents",

@@ -57,4 +57,5 @@ "main": "lib/index.js",

"@types/json-schema": "^7.0.3",
"@types/json-schema-traverse": "^0.4.0",
"@types/lodash": "^4.14.132",
"@types/mocha": "^7.0.0",
"@types/mocha": "^8.0.0",
"@types/node": "^13.1.0",

@@ -70,5 +71,5 @@ "@types/pump": "^1.0.1",

"markdownlint-cli": "^0.18.0",
"mocha": "^7.0.1",
"mocha": "^8.0.1",
"nyc": "^15.0.0",
"prettier": "^1.19.1",
"prettier": "^2.0.5",
"pretty-quick": "^2.0.1",

@@ -82,3 +83,4 @@ "semantic-release": "^17.0.4",

"dependencies": {
"ajv": "^6.9.1",
"@apidevtools/json-schema-ref-parser": "^9.0.3",
"ajv": "^6.12.2",
"body-parser": "^1.18.3",

@@ -89,4 +91,3 @@ "content-type": "^1.0.4",

"glob": "^7.1.3",
"json-ptr": "^1.1.1",
"json-schema-ref-parser": "^7.0.0",
"json-ptr": "^1.3.1",
"json-schema-traverse": "^0.4.1",

@@ -93,0 +94,0 @@ "lodash": "^4.17.11",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc