next-openapi-gen 0.4.4 → 0.4.6
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/README.md +1 -1
- package/dist/lib/route-processor.js +3 -3
- package/dist/lib/utils.js +12 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Automatically generate OpenAPI 3.0 documentation from Next.js projects, with sup
|
|
|
9
9
|
- ✅ TypeScript types support
|
|
10
10
|
- ✅ Zod schemas support
|
|
11
11
|
- ✅ JSDoc comments support
|
|
12
|
-
- ✅ Multiple UI interfaces: `Scalar`, `Swagger`, `Redoc`, `Stoplight` and `Rapidoc` available at `/api-docs` url
|
|
12
|
+
- ✅ Multiple UI interfaces: `Scalar`, `Swagger`, `Redoc`, `Stoplight` and `Rapidoc` available at `/api-docs` url
|
|
13
13
|
- ✅ Path parameters detection (`/users/{id}`)
|
|
14
14
|
- ✅ Intelligent parameter examples
|
|
15
15
|
- ✅ Intuitive CLI for initialization and documentation generation
|
|
@@ -16,7 +16,7 @@ export class RouteProcessor {
|
|
|
16
16
|
processFileTracker = {};
|
|
17
17
|
constructor(config) {
|
|
18
18
|
this.config = config;
|
|
19
|
-
this.schemaProcessor = new SchemaProcessor(config.schemaDir);
|
|
19
|
+
this.schemaProcessor = new SchemaProcessor(config.schemaDir, config.schemaType);
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Get the SchemaProcessor instance
|
|
@@ -50,7 +50,7 @@ export class RouteProcessor {
|
|
|
50
50
|
const routePath = this.getRoutePath(filePath);
|
|
51
51
|
const pathParams = extractPathParameters(routePath);
|
|
52
52
|
// If we have path parameters but no pathParamsType defined, we should log a warning
|
|
53
|
-
if (pathParams.length > 0 && !dataTypes.
|
|
53
|
+
if (pathParams.length > 0 && !dataTypes.pathParamsType) {
|
|
54
54
|
console.warn(`Route ${routePath} contains path parameters ${pathParams.join(", ")} but no @pathParams type is defined.`);
|
|
55
55
|
}
|
|
56
56
|
this.addRouteToPaths(declaration.id.name, filePath, dataTypes);
|
|
@@ -67,7 +67,7 @@ export class RouteProcessor {
|
|
|
67
67
|
(this.config.includeOpenApiRoutes && dataTypes.isOpenApi)) {
|
|
68
68
|
const routePath = this.getRoutePath(filePath);
|
|
69
69
|
const pathParams = extractPathParameters(routePath);
|
|
70
|
-
if (pathParams.length > 0 && !dataTypes.
|
|
70
|
+
if (pathParams.length > 0 && !dataTypes.pathParamsType) {
|
|
71
71
|
console.warn(`Route ${routePath} contains path parameters ${pathParams.join(", ")} but no @pathParams type is defined.`);
|
|
72
72
|
}
|
|
73
73
|
this.addRouteToPaths(decl.id.name, filePath, dataTypes);
|
package/dist/lib/utils.js
CHANGED
|
@@ -18,10 +18,10 @@ export function extractJSDocComments(path) {
|
|
|
18
18
|
const comments = path.node.leadingComments;
|
|
19
19
|
let summary = "";
|
|
20
20
|
let description = "";
|
|
21
|
-
let
|
|
22
|
-
let
|
|
23
|
-
let
|
|
24
|
-
let
|
|
21
|
+
let paramsType = "";
|
|
22
|
+
let pathParamsType = "";
|
|
23
|
+
let bodyType = "";
|
|
24
|
+
let responseType = "";
|
|
25
25
|
let auth = "";
|
|
26
26
|
let isOpenApi = false;
|
|
27
27
|
if (comments) {
|
|
@@ -51,16 +51,16 @@ export function extractJSDocComments(path) {
|
|
|
51
51
|
description = commentValue.match(regex)[1].trim();
|
|
52
52
|
}
|
|
53
53
|
if (commentValue.includes("@params")) {
|
|
54
|
-
|
|
54
|
+
paramsType = extractTypeFromComment(commentValue, "@params");
|
|
55
55
|
}
|
|
56
56
|
if (commentValue.includes("@pathParams")) {
|
|
57
|
-
|
|
57
|
+
pathParamsType = extractTypeFromComment(commentValue, "@pathParams");
|
|
58
58
|
}
|
|
59
59
|
if (commentValue.includes("@body")) {
|
|
60
|
-
|
|
60
|
+
bodyType = extractTypeFromComment(commentValue, "@body");
|
|
61
61
|
}
|
|
62
62
|
if (commentValue.includes("@response")) {
|
|
63
|
-
|
|
63
|
+
responseType = extractTypeFromComment(commentValue, "@response");
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
}
|
|
@@ -68,10 +68,10 @@ export function extractJSDocComments(path) {
|
|
|
68
68
|
auth,
|
|
69
69
|
summary,
|
|
70
70
|
description,
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
paramsType,
|
|
72
|
+
pathParamsType,
|
|
73
|
+
bodyType,
|
|
74
|
+
responseType,
|
|
75
75
|
isOpenApi,
|
|
76
76
|
};
|
|
77
77
|
}
|
package/package.json
CHANGED