@lark-apaas/devtool-kits 1.2.21 → 1.2.22-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +20 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1392,11 +1392,30 @@ __name(createOpenapiHandler, "createOpenapiHandler");
|
|
|
1392
1392
|
import fs4 from "fs/promises";
|
|
1393
1393
|
import crypto2 from "crypto";
|
|
1394
1394
|
var MAX_REF_DEPTH = 5;
|
|
1395
|
+
var EMPTY_OPENAPI_SPEC = {
|
|
1396
|
+
openapi: "3.0.0",
|
|
1397
|
+
info: {
|
|
1398
|
+
title: "\u5F00\u653E API",
|
|
1399
|
+
version: "0.0.0"
|
|
1400
|
+
},
|
|
1401
|
+
paths: {},
|
|
1402
|
+
components: {
|
|
1403
|
+
schemas: {}
|
|
1404
|
+
}
|
|
1405
|
+
};
|
|
1395
1406
|
function createOpenapiSpecHandler(openapiSpecFilePath) {
|
|
1396
1407
|
let cache = null;
|
|
1397
1408
|
return async (_req, res, context) => {
|
|
1398
1409
|
try {
|
|
1399
|
-
|
|
1410
|
+
let fileBuffer;
|
|
1411
|
+
try {
|
|
1412
|
+
fileBuffer = await fs4.readFile(openapiSpecFilePath, "utf-8");
|
|
1413
|
+
} catch (err) {
|
|
1414
|
+
if (err?.code === "ENOENT") {
|
|
1415
|
+
return res.json(EMPTY_OPENAPI_SPEC);
|
|
1416
|
+
}
|
|
1417
|
+
throw err;
|
|
1418
|
+
}
|
|
1400
1419
|
const currentHash = crypto2.createHash("md5").update(fileBuffer).digest("hex");
|
|
1401
1420
|
if (cache && cache.fileHash === currentHash) {
|
|
1402
1421
|
return res.json(cache.data);
|