@scalar/nextjs-openapi 0.3.39 → 0.3.41
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/CHANGELOG.md +8 -0
- package/dist/path.d.ts.map +1 -1
- package/dist/path.js +11 -7
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @scalar/nextjs-openapi
|
|
2
2
|
|
|
3
|
+
## 0.3.41
|
|
4
|
+
|
|
5
|
+
## 0.3.40
|
|
6
|
+
|
|
7
|
+
### Patch Changes
|
|
8
|
+
|
|
9
|
+
- [#10135](https://github.com/scalar/scalar/pull/10135): Extract parameters and JSON responses from variable handlers, including concise arrows and multiple declarations. Safely read declaration names and JSDoc.
|
|
10
|
+
|
|
3
11
|
## 0.3.39
|
|
4
12
|
|
|
5
13
|
## 0.3.38
|
package/dist/path.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,UAAU,
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../src/path.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,EAGL,KAAK,OAAO,EACZ,KAAK,UAAU,EAShB,MAAM,YAAY,CAAA;AAoDnB;;GAEG;AACH,eAAO,MAAM,aAAa,GAAI,YAAY,UAAU,EAAE,SAAS,OAAO,KAAG,WAAW,CAAC,WA8CpF,CAAA"}
|
package/dist/path.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { extname, join } from 'node:path';
|
|
2
2
|
import { generateResponses, getJSDocFromNode, getSchemaFromTypeNode } from '@scalar/ts-to-openapi';
|
|
3
|
-
import { isFunctionDeclaration, isIdentifier, isParameter, isPropertySignature, isTypeLiteralNode, isVariableStatement, } from 'typescript';
|
|
3
|
+
import { isArrowFunction, isFunctionDeclaration, isFunctionExpression, isIdentifier, isParameter, isPropertySignature, isTypeLiteralNode, isVariableStatement, } from 'typescript';
|
|
4
4
|
/** Check if identifier is a supported http method */
|
|
5
5
|
const checkForMethod = (identifier) => {
|
|
6
6
|
const method = identifier?.escapedText?.toLowerCase();
|
|
@@ -63,17 +63,21 @@ export const getPathSchema = (sourceFile, program) => {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
//
|
|
66
|
+
// A statement can declare several route handlers alongside other variables.
|
|
67
67
|
else if (isVariableStatement(statement)) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
for (const declaration of statement.declarationList.declarations) {
|
|
69
|
+
const method = isIdentifier(declaration.name) ? checkForMethod(declaration.name) : null;
|
|
70
|
+
if (!method) {
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
71
73
|
const { title, description } = getJSDocFromNode(statement);
|
|
72
|
-
const
|
|
74
|
+
const initializer = declaration.initializer;
|
|
75
|
+
const handler = initializer && (isArrowFunction(initializer) || isFunctionExpression(initializer)) ? initializer : undefined;
|
|
73
76
|
path[method] = {
|
|
74
77
|
summary: title,
|
|
75
78
|
description,
|
|
76
|
-
|
|
79
|
+
...(handler ? { parameters: extractPathParams(handler.parameters[1], program) } : {}),
|
|
80
|
+
responses: generateResponses(handler, typeChecker),
|
|
77
81
|
};
|
|
78
82
|
}
|
|
79
83
|
}
|
package/package.json
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"scalar",
|
|
17
17
|
"references"
|
|
18
18
|
],
|
|
19
|
-
"version": "0.3.
|
|
19
|
+
"version": "0.3.41",
|
|
20
20
|
"engines": {
|
|
21
21
|
"node": ">=22"
|
|
22
22
|
},
|
|
@@ -33,10 +33,10 @@
|
|
|
33
33
|
"CHANGELOG.md"
|
|
34
34
|
],
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"
|
|
37
|
-
"@scalar/
|
|
38
|
-
"@scalar/types": "0.
|
|
39
|
-
"
|
|
36
|
+
"@scalar/nextjs-api-reference": "0.12.1",
|
|
37
|
+
"@scalar/ts-to-openapi": "0.2.5",
|
|
38
|
+
"@scalar/types": "0.20.1",
|
|
39
|
+
"fast-glob": "^3.3.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/node": "^24.1.0",
|