Skip to content

Commit

Permalink
fix: 修复 Oas 类型联合错误
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudcome committed Mar 16, 2023
1 parent 5e14f48 commit 7bac37c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import path from 'path';
import { generateApi } from 'swagger-typescript-api';
import { defineConfig } from './configure';
import { axiosImportDefault, helpersImport, templatesDir } from './const';
import { StrictConfig, Oas, UserConfig } from './types';
import { StrictConfig, Oas, UserConfig, OasAsUrl, OasAsSpec } from './types';
import { exitError, normalizeError, tryCatch } from './utils';

export async function generateItem(oas: Oas, config: StrictConfig) {
const { name, url, spec, axiosImport: axiosImportScope } = oas;
const { name, axiosImport: axiosImportScope } = oas;
const { cwd, dest, axiosImport: axiosImportGlobal, unwrapResponseData } = config;
const axiosImport = axiosImportScope || axiosImportGlobal || axiosImportDefault;
const { files } = await generateApi({
name,
url,
spec,
url: (oas as OasAsUrl).url,
spec: (oas as OasAsSpec).spec,
output: false,
httpClientType: 'axios',
templates: templatesDir,
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './generator';
export * from './configure';
export * from './types';
6 changes: 3 additions & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ interface OasBase {
axiosImport?: string;
}

interface OasAsUrl extends OasBase {
export interface OasAsUrl extends OasBase {
url: string;
}

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

export interface Oas extends OasAsUrl, OasAsSpec {}
export type Oas = OasAsUrl | OasAsSpec;

export interface UserConfig {
/**
Expand Down

0 comments on commit 7bac37c

Please sign in to comment.