@elysiajs/openapi 1.4.7 → 1.4.8

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.
@@ -8314,7 +8314,6 @@ var import_path2 = require("path");
8314
8314
  var import_child_process = require("child_process");
8315
8315
  var matchRoute = /: Elysia<(.*)>/gs;
8316
8316
  var matchStatus = /(\d{3}):/g;
8317
- var wrapStatusInQuote = (value) => value.replace(matchStatus, '"$1":');
8318
8317
  function extractRootObjects(code) {
8319
8318
  const results = [];
8320
8319
  let i = 0;
@@ -8458,13 +8457,11 @@ var fromTypes = (targetFilePath, {
8458
8457
  3
8459
8458
  )
8460
8459
  );
8461
- const routesString = wrapStatusInQuote(
8462
- // Intentionally not adding "}"
8463
- // to avoid mismatched bracket in loop below
8464
- instance.slice(3, instance.indexOf("}, {", 4))
8460
+ const routesString = extractRootObjects(
8461
+ instance.replace(matchStatus, '"$1":')
8465
8462
  );
8466
8463
  const routes = {};
8467
- for (const route of extractRootObjects(routesString)) {
8464
+ for (const route of routesString) {
8468
8465
  let schema = TypeBox(route.replaceAll(/readonly/g, ""));
8469
8466
  if (schema.type !== "object") continue;
8470
8467
  const paths = [];
package/dist/cjs/index.js CHANGED
@@ -629,7 +629,7 @@ function toOpenAPISchema(app, exclude, references, vendors) {
629
629
  const { type, description, $ref, ...options } = unwrapReference(response, definitions);
630
630
  operation.responses[status] = {
631
631
  description: description ?? `Response for status ${status}`,
632
- content: type === "void" || type === "null" || type === "undefined" ? response : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
632
+ content: type === "void" || type === "null" || type === "undefined" ? { type, description } : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
633
633
  "text/plain": {
634
634
  schema: response
635
635
  }
@@ -651,7 +651,7 @@ function toOpenAPISchema(app, exclude, references, vendors) {
651
651
  const type = _type;
652
652
  operation.responses["200"] = {
653
653
  description: description ?? `Response for status 200`,
654
- content: type === "void" || type === "null" || type === "undefined" ? response : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
654
+ content: type === "void" || type === "null" || type === "undefined" ? { type, description } : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
655
655
  "text/plain": {
656
656
  schema: response
657
657
  }
@@ -372,7 +372,7 @@ function toOpenAPISchema(app, exclude, references, vendors) {
372
372
  const { type, description, $ref, ...options } = unwrapReference(response, definitions);
373
373
  operation.responses[status] = {
374
374
  description: description ?? `Response for status ${status}`,
375
- content: type === "void" || type === "null" || type === "undefined" ? response : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
375
+ content: type === "void" || type === "null" || type === "undefined" ? { type, description } : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
376
376
  "text/plain": {
377
377
  schema: response
378
378
  }
@@ -394,7 +394,7 @@ function toOpenAPISchema(app, exclude, references, vendors) {
394
394
  const type = _type;
395
395
  operation.responses["200"] = {
396
396
  description: description ?? `Response for status 200`,
397
- content: type === "void" || type === "null" || type === "undefined" ? response : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
397
+ content: type === "void" || type === "null" || type === "undefined" ? { type, description } : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
398
398
  "text/plain": {
399
399
  schema: response
400
400
  }
@@ -8303,7 +8303,6 @@ import { join } from "path";
8303
8303
  import { spawnSync } from "child_process";
8304
8304
  var matchRoute = /: Elysia<(.*)>/gs;
8305
8305
  var matchStatus = /(\d{3}):/g;
8306
- var wrapStatusInQuote = (value) => value.replace(matchStatus, '"$1":');
8307
8306
  function extractRootObjects(code) {
8308
8307
  const results = [];
8309
8308
  let i = 0;
@@ -8447,13 +8446,11 @@ var fromTypes = (targetFilePath, {
8447
8446
  3
8448
8447
  )
8449
8448
  );
8450
- const routesString = wrapStatusInQuote(
8451
- // Intentionally not adding "}"
8452
- // to avoid mismatched bracket in loop below
8453
- instance.slice(3, instance.indexOf("}, {", 4))
8449
+ const routesString = extractRootObjects(
8450
+ instance.replace(matchStatus, '"$1":')
8454
8451
  );
8455
8452
  const routes = {};
8456
- for (const route of extractRootObjects(routesString)) {
8453
+ for (const route of routesString) {
8457
8454
  let schema = TypeBox(route.replaceAll(/readonly/g, ""));
8458
8455
  if (schema.type !== "object") continue;
8459
8456
  const paths = [];
package/dist/index.mjs CHANGED
@@ -602,7 +602,7 @@ function toOpenAPISchema(app, exclude, references, vendors) {
602
602
  const { type, description, $ref, ...options } = unwrapReference(response, definitions);
603
603
  operation.responses[status] = {
604
604
  description: description ?? `Response for status ${status}`,
605
- content: type === "void" || type === "null" || type === "undefined" ? response : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
605
+ content: type === "void" || type === "null" || type === "undefined" ? { type, description } : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
606
606
  "text/plain": {
607
607
  schema: response
608
608
  }
@@ -624,7 +624,7 @@ function toOpenAPISchema(app, exclude, references, vendors) {
624
624
  const type = _type;
625
625
  operation.responses["200"] = {
626
626
  description: description ?? `Response for status 200`,
627
- content: type === "void" || type === "null" || type === "undefined" ? response : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
627
+ content: type === "void" || type === "null" || type === "undefined" ? { type, description } : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
628
628
  "text/plain": {
629
629
  schema: response
630
630
  }
package/dist/openapi.mjs CHANGED
@@ -343,7 +343,7 @@ function toOpenAPISchema(app, exclude, references, vendors) {
343
343
  const { type, description, $ref, ...options } = unwrapReference(response, definitions);
344
344
  operation.responses[status] = {
345
345
  description: description ?? `Response for status ${status}`,
346
- content: type === "void" || type === "null" || type === "undefined" ? response : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
346
+ content: type === "void" || type === "null" || type === "undefined" ? { type, description } : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
347
347
  "text/plain": {
348
348
  schema: response
349
349
  }
@@ -365,7 +365,7 @@ function toOpenAPISchema(app, exclude, references, vendors) {
365
365
  const type = _type;
366
366
  operation.responses["200"] = {
367
367
  description: description ?? `Response for status 200`,
368
- content: type === "void" || type === "null" || type === "undefined" ? response : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
368
+ content: type === "void" || type === "null" || type === "undefined" ? { type, description } : type === "string" || type === "number" || type === "integer" || type === "boolean" ? {
369
369
  "text/plain": {
370
370
  schema: response
371
371
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elysiajs/openapi",
3
- "version": "1.4.7",
3
+ "version": "1.4.8",
4
4
  "description": "Plugin for Elysia to auto-generate API documentation",
5
5
  "author": {
6
6
  "name": "saltyAom",