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 26
26
"author" : " OpenAPI Contrib" ,
27
27
"license" : " MIT" ,
28
28
"dependencies" : {
29
- "fast-deep-equal" : " ^3.1.3" ,
30
- "lodash-es" : " ^4.17.21"
29
+ "fast-deep-equal" : " ^3.1.3"
31
30
},
32
31
"devDependencies" : {
33
32
"@types/json-schema" : " ^7.0.11" ,
34
- "@types/lodash-es" : " ^4.17.7" ,
35
33
"@typescript-eslint/eslint-plugin" : " ^5.57.0" ,
36
34
"@typescript-eslint/parser" : " ^5.57.0" ,
37
35
"c8" : " ^7.13.0" ,
Original file line number Diff line number Diff line change @@ -2,9 +2,9 @@ import deepEqual from "fast-deep-equal";
2
2
import { fromSchema , fromParameter } from "./lib/convert" ;
3
3
import type { Options , OptionsInternal , OpenAPI3 } from "./openapi-schema-types" ;
4
4
import { NOT_SUPPORTED , STRUCTS } from "./consts" ;
5
- import { cloneDeep } from "lodash-es" ;
6
5
import type { JSONSchema4 } from "json-schema" ;
7
6
import type { ParameterObject , ResponseObject } from "openapi-typescript/src/types" ;
7
+ import { cloneDeep } from "./lib/utils/cloneDeep" ;
8
8
const patternPropertiesHandler = ( schema ) => {
9
9
let pattern ;
10
10
const patternsObj = schema . patternProperties ;
Original file line number Diff line number Diff line change 1
1
import { isObject } from "../utils/isObject" ;
2
2
import InvalidTypeError from "../errors/invalid-type-error" ;
3
3
import type { OptionsInternal } from "../../openapi-schema-types" ;
4
- import { cloneDeep } from "lodash-es" ;
5
4
import type { JSONSchema4 , JSONSchema4TypeName } from "json-schema" ;
6
5
import { VALID_OPENAPI_FORMATS } from "../../consts" ;
7
6
import type { SchemaObject } from "openapi-typescript/src/types" ;
8
7
import type { PatternPropertiesHandler } from "../../openapi-schema-types" ;
9
8
import type { OpenAPI3 } from "openapi-typescript" ;
10
9
import type { ReferenceObject } from "openapi-typescript/src/types" ;
10
+ import { cloneDeep } from "../utils/cloneDeep" ;
11
11
12
12
// Convert from OpenAPI 3.0 `SchemaObject` to JSON schema v4
13
13
function 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 650
650
resolved "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
651
651
integrity sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==
652
652
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
-
665
653
" @types/minimist@^1.2.0 " :
666
654
version "1.2.2"
667
655
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