File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
packages/rtk-query-codegen-openapi/src Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -92,9 +92,10 @@ export async function generateApi(
92
92
flattenArg = false ,
93
93
useEnumType = false ,
94
94
mergeReadWriteOnly = false ,
95
+ httpResolverOptions,
95
96
} : GenerationOptions
96
97
) {
97
- const v3Doc = await getV3Doc ( spec ) ;
98
+ const v3Doc = await getV3Doc ( spec , httpResolverOptions ) ;
98
99
99
100
const apiGen = new ApiGenerator ( v3Doc , {
100
101
unionUndefined,
Original file line number Diff line number Diff line change
1
+ import type SwaggerParser from '@apidevtools/swagger-parser' ;
1
2
import type { OpenAPIV3 } from 'openapi-types' ;
2
3
3
4
export type OperationDefinition = {
@@ -77,6 +78,10 @@ export interface CommonOptions {
77
78
* `true` will not generate separate types for read-only and write-only properties.
78
79
*/
79
80
mergeReadWriteOnly ?: boolean ;
81
+ /**
82
+ * HTTPResolverOptions object that is passed to the SwaggerParser bundle function.
83
+ */
84
+ httpResolverOptions ?: SwaggerParser . HTTPResolverOptions ;
80
85
}
81
86
82
87
export type TextMatcher = string | RegExp | ( string | RegExp ) [ ] ;
Original file line number Diff line number Diff line change @@ -3,9 +3,18 @@ import type { OpenAPIV3 } from 'openapi-types';
3
3
// @ts -ignore
4
4
import converter from 'swagger2openapi' ;
5
5
6
- export async function getV3Doc ( spec : string ) : Promise < OpenAPIV3 . Document > {
7
- const doc = await SwaggerParser . bundle ( spec ) ;
6
+ export async function getV3Doc (
7
+ spec : string ,
8
+ httpResolverOptions ?: SwaggerParser . HTTPResolverOptions
9
+ ) : Promise < OpenAPIV3 . Document > {
10
+ const doc = await SwaggerParser . bundle ( spec , {
11
+ resolve : {
12
+ http : httpResolverOptions ,
13
+ } ,
14
+ } ) ;
15
+
8
16
const isOpenApiV3 = 'openapi' in doc && doc . openapi . startsWith ( '3' ) ;
17
+
9
18
if ( isOpenApiV3 ) {
10
19
return doc as OpenAPIV3 . Document ;
11
20
} else {
You can’t perform that action at this time.
0 commit comments