@forinda/kickjs-swagger 2.0.1 → 2.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forinda/kickjs-swagger",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "description": "OpenAPI spec generation from decorators, Swagger UI and ReDoc serving for KickJS",
5
5
  "keywords": [
6
6
  "kickjs",
@@ -38,20 +38,39 @@
38
38
  "vite"
39
39
  ],
40
40
  "type": "module",
41
- "main": "dist/index.js",
42
- "types": "dist/index.d.ts",
41
+ "main": "dist/index.mjs",
42
+ "types": "dist/index.d.mts",
43
43
  "exports": {
44
44
  ".": {
45
- "import": "./dist/index.js",
46
- "types": "./dist/index.d.ts"
45
+ "import": "./dist/index.mjs",
46
+ "types": "./dist/index.d.mts"
47
47
  }
48
48
  },
49
49
  "files": [
50
50
  "dist"
51
51
  ],
52
+ "wireit": {
53
+ "build": {
54
+ "command": "tsdown",
55
+ "files": [
56
+ "src/**/*.ts",
57
+ "tsdown.config.ts",
58
+ "tsconfig.json",
59
+ "package.json"
60
+ ],
61
+ "output": [
62
+ "dist/**"
63
+ ],
64
+ "dependencies": [
65
+ "../core:build",
66
+ "../http:build"
67
+ ]
68
+ }
69
+ },
52
70
  "dependencies": {
53
71
  "reflect-metadata": "^0.2.2",
54
- "@forinda/kickjs": "2.0.1"
72
+ "swagger-ui-dist": "^5.32.1",
73
+ "@forinda/kickjs": "2.2.0"
55
74
  },
56
75
  "peerDependencies": {
57
76
  "express": "^5.1.0",
@@ -63,12 +82,12 @@
63
82
  }
64
83
  },
65
84
  "devDependencies": {
66
- "@swc/core": "^1.7.28",
85
+ "@swc/core": "^1.15.21",
67
86
  "@types/express": "^5.0.6",
68
87
  "@types/node": "^25.0.0",
69
88
  "express": "^5.1.0",
70
89
  "typescript": "^5.9.2",
71
- "vitest": "^4.1.1",
90
+ "vitest": "^4.1.2",
72
91
  "zod": "^4.3.6"
73
92
  },
74
93
  "publishConfig": {
@@ -89,13 +108,12 @@
89
108
  "url": "https://github.com/forinda/kick-js/issues"
90
109
  },
91
110
  "scripts": {
92
- "build": "vite build && pnpm build:types",
93
- "build:types": "tsc -p tsconfig.build.json",
94
- "dev": "vite build --watch",
111
+ "build": "wireit",
112
+ "dev": "tsdown --watch",
95
113
  "test": "vitest run --passWithNoTests",
96
114
  "test:watch": "vitest",
97
115
  "typecheck": "tsc --noEmit",
98
- "clean": "rm -rf dist .turbo",
116
+ "clean": "rm -rf dist .wireit",
99
117
  "lint": "tsc --noEmit"
100
118
  }
101
119
  }
