@elysiajs/openapi 1.3.5 → 1.3.6-exp.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/dist/cjs/index.js CHANGED
@@ -318,6 +318,11 @@ var getPossiblePath = (path) => {
318
318
  return paths;
319
319
  };
320
320
  var isValidSchema = (schema) => typeof schema === "object" && (Kind in schema && schema[Kind] !== "Unknown" || schema.type || schema.properties || schema.items);
321
+ var getLoosePath = (path) => {
322
+ if (path.charCodeAt(path.length - 1) === 47)
323
+ return path.slice(0, path.length - 1);
324
+ return path + "/";
325
+ };
321
326
  function toOpenAPISchema(app, exclude, references) {
322
327
  const {
323
328
  methods: excludeMethods = ["OPTIONS"],
@@ -342,7 +347,7 @@ function toOpenAPISchema(app, exclude, references) {
342
347
  const hooks = route.hooks ?? {};
343
348
  if (references)
344
349
  for (const reference of references) {
345
- const refer = reference[route.path]?.[method];
350
+ const refer = reference[route.path]?.[method] ?? reference[getLoosePath(route.path)]?.[method];
346
351
  if (!refer) continue;
347
352
  if (!hooks.body && isValidSchema(refer.body))
348
353
  hooks.body = refer.body;
@@ -9,6 +9,7 @@ export declare const capitalize: (word: string) => string;
9
9
  * @returns {string[]} paths
10
10
  */
11
11
  export declare const getPossiblePath: (path: string) => string[];
12
+ export declare const getLoosePath: (path: string) => string;
12
13
  /**
13
14
  * Converts Elysia routes to OpenAPI 3.0.3 paths schema
14
15
  * @param routes Array of Elysia route objects
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var openapi_exports = {};
22
22
  __export(openapi_exports, {
23
23
  capitalize: () => capitalize,
24
+ getLoosePath: () => getLoosePath,
24
25
  getPossiblePath: () => getPossiblePath,
25
26
  toOpenAPISchema: () => toOpenAPISchema,
26
27
  withHeaders: () => withHeaders
@@ -59,6 +60,11 @@ var getPossiblePath = (path) => {
59
60
  return paths;
60
61
  };
61
62
  var isValidSchema = (schema) => typeof schema === "object" && (Kind in schema && schema[Kind] !== "Unknown" || schema.type || schema.properties || schema.items);
63
+ var getLoosePath = (path) => {
64
+ if (path.charCodeAt(path.length - 1) === 47)
65
+ return path.slice(0, path.length - 1);
66
+ return path + "/";
67
+ };
62
68
  function toOpenAPISchema(app, exclude, references) {
63
69
  const {
64
70
  methods: excludeMethods = ["OPTIONS"],
@@ -83,7 +89,7 @@ function toOpenAPISchema(app, exclude, references) {
83
89
  const hooks = route.hooks ?? {};
84
90
  if (references)
85
91
  for (const reference of references) {
86
- const refer = reference[route.path]?.[method];
92
+ const refer = reference[route.path]?.[method] ?? reference[getLoosePath(route.path)]?.[method];
87
93
  if (!refer) continue;
88
94
  if (!hooks.body && isValidSchema(refer.body))
89
95
  hooks.body = refer.body;
@@ -294,6 +300,7 @@ var withHeaders = (schema, headers) => Object.assign(schema, {
294
300
  // Annotate the CommonJS export names for ESM import in node:
295
301
  0 && (module.exports = {
296
302
  capitalize,
303
+ getLoosePath,
297
304
  getPossiblePath,
298
305
  toOpenAPISchema,
299
306
  withHeaders
package/dist/index.mjs CHANGED
@@ -291,6 +291,11 @@ var getPossiblePath = (path) => {
291
291
  return paths;
292
292
  };
293
293
  var isValidSchema = (schema) => typeof schema === "object" && (Kind in schema && schema[Kind] !== "Unknown" || schema.type || schema.properties || schema.items);
294
+ var getLoosePath = (path) => {
295
+ if (path.charCodeAt(path.length - 1) === 47)
296
+ return path.slice(0, path.length - 1);
297
+ return path + "/";
298
+ };
294
299
  function toOpenAPISchema(app, exclude, references) {
295
300
  const {
296
301
  methods: excludeMethods = ["OPTIONS"],
@@ -315,7 +320,7 @@ function toOpenAPISchema(app, exclude, references) {
315
320
  const hooks = route.hooks ?? {};
316
321
  if (references)
317
322
  for (const reference of references) {
318
- const refer = reference[route.path]?.[method];
323
+ const refer = reference[route.path]?.[method] ?? reference[getLoosePath(route.path)]?.[method];
319
324
  if (!refer) continue;
320
325
  if (!hooks.body && isValidSchema(refer.body))
321
326
  hooks.body = refer.body;
package/dist/openapi.d.ts CHANGED
@@ -9,6 +9,7 @@ export declare const capitalize: (word: string) => string;
9
9
  * @returns {string[]} paths
10
10
  */
11
11
  export declare const getPossiblePath: (path: string) => string[];
12
+ export declare const getLoosePath: (path: string) => string;
12
13
  /**
13
14
  * Converts Elysia routes to OpenAPI 3.0.3 paths schema
14
15
  * @param routes Array of Elysia route objects
package/dist/openapi.mjs CHANGED
@@ -32,6 +32,11 @@ var getPossiblePath = (path) => {
32
32
  return paths;
33
33
  };
34
34
  var isValidSchema = (schema) => typeof schema === "object" && (Kind in schema && schema[Kind] !== "Unknown" || schema.type || schema.properties || schema.items);
35
+ var getLoosePath = (path) => {
36
+ if (path.charCodeAt(path.length - 1) === 47)
37
+ return path.slice(0, path.length - 1);
38
+ return path + "/";
39
+ };
35
40
  function toOpenAPISchema(app, exclude, references) {
36
41
  const {
37
42
  methods: excludeMethods = ["OPTIONS"],
@@ -56,7 +61,7 @@ function toOpenAPISchema(app, exclude, references) {
56
61
  const hooks = route.hooks ?? {};
57
62
  if (references)
58
63
  for (const reference of references) {
59
- const refer = reference[route.path]?.[method];
64
+ const refer = reference[route.path]?.[method] ?? reference[getLoosePath(route.path)]?.[method];
60
65
  if (!refer) continue;
61
66
  if (!hooks.body && isValidSchema(refer.body))
62
67
  hooks.body = refer.body;
@@ -266,6 +271,7 @@ var withHeaders = (schema, headers) => Object.assign(schema, {
266
271
  });
267
272
  export {
268
273
  capitalize,
274
+ getLoosePath,
269
275
  getPossiblePath,
270
276
  toOpenAPISchema,
271
277
  withHeaders
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elysiajs/openapi",
3
- "version": "1.3.5",
3
+ "version": "1.3.6-exp.0",
4
4
  "description": "Plugin for Elysia to auto-generate API documentation",
5
5
  "author": {
6
6
  "name": "saltyAom",
package/bunfig.toml DELETED
@@ -1,2 +0,0 @@
1
- [install]
2
- registry = "https://registry.npmjs.org/"