From 63e65abd0013eb3e2e920333e4bffb25875d3bae Mon Sep 17 00:00:00 2001 From: fasblom Date: Sun, 28 Jan 2024 08:38:08 +0100 Subject: [PATCH 01/20] Upgraded dependencies --- package.json | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 0e0f8e8..74f3b62 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-red-node-swagger", - "version": "0.1.9", + "version": "0.2.0", "description": "A set of tools for generating Swagger API documentation based on the HTTP nodes deployed in a flow", "license": "Apache", "repository": { @@ -9,10 +9,11 @@ }, "keywords": [ "node-red", - "swagger" + "swagger", + "open-api" ], "node-red": { - "version": ">=0.11.0", + "version": ">=3.0.0", "nodes": { "swagger": "swagger/swagger.js" } @@ -23,10 +24,11 @@ "Jon Silver " ], "dependencies": { - "swagger-ui": "2.1.4", - "i18next-client": "1.11.4" + "i18next": "^23.7.20", + "swagger-ui": "^5.11.1", + "swagger-ui-dist": "^5.11.1" }, "devDependencies": { - "eslint": "^6.4.0" + "eslint": "^8.56.0" } } From 48af206708340a146f6b5ffa93a34cfd6cb4fff2 Mon Sep 17 00:00:00 2001 From: fasblom Date: Sun, 28 Jan 2024 08:38:20 +0100 Subject: [PATCH 02/20] updated basics in readme --- README.md | 76 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index 12e566a..00b41f8 100644 --- a/README.md +++ b/README.md @@ -13,39 +13,61 @@ based on the HTTP nodes deployed in a flow. npm install node-red/node-red-node-swagger -2. Provide a template swagger file in `settings.js`: - - swagger: { - "template": { - "swagger": "2.0", - "info": { - "title": "My Node-RED API", - "version": "0.0.1" +2. Provide a template OpenAPI file in `settings.js`: + + openapi: { + template: { + openapi: "3.0.0", + info: { + title: "My Node-RED API", + version: "0.0.1", + description: "API documentation generated by Node-RED" + }, + servers: [ + { + url: "http://localhost:1880/", + description: "Local server" + } + ], + paths: {}, + components: { + schemas: {}, + responses: {}, + parameters: {}, + securitySchemes: {} + // Add other components here } } } -3. This template will remain unchanged and serve as the basis for the swagger doc. +3. This template will remain unchanged and serve as the basis for the OpenAPI documentation. - **Note:** You may additionally add parameters to the swagger file in 'settings.js' to have those parameters automatically added to each path in the generated swagger doc. - - "swagger": { - "template": { - "swagger": "2.0", - "info": { - "title": "My Node-RED API", - "version": "0.0.1" - } + **Note:** You may additionally add components like `schemas`, `responses`, `parameters`, `securitySchemes`, etc., to the OpenAPI file in 'settings.js' to have those components available for reuse in the generated OpenAPI documentation. + + openapi: { + template: { + // ... (rest of your OpenAPI template) }, - "parameters": [ - { - "name": "parameterA", - "type": "string", - "in": "header", - "required": false, - "description": "This is a test parameter to show how parameters are automatically added to each path in the generated swagger doc." + components: { + schemas: { + MySchema: { + type: "object", + properties: { + name: { + type: "string" + } + } + } + }, + securitySchemes: { + ApiKeyAuth: { + type: "apiKey", + in: "header", + name: "X-API-Key" + } } - ] + // Add other reusable components here + } } 4. After installing the package, you have the option to identify metadata for each HTTP-In node that will be used in the swagger doc generation. @@ -131,4 +153,4 @@ Swagger-UI is including in the plugin. Once loaded, the plugin will show a swagg if that value is something other than `/`. -###### Attribute definitions provided come from the [Swagger 2.0 Spec](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md) \ No newline at end of file +###### Attribute definitions provided come from the [OpenAPI Specification Version 3.1.0](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md) \ No newline at end of file From 3a23fb37327a69893279f03896d30825ee7465b4 Mon Sep 17 00:00:00 2001 From: fasblom Date: Sun, 4 Feb 2024 10:52:01 +0100 Subject: [PATCH 03/20] ignore package-lock.json --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b512c09..25c8fdb 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -node_modules \ No newline at end of file +node_modules +package-lock.json \ No newline at end of file From 3e35e914297ceb280125e58e6034ca5f33f531ca Mon Sep 17 00:00:00 2001 From: fasblom Date: Sun, 4 Feb 2024 11:50:33 +0100 Subject: [PATCH 04/20] Basic working example compliant with openapi3 --- swagger/swagger-ui/swagger-ui.html | 16 +- swagger/swagger.js | 278 ++++++++++++++++++++++++++--- 2 files changed, 269 insertions(+), 25 deletions(-) diff --git a/swagger/swagger-ui/swagger-ui.html b/swagger/swagger-ui/swagger-ui.html index ddb91e5..36cdeb8 100644 --- a/swagger/swagger-ui/swagger-ui.html +++ b/swagger/swagger-ui/swagger-ui.html @@ -1,13 +1,14 @@ Swagger UI + + + + + + + + + - - - - - - - - + - -
-

- - -

-

swagger.helpBox.title

-

swagger.helpBox.swaggerIntro

-

swagger.helpBox.swaggerInfo

-

swagger.helpBox.swaggerInstructions0

-

swagger.helpBox.swaggerInstructions1

-

swagger.helpBox.swaggerInstructions2

-

swagger.helpBox.swaggerOutro

-

-
- + +
+ + + + From 339b6b5e8f653cde5486a26b1633f6d8673c75bc Mon Sep 17 00:00:00 2001 From: fasblom Date: Sun, 4 Feb 2024 16:47:45 +0100 Subject: [PATCH 08/20] Removed help section on parameters and status --- swagger/swagger.html | 7 ------- 1 file changed, 7 deletions(-) diff --git a/swagger/swagger.html b/swagger/swagger.html index 1b2e1dd..4c1377e 100644 --- a/swagger/swagger.html +++ b/swagger/swagger.html @@ -55,15 +55,8 @@
    -
    - - -
    -
    -
      -
      From 8948c12a46892020362eccaa6c72884d5c36ff57 Mon Sep 17 00:00:00 2001 From: fasblom Date: Sun, 4 Feb 2024 17:17:55 +0100 Subject: [PATCH 09/20] Removed not needed load --- swagger/swagger.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/swagger/swagger.html b/swagger/swagger.html index 4c1377e..f0ee5ac 100644 --- a/swagger/swagger.html +++ b/swagger/swagger.html @@ -118,6 +118,7 @@ swaggerUi.load(); } }); + swaggerDocUrl = window.location.protocol + "//" + window.location.hostname + ":" + window.location.port + RED.settings.httpNodeRoot + 'http-api/swagger.json'; var swaggerFrame = $("