next-openapi-gen 0.0.17 → 0.0.19

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.
@@ -118,7 +118,7 @@ export class RouteProcessor {
118
118
  const aTags = Object.values(aMethods).flatMap((method) => method.tags || []);
119
119
  // Extract tags for all methods in path b
120
120
  const bTags = Object.values(bMethods).flatMap((method) => method.tags || []);
121
- // Assume we are interested in only the first tags
121
+ // Let's user only the first tags
122
122
  const aPrimaryTag = aTags[0] || "";
123
123
  const bPrimaryTag = bTags[0] || "";
124
124
  // Sort alphabetically based on the first tag
@@ -129,7 +129,6 @@ export class RouteProcessor {
129
129
  // Compare lengths of the paths
130
130
  const aLength = a.split("/").length;
131
131
  const bLength = b.split("/").length;
132
- // Return the result of length comparison
133
132
  return aLength - bLength; // Shorter paths come before longer ones
134
133
  }
135
134
  return Object.keys(paths)
@@ -121,6 +121,16 @@ export class SchemaProcessor {
121
121
  });
122
122
  return { type: "object", properties };
123
123
  }
124
+ if (t.isTSUnionType(node)) {
125
+ return {
126
+ anyOf: node.types.map((subNode) => this.resolveTSNodeType(subNode)),
127
+ };
128
+ }
129
+ // case where a type is a reference to another defined type
130
+ if (t.isTSTypeReference(node) && t.isIdentifier(node.typeName)) {
131
+ return { $ref: `#/components/schemas/${node.typeName.name}` };
132
+ }
133
+ console.warn("Unrecognized TypeScript type node:", node);
124
134
  return {};
125
135
  }
126
136
  processSchemaFile(filePath, schemaName) {
@@ -207,10 +217,7 @@ export class SchemaProcessor {
207
217
  return {
208
218
  content: {
209
219
  "application/json": {
210
- schema: {
211
- type: "object",
212
- properties: body,
213
- },
220
+ schema: body,
214
221
  },
215
222
  },
216
223
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "next-openapi-gen",
3
- "version": "0.0.17",
4
- "description": "Super fast and easy way to generate OpenAPI documentation automatically from API routes in a NextJS 14",
3
+ "version": "0.0.19",
4
+ "description": "Super fast and easy way to generate OpenAPI documentation automatically from API routes in NextJS 14",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.mjs",