Skip to content

Commit 7bac37c

Browse files
committed
fix: 修复 Oas 类型联合错误
1 parent 5e14f48 commit 7bac37c

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/generator.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ import path from 'path';
55
import { generateApi } from 'swagger-typescript-api';
66
import { defineConfig } from './configure';
77
import { axiosImportDefault, helpersImport, templatesDir } from './const';
8-
import { StrictConfig, Oas, UserConfig } from './types';
8+
import { StrictConfig, Oas, UserConfig, OasAsUrl, OasAsSpec } from './types';
99
import { exitError, normalizeError, tryCatch } from './utils';
1010

1111
export async function generateItem(oas: Oas, config: StrictConfig) {
12-
const { name, url, spec, axiosImport: axiosImportScope } = oas;
12+
const { name, axiosImport: axiosImportScope } = oas;
1313
const { cwd, dest, axiosImport: axiosImportGlobal, unwrapResponseData } = config;
1414
const axiosImport = axiosImportScope || axiosImportGlobal || axiosImportDefault;
1515
const { files } = await generateApi({
1616
name,
17-
url,
18-
spec,
17+
url: (oas as OasAsUrl).url,
18+
spec: (oas as OasAsSpec).spec,
1919
output: false,
2020
httpClientType: 'axios',
2121
templates: templatesDir,

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export * from './generator';
22
export * from './configure';
3+
export * from './types';

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ interface OasBase {
1010
axiosImport?: string;
1111
}
1212

13-
interface OasAsUrl extends OasBase {
13+
export interface OasAsUrl extends OasBase {
1414
url: string;
1515
}
1616

17-
interface OasAsSpec extends OasBase {
17+
export interface OasAsSpec extends OasBase {
1818
spec: import('swagger-schema-official').Spec;
1919
}
2020

21-
export interface Oas extends OasAsUrl, OasAsSpec {}
21+
export type Oas = OasAsUrl | OasAsSpec;
2222

2323
export interface UserConfig {
2424
/**

0 commit comments

Comments
 (0)