next-openapi-gen 0.7.6 → 0.7.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.
@@ -19,18 +19,18 @@ export class OpenApiGenerator {
19
19
  // @ts-ignore
20
20
  const { apiDir, schemaDir, docsUrl, ui, outputFile, outputDir, includeOpenApiRoutes, schemaType = "typescript", defaultResponseSet, responseSets, errorConfig, debug } = this.template;
21
21
  return {
22
- apiDir,
23
- schemaDir,
24
- docsUrl,
25
- ui,
26
- outputFile,
27
- outputDir,
28
- includeOpenApiRoutes,
22
+ apiDir: apiDir || "./src/app/api",
23
+ schemaDir: schemaDir || "./src",
24
+ docsUrl: docsUrl || "api-docs",
25
+ ui: ui || "scalar",
26
+ outputFile: outputFile || "openapi.json",
27
+ outputDir: outputDir || "./public",
28
+ includeOpenApiRoutes: includeOpenApiRoutes || false,
29
29
  schemaType,
30
30
  defaultResponseSet,
31
31
  responseSets,
32
32
  errorConfig,
33
- debug,
33
+ debug: debug || false,
34
34
  };
35
35
  }
36
36
  generate() {
package/dist/lib/utils.js CHANGED
@@ -48,7 +48,11 @@ export function extractJSDocComments(path) {
48
48
  }
49
49
  }
50
50
  if (!summary) {
51
- summary = commentValue.split("\n")[0];
51
+ const firstLine = commentValue.split("\n")[0];
52
+ // Don't use tags as summary - only use actual descriptions
53
+ if (!firstLine.trim().startsWith("@")) {
54
+ summary = firstLine;
55
+ }
52
56
  }
53
57
  if (commentValue.includes("@auth")) {
54
58
  const regex = /@auth\s*(.*)/;
@@ -855,22 +855,6 @@ export class ZodSchemaConverter {
855
855
  !t.isIdentifier(node.callee.property)) {
856
856
  return { type: "string" };
857
857
  }
858
- if (t.isMemberExpression(node.callee) &&
859
- t.isIdentifier(node.callee.property)) {
860
- const zodType = node.callee.property.name;
861
- // Custom() support for FormData
862
- if (zodType === "custom" && node.arguments.length > 0) {
863
- // Check if it is FormData
864
- if (t.isArrowFunctionExpression(node.arguments[0])) {
865
- // Assume custom FormData validation
866
- return {
867
- type: "object",
868
- additionalProperties: true,
869
- description: "Form data object",
870
- };
871
- }
872
- }
873
- }
874
858
  const zodType = node.callee.property.name;
875
859
  let schema = {};
876
860
  // Basic type mapping
@@ -990,6 +974,37 @@ export class ZodSchemaConverter {
990
974
  schema = { type: "object" };
991
975
  }
992
976
  break;
977
+ case "custom":
978
+ // Check if it has TypeScript generic type parameters (z.custom<File>())
979
+ if (node.typeParameters && node.typeParameters.params.length > 0) {
980
+ const typeParam = node.typeParameters.params[0];
981
+ // Check if the generic type is File
982
+ if (t.isTSTypeReference(typeParam) &&
983
+ t.isIdentifier(typeParam.typeName) &&
984
+ typeParam.typeName.name === "File") {
985
+ schema = {
986
+ type: "string",
987
+ format: "binary",
988
+ };
989
+ }
990
+ else {
991
+ // Other generic types default to string
992
+ schema = { type: "string" };
993
+ }
994
+ }
995
+ else if (node.arguments.length > 0 &&
996
+ t.isArrowFunctionExpression(node.arguments[0])) {
997
+ // Legacy support: FormData validation
998
+ schema = {
999
+ type: "object",
1000
+ additionalProperties: true,
1001
+ };
1002
+ }
1003
+ else {
1004
+ // Default case for z.custom() without specific type detection
1005
+ schema = { type: "string" };
1006
+ }
1007
+ break;
993
1008
  default:
994
1009
  schema = { type: "string" };
995
1010
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-openapi-gen",
3
- "version": "0.7.6",
3
+ "version": "0.7.8",
4
4
  "description": "Automatically generate OpenAPI 3.0 documentation from Next.js projects, with support for Zod schemas and TypeScript types.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",