From bf23903226270ff45f9d64667b4db1c9b848f3ed Mon Sep 17 00:00:00 2001 From: fairking <13495631+fairking@users.noreply.github.com> Date: Wed, 28 Jan 2026 15:06:20 +0200 Subject: [PATCH 1/2] Wrong property type generated on binary #209 --- src/utils.ts | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/src/utils.ts b/src/utils.ts index 14a9c97..aa5d967 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -41,8 +41,8 @@ export function getGenericsClassNames(definitionClassName: string): string { const TClassName = definitionClassName.slice(splitIndex + 1, -1) if (isDefinedGenericTypes(interfaceClassName)) { str = interfaceClassName === 'IDictionary' || interfaceClassName === 'Dictionary' - ? `${interfaceClassName}` - : `${interfaceClassName}<${refClassName(TClassName)}>` + ? `${interfaceClassName}` + : `${interfaceClassName}<${refClassName(TClassName)}>` } else { str = trimString(RemoveSpecialCharacters(definitionClassName), '_', 'right') @@ -81,40 +81,47 @@ export function validRefTypeName(str: string) { return reg.test(str) } -export function isBaseType(s: string) { +export function isBaseType(s: string): boolean { return ['boolean', 'number', 'string', 'Date', 'any'].includes(s) } -export function toBaseType(s: string, format?: string) { +export function toBaseType(s: string, format?: string): string { if (s === undefined || s === null || s.length === 0) { return 'any | null' } + + const s_lower = s.toLowerCase() + const format_lower = format?.toLowerCase() + let result = '' - switch (s) { + switch (s_lower) { case 'boolean': case 'bool': - case 'Boolean': result = 'boolean' break case 'array': result = '[]' break - case 'Int64': - case 'Int32': + case 'int64': + case 'int32': case 'int': case 'integer': case 'number': - result = format === 'int64' || format === 'Int64' || format === 'long' ? 'string' : 'number' + result = format_lower === 'int64' || format_lower === 'long' ? 'string' : 'number' break - case 'Guid': - case 'String': - case 'string': case 'uuid': - switch (format) { + case 'guid': + result = 'string' + break + case 'string': + switch (format_lower) { case 'date': case 'date-time': result = 'Date' break + case 'binary': + result = 'any' + break default: result = 'string' } @@ -161,7 +168,7 @@ export function trimString(str: string, char: string, type: string) { return str.replace(/^\s+|\s+$/g, '') } -/** +/** * 泛型类名提取数组 * A> => [A,B,C] **/ @@ -300,4 +307,4 @@ export function getValidationModel(propName: string, prop: IDefinitionProperty, hasValidationRules = true } return hasValidationRules ? validationModel : null -} \ No newline at end of file +} From dcaff99263b4d96a7a3469ae181f51b2c6efc8e5 Mon Sep 17 00:00:00 2001 From: fairking <13495631+fairking@users.noreply.github.com> Date: Wed, 28 Jan 2026 16:35:23 +0200 Subject: [PATCH 2/2] Fixed "AxiosInstance" is not exported by "node_modules/axios/index.js", imported by "src/api/member_area.ts". --- src/templates/serviceHeader.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/templates/serviceHeader.ts b/src/templates/serviceHeader.ts index af35a20..4e89f55 100644 --- a/src/templates/serviceHeader.ts +++ b/src/templates/serviceHeader.ts @@ -11,7 +11,8 @@ export function serviceHeader(options: ISwaggerOptions) { return `/** Generate by swagger-axios-codegen */ /* eslint-disable */ // @ts-nocheck - import axiosStatic, { type AxiosInstance, type AxiosRequestConfig } from 'axios'; + import axiosStatic from 'axios'; + import type { AxiosInstance, AxiosRequestConfig } from 'axios'; ${classTransformerImport} @@ -63,7 +64,8 @@ export function customerServiceHeader(options: ISwaggerOptions) { return `/** Generate by swagger-axios-codegen */ // @ts-nocheck /* eslint-disable */ - import axiosStatic, { type AxiosInstance, type AxiosRequestConfig } from 'axios'; + import axiosStatic from 'axios'; + import type { AxiosInstance, AxiosRequestConfig } from 'axios'; export interface IRequestOptions extends AxiosRequestConfig { /**