Skip to content

Commit 1206802

Browse files
authored
removes lodash.uniq and lodash.zipobject dependencies (#893)
1 parent 2977c0a commit 1206802

File tree

5 files changed

+12
-19
lines changed

5 files changed

+12
-19
lines changed

package-lock.json

+1-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
"json-schema-traverse": "^1.0.0",
4343
"lodash.clonedeep": "^4.5.0",
4444
"lodash.get": "^4.4.2",
45-
"lodash.uniq": "^4.5.0",
46-
"lodash.zipobject": "^4.1.3",
4745
"media-typer": "^1.1.0",
4846
"multer": "^1.4.5-lts.1",
4947
"ono": "^7.1.3",

src/middlewares/openapi.metadata.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as _zipObject from 'lodash.zipobject';
1+
import { zipObject } from './util';
22
import { pathToRegexp } from 'path-to-regexp';
33
import { Response, NextFunction } from 'express';
44
import { OpenApiContext } from '../framework/openapi.context';
@@ -94,7 +94,7 @@ export function applyOpenApiMetadata(
9494
const paramKeys = keys.map((k) => k.name);
9595
try {
9696
const paramsVals = matchedRoute.slice(1).map(decodeURIComponent);
97-
const pathParams = _zipObject(paramKeys, paramsVals);
97+
const pathParams = zipObject(paramKeys, paramsVals);
9898

9999
const r = {
100100
schema,

src/middlewares/util.ts

+7
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,10 @@ export const findResponseContent = function (
164164
}
165165
return null;
166166
};
167+
168+
export const zipObject = (keys, values) =>
169+
keys.reduce((acc, key, idx) => {
170+
acc[key] = values[idx]
171+
return acc
172+
}, {})
173+

src/openapi.validator.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Options } from 'ajv';
22
import ono from 'ono';
33
import * as express from 'express';
4-
import * as _uniq from 'lodash.uniq';
54
import * as middlewares from './middlewares';
65
import { Application, Response, NextFunction, Router } from 'express';
76
import { OpenApiContext } from './framework/openapi.context';
@@ -237,7 +236,8 @@ export class OpenApiValidator {
237236
}
238237

239238
// install param on routes with paths
240-
for (const p of _uniq(pathParams)) {
239+
const uniqPathParams = [...new Set(pathParams)]
240+
for (const p of uniqPathParams) {
241241
app.param(
242242
p,
243243
(

0 commit comments

Comments
 (0)