From 7e434f2277dbc81b7ecc585af72fc0084185fb78 Mon Sep 17 00:00:00 2001 From: Sebastian Meier Date: Wed, 17 Jul 2024 08:29:33 +0000 Subject: [PATCH 1/9] use full instead of relative url + includes httpNodeRoot --- swagger/swagger-ui/swagger-ui.html | 9 ++++++++- swagger/swagger.html | 10 ---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/swagger/swagger-ui/swagger-ui.html b/swagger/swagger-ui/swagger-ui.html index 1f10733..686c67c 100644 --- a/swagger/swagger-ui/swagger-ui.html +++ b/swagger/swagger-ui/swagger-ui.html @@ -12,8 +12,15 @@ + + From d33fda0070eb25e2a8b5bdd6d6f27bf9c80d3028 Mon Sep 17 00:00:00 2001 From: Sebastian Meier Date: Thu, 18 Jul 2024 06:26:44 +0000 Subject: [PATCH 3/9] added npmignore --- .npmignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..233bd07 --- /dev/null +++ b/.npmignore @@ -0,0 +1 @@ +readme_images \ No newline at end of file From 8a36572d1950909f7b8d619b36c24cc0b3c1d45e Mon Sep 17 00:00:00 2001 From: Sebastian Meier Date: Thu, 18 Jul 2024 06:51:13 +0000 Subject: [PATCH 4/9] css label fix --- swagger/swagger.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/swagger/swagger.html b/swagger/swagger.html index f8dd0bc..9fd0011 100644 --- a/swagger/swagger.html +++ b/swagger/swagger.html @@ -75,7 +75,7 @@
- +
@@ -1049,8 +1049,9 @@ float: right; vertical-align: middle; } - .node-swagger-full-label-width { - width: auto; + .form-row label.node-swagger-full-label-width { + width: fit-content; + text-wrap: nowrap; } .node-swagger-prop-name-label { width: 100px; From 2353195878f84386c96090d67ae62063b49676fd Mon Sep 17 00:00:00 2001 From: Sebastian Meier Date: Thu, 18 Jul 2024 08:06:54 +0000 Subject: [PATCH 5/9] added request body warning and remove it for some types if not set --- package.json | 2 +- swagger/swagger.html | 14 +++++++++++++- swagger/swagger.js | 5 ++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6d701cf..115813d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@digital-tvilling/node-red-openapi-generator", - "version": "1.1.1", + "version": "1.1.2", "description": "A set of tools for generating OpenAPI3/Swagger documentation based on the HTTP nodes deployed in a flow. An updated version of the Node-RED Swagger Documentation Generator to support OpenAPI3.", "license": "Apache", "repository": { diff --git a/swagger/swagger.html b/swagger/swagger.html index 9fd0011..746206a 100644 --- a/swagger/swagger.html +++ b/swagger/swagger.html @@ -28,7 +28,7 @@
- +
@@ -62,6 +62,9 @@
+
+ Methods like "GET", "HEAD" or "DELETE" should not have a request body. +
@@ -695,6 +698,11 @@ setTimeout(function () { tabs.resize(); }, 10); + + // show / hide request body warning for some methods + if (["GET", "HEAD", "DELETE"].includes($("#node-config-input-method").text())) { + $("#swagger-method-requestBody-warning")[0]?.classList?.remove("hide") + } } RED.nodes.registerType("swagger-doc", { @@ -1057,4 +1065,8 @@ width: 100px; margin-right: 10px; } + #swagger-method-requestBody-warning { + margin: 20px 0; + color: var(--red-ui-text-color-warning); + } diff --git a/swagger/swagger.js b/swagger/swagger.js index d81418b..ba403f5 100644 --- a/swagger/swagger.js +++ b/swagger/swagger.js @@ -79,13 +79,16 @@ module.exports = function (RED) { ); if (!resp.paths[endPoint]) resp.paths[endPoint] = {}; + // request body is permitted in methods GET, HEAD, DELETE but should be avoided https://swagger.io/specification/#operation-object + // editors will show invalid if those methods have an request body -> if not explicit set, do not set it + const avoidRequestBody = ['get', 'head', 'delete'] const { summary = swaggerDocNode.summary || name || method + " " + endPoint, description = swaggerDocNode.description || "", tags = swaggerDocNode.tags || "", deprecated = swaggerDocNode.deprecated || false, parameters = swaggerDocNode.parameters || [], - requestBody = swaggerDocNode.requestBody || {}, + requestBody = swaggerDocNode.requestBody || (avoidRequestBody.includes(method.toLowerCase()) ? undefined : {}), } = swaggerDocNode; const aryTags = csvStrToArray(tags); From 3c277fae66b7adc6e0a1bf0d04104a67b154ddb9 Mon Sep 17 00:00:00 2001 From: meijey <86828187+meijey@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:38:45 +0200 Subject: [PATCH 6/9] Update swagger-ui.html url fix --- swagger/swagger-ui/swagger-ui.html | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/swagger/swagger-ui/swagger-ui.html b/swagger/swagger-ui/swagger-ui.html index 686c67c..a4a2ff4 100644 --- a/swagger/swagger-ui/swagger-ui.html +++ b/swagger/swagger-ui/swagger-ui.html @@ -16,7 +16,11 @@ if (window.parent) { // get full url with node-RED settings (like original node-red-node-swagger) const parentLocation = window.parent.location - swaggerDocUrl = parentLocation.protocol + "//" + parentLocation.hostname + ":" + parentLocation.port + window.parent.RED.settings.httpNodeRoot + "http-api/swagger.json"; + swaggerDocUrl = parentLocation.protocol + "//" + parentLocation.hostname + ":" + parentLocation.port + window.parent.RED.settings.httpNodeRoot + if (!swaggerDocUrl.endsWith('/') { + swaggerDocUrl =+ "/"; + } + swaggerDocUrl =+ "http-api/swagger.json"; } const ui = SwaggerUIBundle({ From abcf48975b6c149baeba7aa0f2e6d899d4065a77 Mon Sep 17 00:00:00 2001 From: meijey <86828187+meijey@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:41:52 +0200 Subject: [PATCH 7/9] Update swagger-ui.html --- swagger/swagger-ui/swagger-ui.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/swagger/swagger-ui/swagger-ui.html b/swagger/swagger-ui/swagger-ui.html index a4a2ff4..63ef45a 100644 --- a/swagger/swagger-ui/swagger-ui.html +++ b/swagger/swagger-ui/swagger-ui.html @@ -17,7 +17,7 @@ // get full url with node-RED settings (like original node-red-node-swagger) const parentLocation = window.parent.location swaggerDocUrl = parentLocation.protocol + "//" + parentLocation.hostname + ":" + parentLocation.port + window.parent.RED.settings.httpNodeRoot - if (!swaggerDocUrl.endsWith('/') { + if (!swaggerDocUrl.endsWith('/')) { swaggerDocUrl =+ "/"; } swaggerDocUrl =+ "http-api/swagger.json"; From 705085bf89b162cf885e5231a2c0ed118215e693 Mon Sep 17 00:00:00 2001 From: meijey <86828187+meijey@users.noreply.github.com> Date: Tue, 30 Jul 2024 13:45:10 +0200 Subject: [PATCH 8/9] fixed URL (for real this time) --- swagger/swagger-ui/swagger-ui.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/swagger/swagger-ui/swagger-ui.html b/swagger/swagger-ui/swagger-ui.html index 63ef45a..9406f63 100644 --- a/swagger/swagger-ui/swagger-ui.html +++ b/swagger/swagger-ui/swagger-ui.html @@ -18,9 +18,9 @@ const parentLocation = window.parent.location swaggerDocUrl = parentLocation.protocol + "//" + parentLocation.hostname + ":" + parentLocation.port + window.parent.RED.settings.httpNodeRoot if (!swaggerDocUrl.endsWith('/')) { - swaggerDocUrl =+ "/"; + swaggerDocUrl += "/"; } - swaggerDocUrl =+ "http-api/swagger.json"; + swaggerDocUrl += "http-api/swagger.json"; } const ui = SwaggerUIBundle({ From 0947fab12e3736f8ffc6fd6ce972950d117c2b90 Mon Sep 17 00:00:00 2001 From: Sebastian Meier Date: Thu, 19 Dec 2024 10:46:05 +0000 Subject: [PATCH 9/9] added header and cookie parameter --- .npmignore | 3 ++- CHANGELOG.md | 12 ++++++++++++ package.json | 13 ++++++++----- scripts/setup.sh | 11 +++++++++++ swagger/swagger.html | 10 +++++----- 5 files changed, 38 insertions(+), 11 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 scripts/setup.sh diff --git a/.npmignore b/.npmignore index 233bd07..f9f78c9 100644 --- a/.npmignore +++ b/.npmignore @@ -1 +1,2 @@ -readme_images \ No newline at end of file +readme_images +scripts \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..3614113 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,12 @@ +> **Attention:** ⚠️ means that a change breaks things. Manual adjustments will be necessary. So be careful before updating. Even data loss might occur. + +**Version 1.1.3 (19th of December 2024)** +- added missing path and cookie selection +- added links to official openAPI documentation + +**Version 1.1.2 (18th of July 2024)** +- updated dependencies +- Theme compatibility +- UI fixes (fixed label / input field lengths) +- Using full URL for the swagger-ui-tab +- Warning for "GET", "HEAD" and "DELETE" in request body tab \ No newline at end of file diff --git a/package.json b/package.json index 115813d..f788231 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@digital-tvilling/node-red-openapi-generator", - "version": "1.1.2", + "version": "1.1.3", "description": "A set of tools for generating OpenAPI3/Swagger documentation based on the HTTP nodes deployed in a flow. An updated version of the Node-RED Swagger Documentation Generator to support OpenAPI3.", "license": "Apache", "repository": { @@ -28,14 +28,17 @@ "Filip Åsblom " ], "dependencies": { - "i18next": "^23.11.5", - "swagger-ui": "^5.17.14", - "swagger-ui-dist": "^5.17.14" + "i18next": "^23.16.8", + "swagger-ui": "^5.18.2", + "swagger-ui-dist": "^5.18.2" }, "devDependencies": { "eslint": "^ 9.5.0" }, "engines": { "node": ">=18.0.0" - } + }, + "scripts": { + "setup": "./scripts/setup.sh" + } } diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100644 index 0000000..44b4515 --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Install dependencies +npm install +# Initialize sample project +mkdir -p /home/gitpod/.node-red +cd /home/gitpod/.node-red/ +npm install +npm link /workspace/node-red-openapi-generator --save + +# Go back to workspace directory +cd /workspace/node-red-openapi-generator \ No newline at end of file diff --git a/swagger/swagger.html b/swagger/swagger.html index 746206a..31d40e7 100644 --- a/swagger/swagger.html +++ b/swagger/swagger.html @@ -44,21 +44,21 @@
-
+
    - +
    -
    +
      - +
      @@ -306,7 +306,7 @@ class: "node-swagger-in-select", style: "max-width: 150px", }).appendTo(inSpan); - ["query", "header"].forEach(function (opt) { + ["header", "path", "query", "cookie"].forEach(function (opt) { inSelect.append($("").val(opt).text(opt)); }); inSelect.val(opts.in);