forked from asyncapi/modelina
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TemplateConstrainer.ts
62 lines (60 loc) · 1.63 KB
/
TemplateConstrainer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { Constraints, TypeMapping } from '../../helpers';
import {
defaultEnumKeyConstraints,
defaultEnumValueConstraints
} from './constrainer/EnumConstrainer';
import { defaultModelNameConstraints } from './constrainer/ModelNameConstrainer';
import { defaultPropertyKeyConstraints } from './constrainer/PropertyKeyConstrainer';
import { defaultConstantConstraints } from './constrainer/ConstantConstrainer';
import { TemplateDependencyManager } from './TemplateDependencyManager';
import { TemplateOptions } from './TemplateGenerator';
export const TemplateDefaultTypeMapping: TypeMapping<
TemplateOptions,
TemplateDependencyManager
> = {
Object({ constrainedModel }): string {
//Returning name here because all object models have been split out
return constrainedModel.name;
},
Reference({ constrainedModel }): string {
return constrainedModel.name;
},
Any(): string {
return '';
},
Float(): string {
return '';
},
Integer(): string {
return '';
},
String(): string {
return '';
},
Boolean(): string {
return '';
},
Tuple(): string {
return '';
},
Array(): string {
return '';
},
Enum({ constrainedModel }): string {
//Returning name here because all enum models have been split out
return constrainedModel.name;
},
Union(): string {
return '';
},
Dictionary(): string {
return '';
}
};
export const TemplateDefaultConstraints = {
enumKey: defaultEnumKeyConstraints(),
enumValue: defaultEnumValueConstraints(),
modelName: defaultModelNameConstraints(),
propertyKey: defaultPropertyKeyConstraints(),
constant: defaultConstantConstraints()
};