@@ -1,33 +0,0 @@
1
- import 'reflect-metadata';
2
- declare const SWAGGER_KEYS: {
3
- OPERATION: symbol;
4
- RESPONSES: symbol;
5
- TAGS: symbol;
6
- BEARER_AUTH: symbol;
7
- EXCLUDE: symbol;
8
- };
9
- export { SWAGGER_KEYS };
10
- export interface ApiOperationOptions {
11
- summary?: string;
12
- description?: string;
13
- operationId?: string;
14
- deprecated?: boolean;
15
- }
16
- export interface ApiResponseOptions {
17
- status: number;
18
- description?: string;
19
- schema?: any;
20
- /** Schema name in components/schemas (e.g., 'UserResponse', 'ErrorBody'). Auto-generated from handler name if omitted. */
21
- name?: string;
22
- }
23
- /** Attach operation metadata to a route handler */
24
- export declare function ApiOperation(options: ApiOperationOptions): MethodDecorator;
25
- /** Document a response status. Can be stacked multiple times. */
26
- export declare function ApiResponse(options: ApiResponseOptions): MethodDecorator;
27
- /** Apply OpenAPI tags at class or method level */
28
- export declare function ApiTags(...tags: string[]): ClassDecorator & MethodDecorator;
29
- /** Mark endpoint as requiring Bearer token auth */
30
- export declare function ApiBearerAuth(name?: string): ClassDecorator & MethodDecorator;
31
- /** Exclude a controller or method from the OpenAPI spec */
32
- export declare function ApiExclude(): ClassDecorator & MethodDecorator;
33
- //# sourceMappingURL=decorators.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAEzB,QAAA,MAAM,YAAY;;;;;;CAMjB,CAAA;AAED,OAAO,EAAE,YAAY,EAAE,CAAA;AAEvB,MAAM,WAAW,mBAAmB;IAClC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,0HAA0H;IAC1H,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,mDAAmD;AACnD,wBAAgB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,eAAe,CAI1E;AAED,iEAAiE;AACjE,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,eAAe,CAWxE;AAED,kDAAkD;AAClD,wBAAgB,OAAO,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,cAAc,GAAG,eAAe,CAQ3E;AAED,mDAAmD;AACnD,wBAAgB,aAAa,CAAC,IAAI,SAAe,GAAG,cAAc,GAAG,eAAe,CAQnF;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,IAAI,cAAc,GAAG,eAAe,CAQ7D"}
package/dist/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export { zodSchemaParser, type SchemaParser } from './schema-parser';
2
- export { ApiOperation, ApiResponse, ApiTags, ApiBearerAuth, ApiExclude, type ApiOperationOptions, type ApiResponseOptions, } from './decorators';
3
- export { buildOpenAPISpec, registerControllerForDocs, clearRegisteredRoutes, type OpenAPIInfo, type SwaggerOptions, } from './openapi-builder';
4
- export { SwaggerAdapter, type SwaggerAdapterOptions } from './swagger.adapter';
5
- export { swaggerUIHtml, redocHtml } from './ui';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAGpE,OAAO,EACL,YAAY,EACZ,WAAW,EACX,OAAO,EACP,aAAa,EACb,UAAU,EACV,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,qBAAqB,EACrB,KAAK,WAAW,EAChB,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAA;AAG1B,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAA;AAG9E,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,MAAM,CAAA"}
package/dist/index.js DELETED
@@ -1,345 +0,0 @@
1
- import "reflect-metadata";
2
- import { Logger as D, METADATA as T, joinPaths as C } from "@forinda/kickjs";
3
- import { Router as L } from "express";
4
- var H = {
5
- name: "zod",
6
- supports(e) {
7
- return e != null && typeof e == "object" && typeof e.safeParse == "function" && typeof e.toJSONSchema == "function";
8
- },
9
- toJsonSchema(e) {
10
- const { $schema: t, ...a } = e.toJSONSchema();
11
- return a;
12
- }
13
- }, i = {
14
- OPERATION: /* @__PURE__ */ Symbol("kick:swagger:operation"),
15
- RESPONSES: /* @__PURE__ */ Symbol("kick:swagger:responses"),
16
- TAGS: /* @__PURE__ */ Symbol("kick:swagger:tags"),
17
- BEARER_AUTH: /* @__PURE__ */ Symbol("kick:swagger:bearer"),
18
- EXCLUDE: /* @__PURE__ */ Symbol("kick:swagger:exclude")
19
- };
20
- function Z(e) {
21
- return (t, a) => {
22
- Reflect.defineMetadata(i.OPERATION, e, t.constructor, a);
23
- };
24
- }
25
- function Q(e) {
26
- return (t, a) => {
27
- const p = Reflect.getMetadata(i.RESPONSES, t.constructor, a) || [];
28
- Reflect.defineMetadata(i.RESPONSES, [...p, e], t.constructor, a);
29
- };
30
- }
31
- function V(...e) {
32
- return (t, a) => {
33
- a ? Reflect.defineMetadata(i.TAGS, e, t.constructor, a) : Reflect.defineMetadata(i.TAGS, e, t);
34
- };
35
- }
36
- function K(e = "BearerAuth") {
37
- return (t, a) => {
38
- a ? Reflect.defineMetadata(i.BEARER_AUTH, e, t.constructor, a) : Reflect.defineMetadata(i.BEARER_AUTH, e, t);
39
- };
40
- }
41
- function ee() {
42
- return (e, t) => {
43
- t ? Reflect.defineMetadata(i.EXCLUDE, !0, e.constructor, t) : Reflect.defineMetadata(i.EXCLUDE, !0, e);
44
- };
45
- }
46
- var M = [];
47
- function F(e, t) {
48
- M.push({
49
- controllerClass: e,
50
- mountPath: t
51
- });
52
- }
53
- function x() {
54
- M.length = 0;
55
- }
56
- function J(e = {}) {
57
- const t = e.schemaParser ?? H, a = (o) => {
58
- try {
59
- return t.supports(o) ? t.toJsonSchema(o) : null;
60
- } catch {
61
- return null;
62
- }
63
- }, p = {};
64
- let d = 0;
65
- const m = (o, w) => {
66
- let u = o.title || o.label || w || "";
67
- if (u || (u = `Schema${++d}`), u = u.replace(/[^a-zA-Z0-9]/g, ""), !p[u]) {
68
- const A = { ...o };
69
- delete A.title, delete A.label, delete A.$schema, p[u] = A;
70
- }
71
- return { $ref: `#/components/schemas/${u}` };
72
- }, r = {
73
- openapi: "3.0.3",
74
- info: {
75
- title: e.info?.title || "API",
76
- version: e.info?.version || "1.0.0",
77
- ...e.info?.description ? { description: e.info.description } : {}
78
- },
79
- paths: {},
80
- components: {
81
- schemas: {},
82
- securitySchemes: {}
83
- },
84
- tags: []
85
- };
86
- e.servers && (r.servers = e.servers);
87
- const S = /* @__PURE__ */ new Set(), E = {};
88
- for (const { controllerClass: o, mountPath: w } of M) {
89
- if (Reflect.getMetadata(i.EXCLUDE, o)) continue;
90
- const u = Reflect.getMetadata(T.ROUTES, o) || [], A = Reflect.getMetadata(i.TAGS, o) || [], I = Reflect.getMetadata(i.BEARER_AUTH, o);
91
- for (const n of u) {
92
- if (Reflect.getMetadata(i.EXCLUDE, o, n.handlerName)) continue;
93
- const $ = C(w, n.path), P = $.replace(/:([a-zA-Z_]+)/g, "{$1}"), R = n.method.toLowerCase(), h = Reflect.getMetadata(i.OPERATION, o, n.handlerName) || {}, N = Reflect.getMetadata(i.RESPONSES, o, n.handlerName) || [], k = Reflect.getMetadata(i.TAGS, o, n.handlerName) || [], B = Reflect.getMetadata(i.BEARER_AUTH, o, n.handlerName), v = k.length > 0 ? k : A;
94
- v.forEach((s) => S.add(s));
95
- const c = {
96
- ...v.length > 0 ? { tags: v } : {},
97
- ...h.summary ? { summary: h.summary } : {},
98
- ...h.description ? { description: h.description } : {},
99
- ...h.operationId ? { operationId: h.operationId } : {},
100
- ...h.deprecated ? { deprecated: !0 } : {},
101
- parameters: [],
102
- responses: {}
103
- }, _ = $.match(/:([a-zA-Z_]+)/g) || [];
104
- for (const s of _) {
105
- const l = s.slice(1);
106
- let y = { type: "string" };
107
- if (n.validation?.params) {
108
- const f = a(n.validation.params);
109
- if (f?.properties && typeof f.properties == "object") {
110
- const U = f.properties;
111
- U[l] && (y = U[l]);
112
- }
113
- }
114
- c.parameters.push({
115
- name: l,
116
- in: "path",
117
- required: !0,
118
- schema: y
119
- });
120
- }
121
- if (n.validation?.query) {
122
- const s = a(n.validation.query);
123
- if (s?.properties && typeof s.properties == "object") {
124
- const l = Array.isArray(s.required) ? s.required : [];
125
- for (const [y, f] of Object.entries(s.properties)) c.parameters.push({
126
- name: y,
127
- in: "query",
128
- required: l.includes(y),
129
- schema: f
130
- });
131
- }
132
- }
133
- const g = Reflect.getMetadata(T.QUERY_PARAMS, o, n.handlerName);
134
- if (g && (g.filterable?.length && c.parameters.push({
135
- name: "filter",
136
- in: "query",
137
- required: !1,
138
- description: `Filter fields: ${g.filterable.join(", ")}. Format: \`field:operator:value\`. Operators: eq, neq, gt, gte, lt, lte, contains, starts, ends, in, between`,
139
- schema: {
140
- type: "array",
141
- items: { type: "string" }
142
- },
143
- style: "form",
144
- explode: !0
145
- }), g.sortable?.length && c.parameters.push({
146
- name: "sort",
147
- in: "query",
148
- required: !1,
149
- description: `Sort fields: ${g.sortable.join(", ")}. Format: \`field:asc\` or \`field:desc\``,
150
- schema: {
151
- type: "array",
152
- items: { type: "string" }
153
- },
154
- style: "form",
155
- explode: !0
156
- }), g.searchable?.length && c.parameters.push({
157
- name: "q",
158
- in: "query",
159
- required: !1,
160
- description: `Search across: ${g.searchable.join(", ")}`,
161
- schema: { type: "string" }
162
- }), c.parameters.push({
163
- name: "page",
164
- in: "query",
165
- required: !1,
166
- description: "Page number (default: 1)",
167
- schema: {
168
- type: "integer",
169
- minimum: 1,
170
- default: 1
171
- }
172
- }, {
173
- name: "limit",
174
- in: "query",
175
- required: !1,
176
- description: "Items per page (default: 20, max: 100)",
177
- schema: {
178
- type: "integer",
179
- minimum: 1,
180
- maximum: 100,
181
- default: 20
182
- }
183
- })), c.parameters.length === 0 && delete c.parameters, n.validation?.body && [
184
- "post",
185
- "put",
186
- "patch"
187
- ].includes(R)) {
188
- const s = a(n.validation.body);
189
- if (s) {
190
- const l = m(s, n.validation.name || `${n.handlerName}Body`);
191
- c.requestBody = {
192
- required: !0,
193
- content: { "application/json": { schema: l } }
194
- };
195
- }
196
- }
197
- const b = Reflect.getMetadata(T.FILE_UPLOAD, o, n.handlerName);
198
- if (b) {
199
- const s = b.fieldName ?? "file", l = {};
200
- b.mode === "array" ? l[s] = {
201
- type: "array",
202
- items: {
203
- type: "string",
204
- format: "binary"
205
- }
206
- } : b.mode !== "none" && (l[s] = {
207
- type: "string",
208
- format: "binary"
209
- }), c.requestBody = {
210
- required: !0,
211
- content: { "multipart/form-data": { schema: {
212
- type: "object",
213
- properties: l
214
- } } }
215
- };
216
- }
217
- if (N.length > 0) for (const s of N) c.responses[String(s.status)] = {
218
- description: s.description || "",
219
- ...s.schema ? (() => {
220
- const l = typeof s.schema == "function" || typeof s.schema == "object" ? a(s.schema) : null, y = s.name || `${n.handlerName}Response${s.status}`, f = l ? m(l, y) : typeof s.schema == "object" ? s.schema : void 0;
221
- return f ? { content: { "application/json": { schema: f } } } : {};
222
- })() : {}
223
- };
224
- else {
225
- const s = R === "post" ? "201" : R === "delete" ? "204" : "200";
226
- c.responses[s] = { description: "Successful operation" }, n.validation?.body && (c.responses[422] = { description: "Validation error" });
227
- }
228
- const q = B || I;
229
- q && (c.security = [{ [q]: [] }], E[q] = {
230
- type: "http",
231
- scheme: "bearer",
232
- bearerFormat: "JWT"
233
- }), r.paths[P] || (r.paths[P] = {}), r.paths[P][R] = c;
234
- }
235
- }
236
- return r.tags = Array.from(S).map((o) => ({ name: o })), r.components.securitySchemes = E, e.bearerAuth && (E.BearerAuth || (r.components.securitySchemes.BearerAuth = {
237
- type: "http",
238
- scheme: "bearer",
239
- bearerFormat: "JWT"
240
- }), r.security = [{ BearerAuth: [] }]), r.components.schemas = p, Object.keys(r.components.schemas).length === 0 && delete r.components.schemas, Object.keys(r.components.securitySchemes).length === 0 && delete r.components.securitySchemes, Object.keys(r.components).length === 0 && delete r.components, r;
241
- }
242
- function j(e) {
243
- return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
244
- }
245
- function G(e, t = "API Docs") {
246
- return `<!DOCTYPE html>
247
- <html lang="en">
248
- <head>
249
- <meta charset="UTF-8">
250
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
251
- <title>${j(t)}</title>
252
- <link rel="stylesheet" href="https://unpkg.com/swagger-ui-dist@5/swagger-ui.css">
253
- </head>
254
- <body>
255
- <div id="swagger-ui"></div>
256
- <script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js"><\/script>
257
- <script src="https://unpkg.com/swagger-ui-dist@5/swagger-ui-standalone-preset.js"><\/script>
258
- <script>
259
- SwaggerUIBundle({
260
- url: ${JSON.stringify(e).replace(/</g, "\\u003c")},
261
- dom_id: '#swagger-ui',
262
- deepLinking: true,
263
- presets: [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset],
264
- plugins: [SwaggerUIBundle.plugins.DownloadUrl],
265
- layout: 'StandaloneLayout',
266
- });
267
- <\/script>
268
- </body>
269
- </html>`;
270
- }
271
- function z(e, t = "API Docs") {
272
- return `<!DOCTYPE html>
273
- <html lang="en">
274
- <head>
275
- <meta charset="UTF-8">
276
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
277
- <title>${j(t)}</title>
278
- </head>
279
- <body>
280
- <redoc spec-url="${j(e)}"></redoc>
281
- <script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"><\/script>
282
- </body>
283
- </html>`;
284
- }
285
- var O = D.for("SwaggerAdapter"), te = class {
286
- name = "SwaggerAdapter";
287
- constructor(e = {}) {
288
- this.options = e;
289
- }
290
- afterStart({ server: e }) {
291
- const t = e?.address?.();
292
- if (!t || typeof t != "object") return;
293
- const a = t.address === "::" || t.address === "0.0.0.0" ? "localhost" : t.address;
294
- (!this.options.servers || this.options.servers.length === 0) && (this.options.servers = [{
295
- url: `http://${a}:${t.port}`,
296
- description: "HTTP server"
297
- }]);
298
- const p = this.options.adapters?.find((d) => d.name === "WsAdapter" && typeof d.getStats == "function");
299
- if (p) {
300
- const d = p.getStats();
301
- for (const m of Object.keys(d.namespaces || {})) this.options.servers.push({
302
- url: `ws://${a}:${t.port}${m}`,
303
- description: `WebSocket: ${m}`
304
- });
305
- }
306
- }
307
- onRouteMount(e, t) {
308
- F(e, t);
309
- }
310
- beforeMount({ app: e }) {
311
- x();
312
- const t = this.options.docsPath ?? "/docs", a = this.options.redocPath ?? "/redoc", p = this.options.specPath ?? "/openapi.json", d = L();
313
- d.use((m, r, S) => {
314
- r.setHeader("Content-Security-Policy", [
315
- "default-src 'self'",
316
- "script-src 'self' 'unsafe-inline' https://unpkg.com https://cdn.redoc.ly https://cdn.jsdelivr.net",
317
- "style-src 'self' 'unsafe-inline' https://unpkg.com https://fonts.googleapis.com",
318
- "font-src 'self' https://fonts.gstatic.com",
319
- "img-src 'self' data: https://unpkg.com",
320
- "connect-src 'self'"
321
- ].join("; ")), S();
322
- }), d.get(p, (m, r) => {
323
- const S = J(this.options);
324
- r.json(S);
325
- }), d.get(t, (m, r) => {
326
- r.type("html").send(G(p, this.options.info?.title));
327
- }), d.get(a, (m, r) => {
328
- r.type("html").send(z(p, this.options.info?.title));
329
- }), e.use(d), O.info(`Swagger UI: ${t}`), O.info(`ReDoc: ${a}`), O.info(`OpenAPI spec: ${p}`);
330
- }
331
- };
332
- export {
333
- K as ApiBearerAuth,
334
- ee as ApiExclude,
335
- Z as ApiOperation,
336
- Q as ApiResponse,
337
- V as ApiTags,
338
- te as SwaggerAdapter,
339
- J as buildOpenAPISpec,
340
- x as clearRegisteredRoutes,
341
- z as redocHtml,
342
- F as registerControllerForDocs,
343
- G as swaggerUIHtml,
344
- H as zodSchemaParser
345
- };
@@ -1,36 +0,0 @@
1
- import 'reflect-metadata';
2
- import { type SchemaParser } from './schema-parser';
3
- export interface OpenAPIInfo {
4
- title: string;
5
- version: string;
6
- description?: string;
7
- }
8
- export interface SwaggerOptions {
9
- info?: Partial<OpenAPIInfo>;
10
- servers?: {
11
- url: string;
12
- description?: string;
13
- }[];
14
- bearerAuth?: boolean;
15
- /**
16
- * Pluggable schema parser for converting validation schemas to JSON Schema.
17
- * Defaults to `zodSchemaParser` which handles Zod v4+ schemas.
18
- *
19
- * Override this to use Yup, Joi, Valibot, ArkType, or any other library.
20
- *
21
- * @example
22
- * ```ts
23
- * new SwaggerAdapter({
24
- * schemaParser: myYupParser,
25
- * })
26
- * ```
27
- */
28
- schemaParser?: SchemaParser;
29
- }
30
- /** Register a controller for OpenAPI introspection (called by Application during route mounting) */
31
- export declare function registerControllerForDocs(controllerClass: any, mountPath: string): void;
32
- /** Clear all registered routes (for HMR) */
33
- export declare function clearRegisteredRoutes(): void;
34
- /** Build a full OpenAPI 3.0.3 spec from registered controllers and their decorators */
35
- export declare function buildOpenAPISpec(options?: SwaggerOptions): any;
36
- //# sourceMappingURL=openapi-builder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openapi-builder.d.ts","sourceRoot":"","sources":["../src/openapi-builder.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAA;AAGzB,OAAO,EAAmB,KAAK,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAEpE,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC,WAAW,CAAC,CAAA;IAC3B,OAAO,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;IACjD,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;;;;;;;;;OAYG;IACH,YAAY,CAAC,EAAE,YAAY,CAAA;CAC5B;AASD,oGAAoG;AACpG,wBAAgB,yBAAyB,CAAC,eAAe,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAEvF;AAED,4CAA4C;AAC5C,wBAAgB,qBAAqB,IAAI,IAAI,CAE5C;AAED,uFAAuF;AACvF,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,cAAmB,GAAG,GAAG,CA6UlE"}
@@ -1,42 +0,0 @@
1
- /**
2
- * Interface for converting validation library schemas to JSON Schema.
3
- *
4
- * KickJS ships with a Zod parser by default. To use a different validation
5
- * library (Yup, Joi, Valibot, ArkType, etc.), implement this interface and
6
- * pass it to the SwaggerAdapter.
7
- *
8
- * @example
9
- * ```ts
10
- * import Joi from 'joi'
11
- * import joiToJson from 'joi-to-json'
12
- *
13
- * const joiParser: SchemaParser = {
14
- * name: 'joi',
15
- * supports: (schema) => Joi.isSchema(schema),
16
- * toJsonSchema: (schema) => joiToJson(schema),
17
- * }
18
- *
19
- * new SwaggerAdapter({ schemaParser: joiParser })
20
- * ```
21
- */
22
- export interface SchemaParser {
23
- /** Human-readable name for logging/debugging */
24
- readonly name: string;
25
- /**
26
- * Return true if this parser can handle the given schema object.
27
- * Called before `toJsonSchema` to allow graceful fallback.
28
- */
29
- supports(schema: unknown): boolean;
30
- /**
31
- * Convert a validation schema to a JSON Schema object.
32
- * Should return a plain object conforming to JSON Schema draft-07 or later.
33
- * Must not include the top-level `$schema` key — the builder adds it.
34
- */
35
- toJsonSchema(schema: unknown): Record<string, unknown>;
36
- }
37
- /**
38
- * Default schema parser for Zod v4+.
39
- * Uses Zod's built-in `.toJSONSchema()` instance method.
40
- */
41
- export declare const zodSchemaParser: SchemaParser;
42
- //# sourceMappingURL=schema-parser.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema-parser.d.ts","sourceRoot":"","sources":["../src/schema-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IAErB;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAA;IAElC;;;;OAIG;IACH,YAAY,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACvD;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,YAgB7B,CAAA"}
@@ -1,44 +0,0 @@
1
- import { type AppAdapter, type AdapterContext } from '@forinda/kickjs';
2
- import { registerControllerForDocs, clearRegisteredRoutes, type SwaggerOptions } from './openapi-builder';
3
- export interface SwaggerAdapterOptions extends SwaggerOptions {
4
- /** Path to serve Swagger UI (default: '/docs') */
5
- docsPath?: string;
6
- /** Path to serve ReDoc (default: '/redoc') */
7
- redocPath?: string;
8
- /** Path to serve the raw JSON spec (default: '/openapi.json') */
9
- specPath?: string;
10
- /** Other adapters to discover (e.g., WsAdapter for WebSocket server URLs) */
11
- adapters?: any[];
12
- }
13
- /**
14
- * Swagger adapter — auto-generates OpenAPI spec from decorators and serves docs.
15
- *
16
- * @example
17
- * ```ts
18
- * bootstrap({
19
- * modules,
20
- * adapters: [
21
- * new SwaggerAdapter({
22
- * info: { title: 'My API', version: '1.0.0' },
23
- * }),
24
- * ],
25
- * })
26
- * ```
27
- *
28
- * Endpoints:
29
- * GET /docs — Swagger UI
30
- * GET /redoc — ReDoc
31
- * GET /openapi.json — Raw OpenAPI 3.0.3 spec
32
- */
33
- export declare class SwaggerAdapter implements AppAdapter {
34
- private options;
35
- name: string;
36
- constructor(options?: SwaggerAdapterOptions);
37
- /** Auto-detect server URLs from the running HTTP server and peer adapters */
38
- afterStart({ server }: AdapterContext): void;
39
- /** Collect controller metadata as routes are mounted */
40
- onRouteMount(controllerClass: any, mountPath: string): void;
41
- beforeMount({ app }: AdapterContext): void;
42
- }
43
- export { registerControllerForDocs, clearRegisteredRoutes };
44
- //# sourceMappingURL=swagger.adapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"swagger.adapter.d.ts","sourceRoot":"","sources":["../src/swagger.adapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAC9E,OAAO,EAEL,yBAAyB,EACzB,qBAAqB,EACrB,KAAK,cAAc,EACpB,MAAM,mBAAmB,CAAA;AAK1B,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,kDAAkD;IAClD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iEAAiE;IACjE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,GAAG,EAAE,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBAAa,cAAe,YAAW,UAAU;IAGnC,OAAO,CAAC,OAAO;IAF3B,IAAI,SAAmB;gBAEH,OAAO,GAAE,qBAA0B;IAEvD,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,EAAE,EAAE,cAAc,GAAG,IAAI;IA0B5C,wDAAwD;IACxD,YAAY,CAAC,eAAe,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAI3D,WAAW,CAAC,EAAE,GAAG,EAAE,EAAE,cAAc,GAAG,IAAI;CA+C3C;AAGD,OAAO,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,CAAA"}
package/dist/ui.d.ts DELETED
@@ -1,5 +0,0 @@
1
- /** Generate Swagger UI HTML that loads from CDN */
2
- export declare function swaggerUIHtml(specUrl: string, title?: string): string;
3
- /** Generate ReDoc HTML that loads from CDN */
4
- export declare function redocHtml(specUrl: string, title?: string): string;
5
- //# sourceMappingURL=ui.d.ts.map
package/dist/ui.d.ts.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../src/ui.ts"],"names":[],"mappings":"AAUA,mDAAmD;AACnD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAa,GAAG,MAAM,CA4BzE;AAED,8CAA8C;AAC9C,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,SAAa,GAAG,MAAM,CAgBrE"}