Skip to content

Commit 5108da4

Browse files
author
sunlei
committed
front datasource
1 parent 4953e7b commit 5108da4

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

server/node-service/src/plugins/front/index.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ import spec from "./front.spec.json";
99
const dataSourceConfig = {
1010
type: "dataSource",
1111
params: [
12-
{
13-
type: "groupTitle",
14-
key: "http",
15-
label: "Api Token Auth",
16-
},
1712
{
1813
type: "password",
1914
key: "http.value",
@@ -24,7 +19,10 @@ const dataSourceConfig = {
2419

2520
const parseOptions: ParseOpenApiOptions = {
2621
actionLabel: (method: string, path: string, operation: OpenAPI.Operation) => {
27-
return _.upperFirst(operation.operationId || "");
22+
return operation.summary || "";
23+
},
24+
actionDescription: (method: string, path: string, operation: OpenAPI.Operation) => {
25+
return operation.description || "";
2826
},
2927
};
3028

server/node-service/src/plugins/openApi/parse.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import _ from "lodash";
1313
// @ts-ignore
1414
import SwaggerClient from "swagger-client";
1515
import {
16+
appendCategories,
1617
isOas3HttpMethods,
1718
isOas3RefObject,
1819
isSwagger2HttpMethods,
@@ -239,7 +240,7 @@ export async function parseOpenApi(
239240
return;
240241
}
241242

242-
const operation = (pathSpec as any)[httpMethod];
243+
const operation = (pathSpec as any)[httpMethod] as OpenAPI.Operation;
243244
if (!operation) {
244245
return;
245246
}
@@ -250,6 +251,14 @@ export async function parseOpenApi(
250251
return;
251252
}
252253

254+
const { tags } = operation;
255+
if (tags) {
256+
appendCategories(
257+
categories,
258+
tags.map((i) => ({ label: _.upperFirst(i), value: i }))
259+
);
260+
}
261+
253262
// params
254263
let params: ActionParamConfig[] = [];
255264

server/node-service/src/plugins/openApi/util.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,12 @@ export function mergeCategories(a: ActionCategory[], b: ActionCategory[]) {
410410
});
411411
return ret;
412412
}
413+
414+
export function appendCategories(a: ActionCategory[], b: ActionCategory[]) {
415+
b.forEach((i) => {
416+
if (a.find((j) => i.value === j.value)) {
417+
return;
418+
}
419+
a.push(i);
420+
});
421+
}

0 commit comments

Comments
 (0)