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(
9292 flattenArg = false ,
9393 useEnumType = false ,
9494 mergeReadWriteOnly = false ,
95+ httpResolverOptions,
9596 } : GenerationOptions
9697) {
97- const v3Doc = await getV3Doc ( spec ) ;
98+ const v3Doc = await getV3Doc ( spec , httpResolverOptions ) ;
9899
99100 const apiGen = new ApiGenerator ( v3Doc , {
100101 unionUndefined,
Original file line number Diff line number Diff line change 1+ import type SwaggerParser from '@apidevtools/swagger-parser' ;
12import type { OpenAPIV3 } from 'openapi-types' ;
23
34export type OperationDefinition = {
@@ -77,6 +78,10 @@ export interface CommonOptions {
7778 * `true` will not generate separate types for read-only and write-only properties.
7879 */
7980 mergeReadWriteOnly ?: boolean ;
81+ /**
82+ * HTTPResolverOptions object that is passed to the SwaggerParser bundle function.
83+ */
84+ httpResolverOptions ?: SwaggerParser . HTTPResolverOptions ;
8085}
8186
8287export 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';
33// @ts -ignore
44import converter from 'swagger2openapi' ;
55
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+
816 const isOpenApiV3 = 'openapi' in doc && doc . openapi . startsWith ( '3' ) ;
17+
918 if ( isOpenApiV3 ) {
1019 return doc as OpenAPIV3 . Document ;
1120 } else {
You can’t perform that action at this time.
0 commit comments