From edaffe57a3a05c6d00a63ab80e26654427c516db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E6=B3=BD=E9=94=B4?= Date: Thu, 15 May 2025 18:24:01 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9AoperationId.replace(/[^a-zA-Z]+$/g?= =?UTF-8?q?,=20'')=20=20//=203.=20=E7=A7=BB=E9=99=A4=E5=B0=BE=E9=83=A8?= =?UTF-8?q?=E7=9A=84=E9=9D=9E=E5=AD=97=E6=AF=8D=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 23 ++++++----------------- src/openApi/v3/parser/getOperationName.ts | 1 + src/utils/postProcessServiceOperations.ts | 14 +++++++------- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/package.json b/package.json index 35068f294..1f88aa939 100644 --- a/package.json +++ b/package.json @@ -1,15 +1,15 @@ { - "name": "openapi-typescript-codegen", - "version": "0.29.0", + "name": "openapi-typescript-codegen-leyiya", + "version": "0.33.0", "description": "Library that generates Typescript clients based on the OpenAPI specification.", "author": "Ferdi Koomen", - "homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen", + "homepage": "https://github.com/a-leyi/openapi-typescript-codegen", "repository": { "type": "git", - "url": "git+https://github.com/ferdikoomen/openapi-typescript-codegen.git" + "url": "git+https://github.com/a-leyi/openapi-typescript-codegen.git" }, "bugs": { - "url": "https://github.com/ferdikoomen/openapi-typescript-codegen/issues" + "url": "https://github.com/a-leyi/openapi-typescript-codegen/issues" }, "license": "MIT", "keywords": [ @@ -55,7 +55,7 @@ "test:e2e": "jest --selectProjects E2E --runInBand --verbose", "eslint": "eslint .", "eslint:fix": "eslint . --fix", - "prepare": "npm run clean && npm run release", + "prepare": "", "codecov": "codecov --token=66c30c23-8954-4892-bef9-fbaed0a2e42b", "docker": "docker build -t eeelenbaas/openapi-typescript-codegen ." }, @@ -67,17 +67,6 @@ "handlebars": "^4.7.8" }, "devDependencies": { - "@angular-devkit/build-angular": "19.2.10", - "@angular/animations": "17.3.3", - "@angular/cli": "17.3.3", - "@angular/common": "17.3.3", - "@angular/compiler": "17.3.3", - "@angular/compiler-cli": "17.3.3", - "@angular/core": "17.3.3", - "@angular/forms": "17.3.3", - "@angular/platform-browser": "17.3.3", - "@angular/platform-browser-dynamic": "17.3.3", - "@angular/router": "17.3.3", "@babel/cli": "7.24.8", "@babel/core": "7.26.7", "@babel/preset-env": "7.26.0", diff --git a/src/openApi/v3/parser/getOperationName.ts b/src/openApi/v3/parser/getOperationName.ts index 124bf66bd..e818885b3 100644 --- a/src/openApi/v3/parser/getOperationName.ts +++ b/src/openApi/v3/parser/getOperationName.ts @@ -11,6 +11,7 @@ export const getOperationName = (url: string, method: string, operationId?: stri operationId .replace(/^[^a-zA-Z]+/g, '') .replace(/[^\w\-]+/g, '-') + .replace(/[^a-zA-Z]+$/g, '') // 3. 移除尾部的非字母字符 .trim() ); } diff --git a/src/utils/postProcessServiceOperations.ts b/src/utils/postProcessServiceOperations.ts index 5b88a5b21..211f3c301 100644 --- a/src/utils/postProcessServiceOperations.ts +++ b/src/utils/postProcessServiceOperations.ts @@ -3,7 +3,7 @@ import type { Service } from '../client/interfaces/Service'; import { flatMap } from './flatMap'; export const postProcessServiceOperations = (service: Service): Operation[] => { - const names = new Map(); + // const names = new Map(); return service.operations.map(operation => { const clone = { ...operation }; @@ -14,12 +14,12 @@ export const postProcessServiceOperations = (service: Service): Operation[] => { clone.imports.push(...flatMap(clone.results, result => result.imports)); // Check if the operation name is unique, if not then prefix this with a number - const name = clone.name; - const index = names.get(name) || 0; - if (index > 0) { - clone.name = `${name}${index}`; - } - names.set(name, index + 1); + // const name = clone.name; + // const index = names.get(name) || 0; + // if (index > 0) { + // clone.name = `${name}${index}`; + // } + // names.set(name, index + 1); return clone; });