You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-27Lines changed: 49 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,39 +13,61 @@ based on the HTTP nodes deployed in a flow.
13
13
14
14
npm install node-red/node-red-node-swagger
15
15
16
-
2. Provide a template swagger file in `settings.js`:
17
-
18
-
swagger: {
19
-
"template": {
20
-
"swagger": "2.0",
21
-
"info": {
22
-
"title": "My Node-RED API",
23
-
"version": "0.0.1"
16
+
2. Provide a template OpenAPI file in `settings.js`:
17
+
18
+
openapi: {
19
+
template: {
20
+
openapi: "3.0.0",
21
+
info: {
22
+
title: "My Node-RED API",
23
+
version: "0.0.1",
24
+
description: "API documentation generated by Node-RED"
25
+
},
26
+
servers: [
27
+
{
28
+
url: "http://localhost:1880/",
29
+
description: "Local server"
30
+
}
31
+
],
32
+
paths: {},
33
+
components: {
34
+
schemas: {},
35
+
responses: {},
36
+
parameters: {},
37
+
securitySchemes: {}
38
+
// Add other components here
24
39
}
25
40
}
26
41
}
27
42
28
-
3. This template will remain unchanged and serve as the basis for the swagger doc.
43
+
3. This template will remain unchanged and serve as the basis for the OpenAPI documentation.
29
44
30
-
**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.
31
-
32
-
"swagger": {
33
-
"template": {
34
-
"swagger": "2.0",
35
-
"info": {
36
-
"title": "My Node-RED API",
37
-
"version": "0.0.1"
38
-
}
45
+
**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.
46
+
47
+
openapi: {
48
+
template: {
49
+
// ... (rest of your OpenAPI template)
39
50
},
40
-
"parameters": [
41
-
{
42
-
"name": "parameterA",
43
-
"type": "string",
44
-
"in": "header",
45
-
"required": false,
46
-
"description": "This is a test parameter to show how parameters are automatically added to each path in the generated swagger doc."
51
+
components: {
52
+
schemas: {
53
+
MySchema: {
54
+
type: "object",
55
+
properties: {
56
+
name: {
57
+
type: "string"
58
+
}
59
+
}
60
+
}
61
+
},
62
+
securitySchemes: {
63
+
ApiKeyAuth: {
64
+
type: "apiKey",
65
+
in: "header",
66
+
name: "X-API-Key"
67
+
}
47
68
}
48
-
]
69
+
// Add other reusable components here
70
+
}
49
71
}
50
72
51
73
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
131
153
if that value is something other than `/`.
132
154
133
155
134
-
###### Attribute definitions provided come from the [Swagger 2.0 Spec](https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md)
156
+
###### 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)
0 commit comments