Skip to content

Commit

Permalink
Merge pull request #92 from long-woo/dev
Browse files Browse the repository at this point in the history
fix: 修复 action 重名,导致接口丢失
  • Loading branch information
long-woo authored Nov 29, 2024
2 parents 4bdc3d2 + 34b1b74 commit 75ce468
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ Create a `myPlugin.ts` file:

```ts
// 引用模块
// import { start } from 'https://deno.land/x/[email protected].0/mod.ts'
import { start } from 'jsr:@loongwoo/stc@^2.6.0'
// import { start } from 'https://deno.land/x/[email protected].1/mod.ts'
import { start } from 'jsr:@loongwoo/stc@^2.6.1'

// Defining plugins
const myPlugin: IPlugin = {
Expand Down
4 changes: 2 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@loongwoo/stc",
"version": "2.6.0",
"version": "2.6.1",
"exports": "./mod.ts",
"tasks": {
"pack": "deno run -A src/pack.ts",
"dev": "deno task pack && deno run -A --watch=src src/main.ts --url='https://petstore3.swagger.io/api/v3/openapi.json' --lang=ts",
"serve": "deno run -A --watch=src src/service.ts",
"version": "echo '2.6.0' > release/version",
"version": "echo '2.6.1' > release/version",
"build:npm": "deno run -A src/npm/build.ts",
"build:mac": "deno compile -A --target x86_64-apple-darwin --output release/stc src/main.ts",
"build:mac-m": "deno compile -A --target aarch64-apple-darwin --output release/stc-m src/main.ts",
Expand Down
3 changes: 3 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,11 @@ export const getApiPath = (
if (url.includes("?")) url = url.slice(0, url.indexOf("?"));

const currentMethod = methods[method];

// 方法名
let name = currentMethod.operationId ??
getMethodName(url, options!.conjunction!);

if (!name) {
Logs.error(getT("$t(path.notName)", { url, method }));
return;
Expand All @@ -466,6 +468,7 @@ export const getApiPath = (
options?.tag,
);

name = `${value.tag}@${name}`;
pathMap.set(name, value);
});
});
Expand Down
2 changes: 1 addition & 1 deletion src/npm/pkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@loongwoo/stc",
"version": "2.6.0",
"version": "2.6.1",
"description": "A tool for converting OpenApi/Swagger/Apifox into code.",
"type": "module",
"module": "esm/mod.js",
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,8 @@ const getActionFiles = (data: Map<string, IPathVirtualProperty>) => {
return;
}

const _apiData = generateApi(item, key);
const actionName = key.slice(key.indexOf("@") + 1);
const _apiData = generateApi(item, actionName);
const _actionFile = _actionFileMap.get(_tag);

if (_actionFile) {
Expand Down

0 comments on commit 75ce468

Please sign in to comment.