sprint-es 0.0.63 → 0.0.65
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/cjs/index.cjs +42 -3
- package/dist/esm/index.js +42 -3
- package/dist/types/sprint.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.cjs
CHANGED
|
@@ -167,12 +167,15 @@ class Sprint {
|
|
|
167
167
|
res.json(this.generateOpenAPISpec());
|
|
168
168
|
});
|
|
169
169
|
if (this.openapi.swaggerUi.enabled) {
|
|
170
|
+
console.log(`[Sprint] Loading Swagger UI...`);
|
|
170
171
|
import("swagger-ui-express").then((swaggerUi) => {
|
|
172
|
+
console.log(`[Sprint] Swagger UI imported successfully`);
|
|
171
173
|
this.app.use("/swagger", swaggerUi.serve, swaggerUi.setup(void 0, {
|
|
172
174
|
swaggerUrl: "/openapi.json"
|
|
173
175
|
}));
|
|
174
|
-
|
|
175
|
-
|
|
176
|
+
console.log(`[Sprint] Swagger UI mounted at /swagger`);
|
|
177
|
+
}).catch((err) => {
|
|
178
|
+
console.error(`[Sprint] ⚠️ swagger-ui-express error:`, err);
|
|
176
179
|
});
|
|
177
180
|
}
|
|
178
181
|
}
|
|
@@ -425,10 +428,16 @@ class Sprint {
|
|
|
425
428
|
}
|
|
426
429
|
generateOpenAPISpec() {
|
|
427
430
|
const paths = {};
|
|
431
|
+
let zod;
|
|
432
|
+
try {
|
|
433
|
+
zod = require("zod");
|
|
434
|
+
} catch (e) {
|
|
435
|
+
console.warn("[Sprint] Zod not available for OpenAPI schema generation");
|
|
436
|
+
}
|
|
428
437
|
for (const route of this.registeredRoutes || []) {
|
|
429
438
|
const method = route.method.toLowerCase();
|
|
430
439
|
if (!paths[route.path]) paths[route.path] = {};
|
|
431
|
-
|
|
440
|
+
const routeSpec = {
|
|
432
441
|
summary: "Auto generated by Sprint",
|
|
433
442
|
responses: {
|
|
434
443
|
"200": {
|
|
@@ -436,6 +445,36 @@ class Sprint {
|
|
|
436
445
|
}
|
|
437
446
|
}
|
|
438
447
|
};
|
|
448
|
+
if (route.schema?.body && zod) {
|
|
449
|
+
try {
|
|
450
|
+
routeSpec.requestBody = {
|
|
451
|
+
content: {
|
|
452
|
+
"application/json": {
|
|
453
|
+
schema: route.schema.body.schema || route.schema.body._def?.schema?.toJSON?.() || {}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
} catch (e) {
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
if (route.schema?.queryParams && zod) {
|
|
461
|
+
try {
|
|
462
|
+
routeSpec.parameters = [];
|
|
463
|
+
const querySchema = route.schema.queryParams.schema || route.schema.queryParams._def?.schema;
|
|
464
|
+
if (querySchema?.shape) {
|
|
465
|
+
for (const [key, value] of Object.entries(querySchema.shape)) {
|
|
466
|
+
routeSpec.parameters.push({
|
|
467
|
+
name: key,
|
|
468
|
+
in: "query",
|
|
469
|
+
required: !value.isOptional?.(),
|
|
470
|
+
schema: value._def?.typeName ? { type: "string" } : {}
|
|
471
|
+
});
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
} catch (e) {
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
paths[route.path][method] = routeSpec;
|
|
439
478
|
}
|
|
440
479
|
return {
|
|
441
480
|
openapi: "3.0.0",
|
package/dist/esm/index.js
CHANGED
|
@@ -142,12 +142,15 @@ class Sprint {
|
|
|
142
142
|
res.json(this.generateOpenAPISpec());
|
|
143
143
|
});
|
|
144
144
|
if (this.openapi.swaggerUi.enabled) {
|
|
145
|
+
console.log(`[Sprint] Loading Swagger UI...`);
|
|
145
146
|
import("swagger-ui-express").then((swaggerUi) => {
|
|
147
|
+
console.log(`[Sprint] Swagger UI imported successfully`);
|
|
146
148
|
this.app.use("/swagger", swaggerUi.serve, swaggerUi.setup(void 0, {
|
|
147
149
|
swaggerUrl: "/openapi.json"
|
|
148
150
|
}));
|
|
149
|
-
|
|
150
|
-
|
|
151
|
+
console.log(`[Sprint] Swagger UI mounted at /swagger`);
|
|
152
|
+
}).catch((err) => {
|
|
153
|
+
console.error(`[Sprint] ⚠️ swagger-ui-express error:`, err);
|
|
151
154
|
});
|
|
152
155
|
}
|
|
153
156
|
}
|
|
@@ -400,10 +403,16 @@ class Sprint {
|
|
|
400
403
|
}
|
|
401
404
|
generateOpenAPISpec() {
|
|
402
405
|
const paths = {};
|
|
406
|
+
let zod;
|
|
407
|
+
try {
|
|
408
|
+
zod = require("zod");
|
|
409
|
+
} catch (e) {
|
|
410
|
+
console.warn("[Sprint] Zod not available for OpenAPI schema generation");
|
|
411
|
+
}
|
|
403
412
|
for (const route of this.registeredRoutes || []) {
|
|
404
413
|
const method = route.method.toLowerCase();
|
|
405
414
|
if (!paths[route.path]) paths[route.path] = {};
|
|
406
|
-
|
|
415
|
+
const routeSpec = {
|
|
407
416
|
summary: "Auto generated by Sprint",
|
|
408
417
|
responses: {
|
|
409
418
|
"200": {
|
|
@@ -411,6 +420,36 @@ class Sprint {
|
|
|
411
420
|
}
|
|
412
421
|
}
|
|
413
422
|
};
|
|
423
|
+
if (route.schema?.body && zod) {
|
|
424
|
+
try {
|
|
425
|
+
routeSpec.requestBody = {
|
|
426
|
+
content: {
|
|
427
|
+
"application/json": {
|
|
428
|
+
schema: route.schema.body.schema || route.schema.body._def?.schema?.toJSON?.() || {}
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
} catch (e) {
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
if (route.schema?.queryParams && zod) {
|
|
436
|
+
try {
|
|
437
|
+
routeSpec.parameters = [];
|
|
438
|
+
const querySchema = route.schema.queryParams.schema || route.schema.queryParams._def?.schema;
|
|
439
|
+
if (querySchema?.shape) {
|
|
440
|
+
for (const [key, value] of Object.entries(querySchema.shape)) {
|
|
441
|
+
routeSpec.parameters.push({
|
|
442
|
+
name: key,
|
|
443
|
+
in: "query",
|
|
444
|
+
required: !value.isOptional?.(),
|
|
445
|
+
schema: value._def?.typeName ? { type: "string" } : {}
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
} catch (e) {
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
paths[route.path][method] = routeSpec;
|
|
414
453
|
}
|
|
415
454
|
return {
|
|
416
455
|
openapi: "3.0.0",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sprint.d.ts","sourceRoot":"","sources":["../../src/sprint.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAA+B,gBAAgB,EAAoB,MAAM,SAAS,CAAC;AACnG,OAAO,OAAO,EAAE,EAAE,WAAW,EAAoD,MAAM,SAAS,CAAC;AAejG,eAAO,MAAM,aAAa,SAAQ,CAAC;AACnC,eAAO,MAAM,YAAY,SAAS,CAAC;AAwCnC,qBAAa,MAAM;IACR,GAAG,EAAE,WAAW,CAAC;IACxB,OAAO,CAAC,IAAI,CAAwD;IACpE,OAAO,CAAC,UAAU,CAAsB;IACxC,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,SAAS,CAAkB;IACnC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,YAAY,CAAiB;IACrC,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,iBAAiB,CAA0B;IACnD,OAAO,CAAC,OAAO,CAUb;IACF,OAAO,CAAC,gBAAgB,CAIhB;;
|
|
1
|
+
{"version":3,"file":"sprint.d.ts","sourceRoot":"","sources":["../../src/sprint.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,OAAO,EAA+B,gBAAgB,EAAoB,MAAM,SAAS,CAAC;AACnG,OAAO,OAAO,EAAE,EAAE,WAAW,EAAoD,MAAM,SAAS,CAAC;AAejG,eAAO,MAAM,aAAa,SAAQ,CAAC;AACnC,eAAO,MAAM,YAAY,SAAS,CAAC;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