From 9d7751cfde28daf175fedd4bd49d3f9b58f4ce2f Mon Sep 17 00:00:00 2001 From: Ashot Nazaryan Date: Tue, 23 Apr 2024 22:11:45 -0700 Subject: [PATCH] fix: don't mutate original schemas --- lib/utils.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/utils.js b/lib/utils.js index a8625cb..05d30fe 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,5 +1,5 @@ const { assignWithSet } = require('./helpers'); -const { omit, pick } = require('lodash'); +const { omit, pick, cloneDeep} = require('lodash'); exports.tag = function tag (name, options = {}) { const result = { @@ -165,9 +165,10 @@ function determineSchemaPrefix (schemas) { return undefined; } -exports.createSwaggerServiceOptions = function createSwaggerServiceOptions ({ schemas, docs, transformSchema }) { +exports.createSwaggerServiceOptions = function createSwaggerServiceOptions ({ schemas: originalSchemas, docs, transformSchema }) { const serviceDocs = { schemas: {}, refs: {} }; const transformSchemaFn = transformSchema || exports.defaultTransformSchema; + const schemas = cloneDeep(originalSchemas) let unspecificSchemas; const prefix = determineSchemaPrefix(schemas);