File tree Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Expand file tree Collapse file tree 1 file changed +13
-9
lines changed Original file line number Diff line number Diff line change
1
+ import { Enum } from './client/interfaces/Enum' ;
1
2
import { Model } from './client/interfaces/Model' ;
2
3
3
4
export enum Case {
@@ -23,16 +24,19 @@ const transforms = {
23
24
// A recursive function that looks at the models and their properties and
24
25
// converts each property name using the provided transform function.
25
26
export const convertModelNames = ( model : Model , type : Exclude < Case , Case . NONE > ) : Model => {
26
- if ( ! model . properties . length ) {
27
- return {
28
- ...model ,
29
- name : transforms [ type ] ( model . name ) ,
30
- } ;
31
- }
32
27
return {
33
28
...model ,
34
- properties : model . properties . map ( property => {
35
- return convertModelNames ( property , type ) ;
36
- } ) ,
29
+ name : transforms [ type ] ( model . name ) ,
30
+ link : model . link ? convertModelNames ( model . link , type ) : null ,
31
+ enum : model . enum . map ( modelEnum => convertEnumName ( modelEnum , type ) ) ,
32
+ enums : model . enums . map ( property => convertModelNames ( property , type ) ) ,
33
+ properties : model . properties . map ( property => convertModelNames ( property , type ) ) ,
34
+ } ;
35
+ } ;
36
+
37
+ const convertEnumName = ( modelEnum : Enum , type : Exclude < Case , Case . NONE > ) : Enum => {
38
+ return {
39
+ ...modelEnum ,
40
+ name : transforms [ type ] ( modelEnum . name ) ,
37
41
} ;
38
42
} ;
You can’t perform that action at this time.
0 commit comments