Skip to content

Commit

Permalink
removes lodash.uniq and lodash.zipobject dependencies (#893)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdimascio committed Jan 28, 2024
1 parent 2977c0a commit 1206802
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 19 deletions.
14 changes: 1 addition & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions package.json
Expand Up @@ -42,8 +42,6 @@
"json-schema-traverse": "^1.0.0",
"lodash.clonedeep": "^4.5.0",
"lodash.get": "^4.4.2",
"lodash.uniq": "^4.5.0",
"lodash.zipobject": "^4.1.3",
"media-typer": "^1.1.0",
"multer": "^1.4.5-lts.1",
"ono": "^7.1.3",
Expand Down
4 changes: 2 additions & 2 deletions src/middlewares/openapi.metadata.ts
@@ -1,4 +1,4 @@
import * as _zipObject from 'lodash.zipobject';
import { zipObject } from './util';
import { pathToRegexp } from 'path-to-regexp';
import { Response, NextFunction } from 'express';
import { OpenApiContext } from '../framework/openapi.context';
Expand Down Expand Up @@ -94,7 +94,7 @@ export function applyOpenApiMetadata(
const paramKeys = keys.map((k) => k.name);
try {
const paramsVals = matchedRoute.slice(1).map(decodeURIComponent);
const pathParams = _zipObject(paramKeys, paramsVals);
const pathParams = zipObject(paramKeys, paramsVals);

const r = {
schema,
Expand Down
7 changes: 7 additions & 0 deletions src/middlewares/util.ts
Expand Up @@ -164,3 +164,10 @@ export const findResponseContent = function (
}
return null;
};

export const zipObject = (keys, values) =>
keys.reduce((acc, key, idx) => {
acc[key] = values[idx]
return acc
}, {})

4 changes: 2 additions & 2 deletions src/openapi.validator.ts
@@ -1,7 +1,6 @@
import { Options } from 'ajv';
import ono from 'ono';
import * as express from 'express';
import * as _uniq from 'lodash.uniq';
import * as middlewares from './middlewares';
import { Application, Response, NextFunction, Router } from 'express';
import { OpenApiContext } from './framework/openapi.context';
Expand Down Expand Up @@ -237,7 +236,8 @@ export class OpenApiValidator {
}

// install param on routes with paths
for (const p of _uniq(pathParams)) {
const uniqPathParams = [...new Set(pathParams)]
for (const p of uniqPathParams) {
app.param(
p,
(
Expand Down

0 comments on commit 1206802

Please sign in to comment.