File tree Expand file tree Collapse file tree 5 files changed +50
-17
lines changed Expand file tree Collapse file tree 5 files changed +50
-17
lines changed Original file line number Diff line number Diff line change 2626 "author" : " OpenAPI Contrib" ,
2727 "license" : " MIT" ,
2828 "dependencies" : {
29- "fast-deep-equal" : " ^3.1.3" ,
30- "lodash-es" : " ^4.17.21"
29+ "fast-deep-equal" : " ^3.1.3"
3130 },
3231 "devDependencies" : {
3332 "@types/json-schema" : " ^7.0.11" ,
34- "@types/lodash-es" : " ^4.17.7" ,
3533 "@typescript-eslint/eslint-plugin" : " ^5.57.0" ,
3634 "@typescript-eslint/parser" : " ^5.57.0" ,
3735 "c8" : " ^7.13.0" ,
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ import deepEqual from "fast-deep-equal";
22import { fromSchema , fromParameter } from "./lib/convert" ;
33import type { Options , OptionsInternal , OpenAPI3 } from "./openapi-schema-types" ;
44import { NOT_SUPPORTED , STRUCTS } from "./consts" ;
5- import { cloneDeep } from "lodash-es" ;
65import type { JSONSchema4 } from "json-schema" ;
76import type { ParameterObject , ResponseObject } from "openapi-typescript/src/types" ;
7+ import { cloneDeep } from "./lib/utils/cloneDeep" ;
88const patternPropertiesHandler = ( schema ) => {
99 let pattern ;
1010 const patternsObj = schema . patternProperties ;
Original file line number Diff line number Diff line change 11import { isObject } from "../utils/isObject" ;
22import InvalidTypeError from "../errors/invalid-type-error" ;
33import type { OptionsInternal } from "../../openapi-schema-types" ;
4- import { cloneDeep } from "lodash-es" ;
54import type { JSONSchema4 , JSONSchema4TypeName } from "json-schema" ;
65import { VALID_OPENAPI_FORMATS } from "../../consts" ;
76import type { SchemaObject } from "openapi-typescript/src/types" ;
87import type { PatternPropertiesHandler } from "../../openapi-schema-types" ;
98import type { OpenAPI3 } from "openapi-typescript" ;
109import type { ReferenceObject } from "openapi-typescript/src/types" ;
10+ import { cloneDeep } from "../utils/cloneDeep" ;
1111
1212// Convert from OpenAPI 3.0 `SchemaObject` to JSON schema v4
1313function convertFromSchema < T extends OpenAPI3 = OpenAPI3 > ( schema : T , options : OptionsInternal ) : JSONSchema4 {
Original file line number Diff line number Diff line change 1+ // Fromhttps://dev.to/salyadav/deep-clone-of-js-objects-with-circular-dependency-4if7
2+ const isArray = ( val ) => {
3+ return Array . isArray ( val ) ;
4+ } ;
5+
6+ const isObject = ( val ) => {
7+ return { } . toString . call ( val ) === "[object Object]" && ! isArray ( val ) ;
8+ } ;
9+
10+ export const cloneDeep = ( val , history = new Set ( ) ) => {
11+ const stack = history || new Set ( ) ;
12+
13+ if ( stack . has ( val ) ) {
14+ return val ;
15+ }
16+
17+ stack . add ( val ) ;
18+
19+ const copyObject = ( o ) => {
20+ const oo = Object . create ( { } ) ;
21+ for ( const k in o ) {
22+ oo [ k ] = cloneDeep ( o [ k ] , stack ) ;
23+ }
24+ return oo ;
25+ } ;
26+
27+ const copyArray = ( a ) => {
28+ return [ ...a ] . map ( ( e ) => {
29+ if ( isArray ( e ) ) {
30+ return copyArray ( e ) ;
31+ } else if ( isObject ( e ) ) {
32+ return copyObject ( e ) ;
33+ }
34+ return cloneDeep ( e , stack ) ;
35+ } ) ;
36+ } ;
37+
38+ if ( isArray ( val ) ) {
39+ return copyArray ( val ) ;
40+ }
41+
42+ if ( isObject ( val ) ) {
43+ return copyObject ( val ) ;
44+ }
45+
46+ return val ;
47+ } ;
Original file line number Diff line number Diff line change 650650 resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
651651 integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==
652652
653- " @types/lodash-es@^4.17.7 " :
654- version "4.17.7"
655- resolved "https://registry.npmjs.org/@types/lodash-es/-/lodash-es-4.17.7.tgz#22edcae9f44aff08546e71db8925f05b33c7cc40"
656- integrity sha512-z0ptr6UI10VlU6l5MYhGwS4mC8DZyYer2mCoyysZtSF7p26zOX8UpbrV0YpNYLGS8K4PUFIyEr62IMFFjveSiQ==
657- dependencies :
658- " @types/lodash" " *"
659-
660- " @types/lodash@* " :
661- version "4.14.192"
662- resolved "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.192.tgz#5790406361a2852d332d41635d927f1600811285"
663- integrity sha512-km+Vyn3BYm5ytMO13k9KTp27O75rbQ0NFw+U//g+PX7VZyjCioXaRFisqSIJRECljcTv73G3i6BpglNGHgUQ5A==
664-
665653" @types/minimist@^1.2.0 " :
666654 version "1.2.2"
667655 resolved "https://registry.npmjs.org/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c"
You can’t perform that action at this time.
0 commit comments