-
-
Notifications
You must be signed in to change notification settings - Fork 386
/
Copy pathconfig.js
97 lines (91 loc) · 2.66 KB
/
config.js
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const { HTTP_CLIENT, TS_KEYWORDS, PRETTIER_OPTIONS } = require("./constants");
const { NameResolver } = require("./utils/resolveName");
const config = {
/** CLI flag */
templates: "../templates/default",
/** CLI flag */
generateResponses: false,
/** CLI flag */
defaultResponseAsSuccess: false,
/** CLI flag */
generateRouteTypes: false,
/** CLI flag */
generateClient: true,
/** CLI flag */
generateUnionEnums: false,
/** CLI flag */
interfaceExtend: "",
/** CLI flag */
customImport: "",
enumNamesAsValues: false,
/** parsed swagger schema from getSwaggerObject() */
/** parsed swagger schema ref */
swaggerSchema: null,
/** original (converted to json) swagger schema ref */
originalSchema: null,
/** { "#/components/schemas/Foo": @TypeInfo, ... } */
componentsMap: {},
/** flag for catching convertion from swagger 2.0 */
convertedFromSwagger2: false,
/** url index from paths used for merging into modules */
moduleNameIndex: 0,
/** use the first tag for the module name */
moduleNameFirstTag: false,
disableStrictSSL: false,
disableProxy: false,
extractRequestParams: false,
extractRequestBody: false,
fileNames: {
dataContracts: "data-contracts",
routeTypes: "route-types",
httpClient: "http-client",
outOfModuleApi: "Common",
},
routeNameDuplicatesMap: new Map(),
prettierOptions: PRETTIER_OPTIONS,
hooks: {
onCreateComponent: (schema) => schema,
onParseSchema: (originalSchema, parsedSchema) => parsedSchema,
onCreateRoute: (routeData) => routeData,
onInit: (config) => config,
onPrepareConfig: (apiConfig) => apiConfig,
onCreateRequestParams: (rawType) => {},
onCreateRouteName: () => {},
onFormatTypeName: (typeName, rawTypeName) => {},
onFormatRouteName: (routeInfo, templateRouteName) => {},
},
defaultResponseType: TS_KEYWORDS.VOID,
singleHttpClient: false,
httpClientType: HTTP_CLIENT.FETCH,
unwrapResponseData: false,
templatePaths: {
/** `templates/base` */
base: "",
/** `templates/default` */
default: "",
/** `templates/modular` */
modular: "",
/** usage path if `--templates` option is not set */
original: "",
/** custom path to templates (`--templates`) */
custom: "",
},
/** Record<templateName, templateContent> */
templatesToRender: {
api: "",
dataContracts: "",
httpClient: "",
routeTypes: "",
routeName: "",
},
toJS: false,
silent: false,
typePrefix: "",
typeSuffix: "",
componentTypeNameResolver: new NameResolver([]),
};
/** needs to use data everywhere in project */
module.exports = {
addToConfig: (configParts) => Object.assign(config, configParts),
config,
};