@lark-apaas/devtool-kits 0.1.0-alpha.0 → 0.1.0-alpha.2
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/README.md +1 -1
- package/dist/index.cjs +17 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +17 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -160,7 +160,7 @@ Enhances OpenAPI/Swagger documentation with source code information.
|
|
|
160
160
|
- Caching support for better performance
|
|
161
161
|
|
|
162
162
|
**Routes:**
|
|
163
|
-
- `GET /dev/openapi` - Get enhanced OpenAPI documentation
|
|
163
|
+
- `GET /dev/openapi.json` - Get enhanced OpenAPI documentation
|
|
164
164
|
|
|
165
165
|
**Example:**
|
|
166
166
|
```typescript
|
package/dist/index.cjs
CHANGED
|
@@ -28507,8 +28507,8 @@ __name(transformOpenapiPaths, "transformOpenapiPaths");
|
|
|
28507
28507
|
// src/middlewares/openapi/services.ts
|
|
28508
28508
|
async function enhanceOpenApiWithSourceInfo(options = {}) {
|
|
28509
28509
|
const startTime = Date.now();
|
|
28510
|
-
const openapiPath = options.openapiPath || import_node_path3.default.resolve(__dirname, "
|
|
28511
|
-
const serverDir = options.serverDir || import_node_path3.default.resolve(__dirname, "
|
|
28510
|
+
const openapiPath = options.openapiPath || import_node_path3.default.resolve(__dirname, "../client/src/api/gen/openapi.json");
|
|
28511
|
+
const serverDir = options.serverDir || import_node_path3.default.resolve(__dirname, "../server");
|
|
28512
28512
|
const writeFile = options.writeFile !== false;
|
|
28513
28513
|
let openapi;
|
|
28514
28514
|
if (options.openapiData) {
|
|
@@ -28621,7 +28621,7 @@ function extractControllerMetadata(sourceFile, filePath) {
|
|
|
28621
28621
|
__name(extractControllerMetadata, "extractControllerMetadata");
|
|
28622
28622
|
|
|
28623
28623
|
// src/middlewares/openapi/controller.ts
|
|
28624
|
-
function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
28624
|
+
function createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir) {
|
|
28625
28625
|
let cache = null;
|
|
28626
28626
|
return async (_req, res, context) => {
|
|
28627
28627
|
try {
|
|
@@ -28634,7 +28634,8 @@ function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
|
28634
28634
|
if (enableEnhancement && context.isDev) {
|
|
28635
28635
|
const { openapi: enhancedPayload, stats } = await enhanceOpenApiWithSourceInfo({
|
|
28636
28636
|
openapiData: payload,
|
|
28637
|
-
writeFile: false
|
|
28637
|
+
writeFile: false,
|
|
28638
|
+
serverDir: serverDir || context.rootDir
|
|
28638
28639
|
});
|
|
28639
28640
|
payload = enhancedPayload;
|
|
28640
28641
|
console.log(`[OpenAPI] Enhanced in ${stats.duration}ms (${stats.endpointsEnhanced} endpoints)`);
|
|
@@ -28657,10 +28658,11 @@ function createOpenapiHandler(openapiFilePath, enableEnhancement) {
|
|
|
28657
28658
|
__name(createOpenapiHandler, "createOpenapiHandler");
|
|
28658
28659
|
|
|
28659
28660
|
// src/middlewares/openapi/router.ts
|
|
28660
|
-
function createOpenapiRouter(
|
|
28661
|
+
function createOpenapiRouter(options, context) {
|
|
28662
|
+
const { openapiFilePath, enableEnhancement, serverDir } = options;
|
|
28661
28663
|
const router = import_express.default.Router();
|
|
28662
|
-
const handler = createOpenapiHandler(openapiFilePath, enableEnhancement);
|
|
28663
|
-
router.get("/", (req, res) => handler(req, res, context));
|
|
28664
|
+
const handler = createOpenapiHandler(openapiFilePath, enableEnhancement, serverDir);
|
|
28665
|
+
router.get("/openapi.json", (req, res) => handler(req, res, context));
|
|
28664
28666
|
return router;
|
|
28665
28667
|
}
|
|
28666
28668
|
__name(createOpenapiRouter, "createOpenapiRouter");
|
|
@@ -28669,19 +28671,23 @@ __name(createOpenapiRouter, "createOpenapiRouter");
|
|
|
28669
28671
|
var OPENAPI_ROUTES = [
|
|
28670
28672
|
{
|
|
28671
28673
|
method: "GET",
|
|
28672
|
-
path: "/",
|
|
28674
|
+
path: "/openapi.json",
|
|
28673
28675
|
description: "Serve enhanced OpenAPI specification with source code references"
|
|
28674
28676
|
}
|
|
28675
28677
|
];
|
|
28676
28678
|
function createOpenapiMiddleware(options) {
|
|
28677
|
-
const { openapiFilePath, enableEnhancement = true } = options;
|
|
28679
|
+
const { openapiFilePath, enableEnhancement = true, serverDir } = options;
|
|
28678
28680
|
return {
|
|
28679
28681
|
name: "openapi",
|
|
28680
|
-
mountPath: "/
|
|
28682
|
+
mountPath: "/dev",
|
|
28681
28683
|
routes: OPENAPI_ROUTES,
|
|
28682
28684
|
enabled: /* @__PURE__ */ __name((context) => context.isDev, "enabled"),
|
|
28683
28685
|
createRouter: /* @__PURE__ */ __name((context) => {
|
|
28684
|
-
return createOpenapiRouter(
|
|
28686
|
+
return createOpenapiRouter({
|
|
28687
|
+
openapiFilePath,
|
|
28688
|
+
enableEnhancement,
|
|
28689
|
+
serverDir
|
|
28690
|
+
}, context);
|
|
28685
28691
|
}, "createRouter")
|
|
28686
28692
|
};
|
|
28687
28693
|
}
|