Skip to content

Commit 0b6f524

Browse files
committed
fix: core/request
1 parent e93992c commit 0b6f524

File tree

6 files changed

+8
-11
lines changed

6 files changed

+8
-11
lines changed

bin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ program
1919
.option('--exportServices <value>', 'Write services to disk', true)
2020
.option('--exportModels <value>', 'Write models to disk', true)
2121
.option('--exportSchemas <value>', 'Write schemas to disk', false)
22-
.option('--apiAlias <value>', 'your api alias here')
22+
.option('--apiAlias <value>', 'your api alias here', '../core/request')
2323
.parse(process.argv);
2424

2525
const OpenAPI = require(path.resolve(__dirname, '../dist/index.js'));

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openapi-typescript-codegen",
3-
"version": "0.5.7",
3+
"version": "0.6.0",
44
"description": "NodeJS library that generates Typescript or Javascript clients based on the OpenAPI specification.",
55
"author": "zengxiangda",
66
"homepage": "http://gitlab.psf-dev.com/frontend/openapi-typescritp-codegen",
@@ -28,8 +28,8 @@
2828
],
2929
"maintainers": [
3030
{
31-
"name": "Ferdi Koomen",
32-
"email": "info@madebyferdi.com"
31+
"name": "dylan",
32+
"email": "dylan_zeng92@qq.com"
3333
}
3434
],
3535
"main": "dist/index.js",

src/templates/exportService.hbs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
import type { {{{this}}} } from '../models/{{{this}}}';
66
{{/each}}
77
{{/if}}
8-
{{#if alias }}
98
import { request as __request } from '{{alias}}';
10-
{{/if}}
119
{{#if @root.useVersion}}
1210
import { OpenAPI } from '../core/OpenAPI';
1311
{{/if}}

src/utils/writeClient.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function writeClient(
3939
): Promise<void> {
4040
const outputPath = path.resolve(process.cwd(), output);
4141
// cancel write core
42-
const outputPathCore = alias ? '' : path.resolve(outputPath, 'core');
42+
const outputPathCore = path.resolve(outputPath, 'core');
4343
const outputPathModels = path.resolve(outputPath, 'models');
4444
const outputPathSchemas = path.resolve(outputPath, 'schemas');
4545
const outputPathServices = path.resolve(outputPath, 'services');
@@ -53,8 +53,7 @@ export async function writeClient(
5353
await rmdir(outputPathServices);
5454
await mkdir(outputPath);
5555
const coreExists = await exists(outputPathCore)
56-
console.log('outputPathCore', outputPathCore,coreExists )
57-
if (exportCore && outputPathCore && !coreExists) {
56+
if (exportCore && outputPathCore) {
5857
await mkdir(outputPathCore);
5958
await writeClientCore(client, templates, outputPathCore, httpClient);
6059
}

src/utils/writeClientServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const VERSION_TEMPLATE_STRING = 'OpenAPI.VERSION';
2020
export async function writeClientServices(services: Service[], templates: Templates, outputPath: string, httpClient: HttpClient, useUnionTypes: boolean, useOptions: boolean, alias: string): Promise<void> {
2121
for (const service of services) {
2222
const file = path.resolve(outputPath, `${service.name}.ts`);
23-
service.alias = alias
23+
if (alias) service.alias = alias
2424
const useVersion = service.operations.some(operation => operation.path.includes(VERSION_TEMPLATE_STRING));
2525
const templateResult = templates.exports.service({
2626
...service,

0 commit comments

Comments
 (0)