Skip to content

Commit 48af206

Browse files
committed
updated basics in readme
1 parent 63e65ab commit 48af206

File tree

1 file changed

+49
-27
lines changed

1 file changed

+49
-27
lines changed

README.md

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,39 +13,61 @@ based on the HTTP nodes deployed in a flow.
1313

1414
npm install node-red/node-red-node-swagger
1515

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
2439
}
2540
}
2641
}
2742

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.
2944

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)
3950
},
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+
}
4768
}
48-
]
69+
// Add other reusable components here
70+
}
4971
}
5072

5173
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
131153
if that value is something other than `/`.
132154

133155

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

Comments
 (0)