@@ -32,9 +32,9 @@ export function getOperation(route: IRoute): oa.OperationObject {
32
32
const operation : oa . OperationObject = {
33
33
operationId : getOperationId ( route ) ,
34
34
parameters : [
35
- ... getHeaderParams ( route ) ,
36
- ... getPathParams ( route ) ,
37
- ... getQueryParams ( route )
35
+ ...getHeaderParams ( route ) ,
36
+ ...getPathParams ( route ) ,
37
+ ...getQueryParams ( route )
38
38
] ,
39
39
requestBody : getRequestBody ( route ) || undefined ,
40
40
responses : getResponses ( route ) ,
@@ -64,7 +64,7 @@ export function getPaths(routes: IRoute[]): oa.PathObject {
64
64
} ) )
65
65
66
66
// @ts -ignore: array spread
67
- return _ . merge ( ... routePaths )
67
+ return _ . merge ( ...routePaths )
68
68
}
69
69
70
70
/**
@@ -127,7 +127,7 @@ export function getPathParams(route: IRoute): oa.ParameterObject[] {
127
127
if ( meta ) {
128
128
const metaSchema = getParamSchema ( meta )
129
129
param . schema =
130
- 'type' in metaSchema ? { ... param . schema , ... metaSchema } : metaSchema
130
+ 'type' in metaSchema ? { ...param . schema , ...metaSchema } : metaSchema
131
131
}
132
132
133
133
return param
@@ -173,26 +173,26 @@ export function getRequestBody(route: IRoute): oa.RequestBodyObject | void {
173
173
const bodyParamsSchema : oa . SchemaObject | null =
174
174
bodyParamMetas . length > 0
175
175
? bodyParamMetas . reduce (
176
- ( acc : oa . SchemaObject , d ) => ( {
177
- ... acc ,
178
- properties : {
179
- ... acc . properties ,
180
- [ d . name ! ] : getParamSchema ( d )
181
- } ,
182
- required : isRequired ( d , route )
183
- ? [ ... ( acc . required || [ ] ) , d . name ! ]
184
- : acc . required
185
- } ) ,
186
- { properties : { } , required : [ ] , type : 'object' }
187
- )
176
+ ( acc : oa . SchemaObject , d ) => ( {
177
+ ...acc ,
178
+ properties : {
179
+ ...acc . properties ,
180
+ [ d . name ! ] : getParamSchema ( d )
181
+ } ,
182
+ required : isRequired ( d , route )
183
+ ? [ ...( acc . required || [ ] ) , d . name ! ]
184
+ : acc . required
185
+ } ) ,
186
+ { properties : { } , required : [ ] , type : 'object' }
187
+ )
188
188
: null
189
189
190
190
const bodyMeta = route . params . find ( d => d . type === 'body' )
191
191
192
192
if ( bodyMeta ) {
193
193
const bodySchema = getParamSchema ( bodyMeta )
194
194
const { $ref } =
195
- 'items' in bodySchema && bodySchema . items ? bodySchema . items : bodySchema
195
+ 'items' in bodySchema && bodySchema . items ? bodySchema . items : bodySchema
196
196
197
197
return {
198
198
content : {
@@ -221,15 +221,15 @@ export function getContentType(route: IRoute): string {
221
221
? 'application/json'
222
222
: 'text/html; charset=utf-8'
223
223
const contentMeta = _ . find ( route . responseHandlers , { type : 'content-type' } )
224
- return contentMeta ? contentMeta . value : defaultContentType
224
+ return contentMeta ? contentMeta . value : defaultContentType
225
225
}
226
226
227
227
/**
228
228
* Return the status code of given route.
229
229
*/
230
230
export function getStatusCode ( route : IRoute ) : string {
231
231
const successMeta = _ . find ( route . responseHandlers , { type : 'success-code' } )
232
- return successMeta ? successMeta . value + '' : '200'
232
+ return successMeta ? successMeta . value + '' : '200'
233
233
}
234
234
235
235
/**
@@ -279,7 +279,7 @@ export function getTags(route: IRoute): string[] {
279
279
export function expressToOpenAPIPath ( expressPath : string ) {
280
280
const tokens = pathToRegexp . parse ( expressPath )
281
281
return tokens
282
- . map ( d => ( _ . isString ( d ) ? d : `${ d . prefix } {${ d . name } }` ) )
282
+ . map ( d => ( _ . isString ( d ) ? d : `${ d . prefix } {${ d . name } }` ) )
283
283
. join ( '' )
284
284
}
285
285
@@ -289,7 +289,7 @@ export function expressToOpenAPIPath(expressPath: string) {
289
289
*/
290
290
function isRequired ( meta : { required ?: boolean } , route : IRoute ) {
291
291
const globalRequired = _ . get ( route . options , 'defaults.paramOptions.required' )
292
- return globalRequired ? meta . required !== false : ! ! meta . required
292
+ return globalRequired ? meta . required !== false : ! ! meta . required
293
293
}
294
294
295
295
/**
@@ -300,8 +300,12 @@ function getParamSchema(
300
300
param : ParamMetadataArgs
301
301
) : oa . SchemaObject | oa . ReferenceObject {
302
302
const { explicitType, index, object, method } = param
303
- const reflectedTypes = Reflect . getMetadata ( 'design:paramtypes' , object , method ) ;
304
- if ( reflectedTypes . length <= index ) return { } ;
303
+ const reflectedTypes = Reflect . getMetadata (
304
+ 'design:paramtypes' ,
305
+ object ,
306
+ method
307
+ )
308
+ if ( reflectedTypes . length <= index ) return { }
305
309
const type = reflectedTypes [ index ]
306
310
if ( _ . isFunction ( type ) && type . name === 'Array' ) {
307
311
const items = explicitType
0 commit comments