File tree 3 files changed +69
-44
lines changed
3 files changed +69
-44
lines changed Original file line number Diff line number Diff line change @@ -83,18 +83,22 @@ export class OpenAPIFramework {
83
83
const absolutePath = path . resolve ( origCwd , filePath ) ;
84
84
if ( fs . existsSync ( absolutePath ) ) {
85
85
// Get document, or throw exception on error
86
- return $refParser . mode === 'dereference'
87
- ? $RefParser . dereference ( absolutePath )
88
- : $RefParser . bundle ( absolutePath ) ;
86
+ const doc =
87
+ $refParser . mode === 'dereference'
88
+ ? $RefParser . dereference ( absolutePath )
89
+ : $RefParser . bundle ( absolutePath ) ;
90
+ return doc as Promise < OpenAPIV3 . Document > ;
89
91
} else {
90
92
throw new Error (
91
93
`${ this . loggingPrefix } spec could not be read at ${ filePath } ` ,
92
94
) ;
93
95
}
94
96
}
95
- return $refParser . mode === 'dereference'
96
- ? $RefParser . dereference ( filePath )
97
- : $RefParser . bundle ( filePath ) ;
97
+ const doc =
98
+ $refParser . mode === 'dereference'
99
+ ? $RefParser . dereference ( filePath )
100
+ : $RefParser . bundle ( filePath ) ;
101
+ return doc as Promise < OpenAPIV3 . Document > ;
98
102
}
99
103
100
104
private sortApiDocTags ( apiDoc : OpenAPIV3 . Document ) : void {
Original file line number Diff line number Diff line change @@ -331,9 +331,8 @@ export class SchemaPreprocessor {
331
331
} ;
332
332
333
333
for ( const option of options ) {
334
- ancestor . _discriminator . validators [ option ] = this . ajv . compile (
335
- newSchema ,
336
- ) ;
334
+ ancestor . _discriminator . validators [ option ] =
335
+ this . ajv . compile ( newSchema ) ;
337
336
}
338
337
}
339
338
//reset data
@@ -477,10 +476,18 @@ export class SchemaPreprocessor {
477
476
if ( v === parameters ) return ;
478
477
v . parameters = v . parameters || [ ] ;
479
478
479
+ const match = (
480
+ pathParam : OpenAPIV3 . ReferenceObject | OpenAPIV3 . ParameterObject ,
481
+ opParam : OpenAPIV3 . ReferenceObject | OpenAPIV3 . OperationObject ,
482
+ ) =>
483
+ // if name or ref exists and are equal
484
+ ( opParam [ 'name' ] && opParam [ 'name' ] === pathParam [ 'name' ] ) ||
485
+ ( opParam [ '$ref' ] && opParam [ '$ref' ] === pathParam [ '$ref' ] ) ;
486
+
480
487
// Add Path level query param to list ONLY if there is not already an operation-level query param by the same name.
481
488
for ( const param of parameters ) {
482
- if ( ! ( v . parameters . some ( vparam => vparam [ "name" ] === param [ "name" ] ) ) ) {
483
- v . parameters . push ( param ) ;
489
+ if ( ! v . parameters . some ( ( vparam ) => match ( param , vparam ) ) ) {
490
+ v . parameters . push ( param ) ;
484
491
}
485
492
}
486
493
}
You can’t perform that action at this time.
0 commit comments