forked from lukeautry/tsoa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ts
174 lines (143 loc) · 4.65 KB
/
config.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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import * as ts from 'typescript';
import { Swagger } from './swagger/swagger';
export interface Config {
/**
* Swagger generation configuration object
*/
swagger: SwaggerConfig;
/**
* Route generation configuration object
*/
routes: RoutesConfig;
/**
* Directories to ignore during TypeScript metadata scan
*/
ignore?: string[];
/**
* Typescript CompilerOptions to be used during generation
*
* @type {ts.CompilerOptions}
* @memberof RoutesConfig
*/
compilerOptions?: ts.CompilerOptions;
}
/**
* these options will be removed in a future version since we would prefer consumers to explicitly state their preference that the tsoa validation throws or removes additional properties
*/
export type DeprecatedOptionForAdditionalPropertiesHandling = true | false;
export interface SwaggerConfig {
/**
* Generated SwaggerConfig.json will output here
*/
outputDirectory: string;
/**
* The entry point to your API
*/
entryFile: string;
/**
* Modes that allow you to prevent input data from entering into your API. This will document your decision in the swagger.yaml and it will turn on excess-property validation (at runtime) in your routes.
*/
noImplicitAdditionalProperties?: 'throw-on-extras' | 'silently-remove-extras' | DeprecatedOptionForAdditionalPropertiesHandling;
/**
* API host, expressTemplat e.g. localhost:3000 or myapi.com, use null for relative urls
*/
host?: string | null;
/**
* API version number; defaults to npm package version
*/
version?: string;
/**
* Major OpenAPI version to generate; defaults to version 2 when not specified
* Possible values:
* - 2: generates OpenAPI version 2.
* - 3: generates OpenAPI version 3.
*/
specVersion?: Swagger.SupportedSpecMajorVersion;
/**
* API name; defaults to npm package name
*/
name?: string;
/**
* 'API description; defaults to npm package description
*/
description?: string;
/**
* API license; defaults to npm package license
*/
license?: string;
/**
* Base API path; e.g. the 'v1' in https://myapi.com/v1
*/
basePath?: string;
/**
* Extend generated swagger spec with this object
* Note that generated properties will always take precedence over what get specified here
*/
spec?: any;
/**
* Alter how the spec is merged to generated swagger spec.
* Possible values:
* - 'immediate' is overriding top level elements only thus you can not append a new path or alter an existing value without erasing same level elements.
* - 'recursive' proceed to a deep merge and will concat every branches or override or create new values if needed. @see https://www.npmjs.com/package/merge
* The default is set to immediate so it is not breaking previous versions.
* @default 'immediate'
*/
specMerging?: 'immediate' | 'recursive';
/**
* Security Definitions Object
* A declaration of the security schemes available to be used in the
* specification. This does not enforce the security schemes on the operations
* and only serves to provide the relevant details for each scheme.
*/
securityDefinitions?: {
[name: string]: Swagger.Security;
};
/**
* Swagger Tags Information for your API
*/
tags?: Swagger.Tag[];
yaml?: boolean;
schemes?: Swagger.Protocol[];
/**
* An array of path globs that point to your route controllers that you would like to have tsoa include. You can provide this config on either the SwaggerConfig or the RoutesConfig
*/
controllerPathGlobs?: string[];
}
export interface RoutesConfig {
/**
* Routes directory; generated routes.ts (which contains the generated code wiring up routes using middleware of choice) will be dropped here
*/
routesDir: string;
/**
* Routes filename; the filename of the generated route file ('routes.ts' by default)
*/
routesFileName?: string;
/**
* The entry point to your API
*/
entryFile: string;
/**
* Base API path; e.g. the '/v1' in https://myapi.com/v1
*/
basePath?: string;
/**
* Middleware provider.
*/
middleware?: 'express' | 'hapi' | 'koa';
/**
* Override the Middleware template
*/
middlewareTemplate?: string;
/**
* IOC module; e.g. './inversify/ioc' where IOC container named `iocContainer` is defined (https://github.com/inversify/InversifyJS)
*/
iocModule?: string;
/**
* Authentication Module for express, hapi and koa
*/
authenticationModule?: string;
/**
* An array of path globs that point to your route controllers that you would like to have tsoa include. You can provide this config on either the SwaggerConfig or the RoutesConfig
*/
controllerPathGlobs?: string[];
}