File tree Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Expand file tree Collapse file tree 2 files changed +7
-12
lines changed Original file line number Diff line number Diff line change 64
64
"commander" : " ^10.0.0" ,
65
65
"fs-extra" : " ^11.1.1" ,
66
66
"handlebars" : " ^4.7.7" ,
67
- "json-schema-ref-parser" : " ^9.0.9"
67
+ "json-schema-ref-parser" : " ^9.0.9" ,
68
+ "lodash" : " ^4.17.21"
68
69
},
69
70
"devDependencies" : {
70
71
"@angular-devkit/build-angular" : " 15.2.5" ,
90
91
"@types/fs-extra" : " ^11.0.1" ,
91
92
"@types/glob" : " 8.1.0" ,
92
93
"@types/jest" : " 29.5.1" ,
94
+ "@types/lodash" : " ^4.14.195" ,
93
95
"@types/node" : " 18.16.3" ,
94
96
"@types/node-fetch" : " 2.6.3" ,
95
97
"@types/qs" : " 6.9.7" ,
Original file line number Diff line number Diff line change
1
+ import { camelCase , snakeCase } from 'lodash' ;
2
+
1
3
import { Enum } from './client/interfaces/Enum' ;
2
4
import { Model } from './client/interfaces/Model' ;
3
5
import { OperationResponse } from './client/interfaces/OperationResponse' ;
@@ -8,19 +10,10 @@ export enum Case {
8
10
CAMEL = 'camel' ,
9
11
SNAKE = 'snake' ,
10
12
}
11
- // Convert a string from snake case to camel case.
12
- const toCamelCase = ( str : string ) : string => {
13
- return str . replace ( / _ ( [ a - z ] ) / g, match => match [ 1 ] . toUpperCase ( ) ) ;
14
- } ;
15
-
16
- // Convert a string from camel case or pascal case to snake case.
17
- const toSnakeCase = ( str : string ) : string => {
18
- return str . replace ( / ( [ A - Z ] ) / g, match => `_${ match . toLowerCase ( ) } ` ) ;
19
- } ;
20
13
21
14
const transforms = {
22
- [ Case . CAMEL ] : toCamelCase ,
23
- [ Case . SNAKE ] : toSnakeCase ,
15
+ [ Case . CAMEL ] : camelCase ,
16
+ [ Case . SNAKE ] : snakeCase ,
24
17
} ;
25
18
26
19
// A recursive function that looks at the models and their properties and
You can’t perform that action at this time.
0 commit comments