@fluojs/openapi 1.0.3 → 2.0.0
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.ko.md +80 -11
- package/README.md +80 -11
- package/dist/decorators.d.ts +7 -5
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +9 -7
- package/dist/openapi-module.d.ts +26 -8
- package/dist/openapi-module.d.ts.map +1 -1
- package/dist/openapi-module.js +39 -44
- package/dist/path-item.d.ts +62 -0
- package/dist/path-item.d.ts.map +1 -0
- package/dist/path-item.js +53 -0
- package/dist/schema-bounds.d.ts +9 -0
- package/dist/schema-bounds.d.ts.map +1 -0
- package/dist/schema-bounds.js +175 -0
- package/dist/schema-builder.d.ts +3 -6
- package/dist/schema-builder.d.ts.map +1 -1
- package/dist/schema-builder.js +27 -14
- package/dist/swagger-ui.d.ts +29 -0
- package/dist/swagger-ui.d.ts.map +1 -0
- package/dist/swagger-ui.js +67 -0
- package/package.json +8 -7
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const SWAGGER_UI_DIST_VERSION = '5.32.2';
|
|
2
|
+
const SWAGGER_UI_DIST_BASE_URL = `https://unpkg.com/swagger-ui-dist@${SWAGGER_UI_DIST_VERSION}`;
|
|
3
|
+
const SWAGGER_UI_CSS_URL = `${SWAGGER_UI_DIST_BASE_URL}/swagger-ui.css`;
|
|
4
|
+
const SWAGGER_UI_BUNDLE_JS_URL = `${SWAGGER_UI_DIST_BASE_URL}/swagger-ui-bundle.js`;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Asset URLs used by the generated Swagger UI HTML page.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
function escapeHtml(value) {
|
|
11
|
+
return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
|
12
|
+
}
|
|
13
|
+
function escapeRegularExpression(value) {
|
|
14
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
15
|
+
}
|
|
16
|
+
function serializeInlineScriptString(value) {
|
|
17
|
+
return JSON.stringify(value).replace(/</g, '\\u003c').replace(/>/g, '\\u003e').replace(/&/g, '\\u0026');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Resolve pinned or caller-provided Swagger UI asset URLs.
|
|
22
|
+
*
|
|
23
|
+
* @param assets Optional caller-provided asset URLs.
|
|
24
|
+
* @returns Complete asset URLs for generated Swagger UI HTML.
|
|
25
|
+
*/
|
|
26
|
+
export function resolveSwaggerUiAssets(assets) {
|
|
27
|
+
return {
|
|
28
|
+
cssUrl: assets?.cssUrl ?? SWAGGER_UI_CSS_URL,
|
|
29
|
+
jsBundleUrl: assets?.jsBundleUrl ?? SWAGGER_UI_BUNDLE_JS_URL
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Render Swagger UI HTML for one configured OpenAPI document route.
|
|
35
|
+
*
|
|
36
|
+
* @param title Document title rendered into the page.
|
|
37
|
+
* @param assets Complete Swagger UI asset URLs.
|
|
38
|
+
* @param routes Normalized JSON document and UI routes.
|
|
39
|
+
* @returns A standalone Swagger UI HTML document.
|
|
40
|
+
*/
|
|
41
|
+
export function createSwaggerUiHtml(title, assets, routes) {
|
|
42
|
+
const uiPathPattern = routes.uiPath === '/' ? '/?$' : `${escapeRegularExpression(routes.uiPath)}/?$`;
|
|
43
|
+
return `<!doctype html>
|
|
44
|
+
<html lang="en">
|
|
45
|
+
<head>
|
|
46
|
+
<meta charset="utf-8" />
|
|
47
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
48
|
+
<title>${escapeHtml(title)}</title>
|
|
49
|
+
<link rel="stylesheet" href="${escapeHtml(assets.cssUrl)}" />
|
|
50
|
+
</head>
|
|
51
|
+
<body>
|
|
52
|
+
<div id="swagger-ui"></div>
|
|
53
|
+
<script src="${escapeHtml(assets.jsBundleUrl)}" crossorigin></script>
|
|
54
|
+
<script>
|
|
55
|
+
const specUrl = window.location.pathname.replace(
|
|
56
|
+
new RegExp(${serializeInlineScriptString(uiPathPattern)}),
|
|
57
|
+
() => ${serializeInlineScriptString(routes.documentPath)}
|
|
58
|
+
);
|
|
59
|
+
const swaggerUi = SwaggerUIBundle({
|
|
60
|
+
url: specUrl,
|
|
61
|
+
dom_id: '#swagger-ui'
|
|
62
|
+
});
|
|
63
|
+
void swaggerUi;
|
|
64
|
+
</script>
|
|
65
|
+
</body>
|
|
66
|
+
</html>`;
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"documentation",
|
|
10
10
|
"rest"
|
|
11
11
|
],
|
|
12
|
-
"version": "
|
|
12
|
+
"version": "2.0.0",
|
|
13
13
|
"private": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"repository": {
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"directory": "packages/openapi"
|
|
19
19
|
},
|
|
20
20
|
"engines": {
|
|
21
|
-
"node": ">=
|
|
21
|
+
"node": ">=24.0.0 <27"
|
|
22
22
|
},
|
|
23
23
|
"publishConfig": {
|
|
24
24
|
"access": "public"
|
|
@@ -36,13 +36,14 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@fluojs/
|
|
40
|
-
"@fluojs/
|
|
41
|
-
"@fluojs/
|
|
42
|
-
"@fluojs/runtime": "^1.1.1"
|
|
39
|
+
"@fluojs/core": "^2.0.0",
|
|
40
|
+
"@fluojs/http": "^3.0.0",
|
|
41
|
+
"@fluojs/runtime": "^3.0.0"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
|
-
"vitest": "^
|
|
44
|
+
"vitest": "^4.1.11",
|
|
45
|
+
"@fluojs/platform-nodejs": "^2.0.0",
|
|
46
|
+
"@fluojs/validation": "^2.0.0"
|
|
46
47
|
},
|
|
47
48
|
"scripts": {
|
|
48
49
|
"prebuild": "node ../../tooling/scripts/clean-dist.mjs",
|