@5minds/node-red-openapi-generator 1.1.2
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/.github/workflows/build-and-publish.yaml +104 -0
- package/.prettierrc.json +6 -0
- package/LICENSE +177 -0
- package/README.md +173 -0
- package/package.json +39 -0
- package/readme_images/Capture_00.PNG +0 -0
- package/readme_images/Capture_01.PNG +0 -0
- package/readme_images/Capture_02.PNG +0 -0
- package/readme_images/Capture_03.PNG +0 -0
- package/readme_images/Capture_04.PNG +0 -0
- package/readme_images/Capture_Swagger_UI.PNG +0 -0
- package/swagger/locales/en-US/swagger.json +72 -0
- package/swagger/swagger-ui/swagger-ui.html +396 -0
- package/swagger/swagger.html +959 -0
- package/swagger/swagger.js +277 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
name: Build and Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- '*'
|
|
7
|
+
- '*/*'
|
|
8
|
+
|
|
9
|
+
env:
|
|
10
|
+
CI_TOOLS_VERSION: '^5.0.0'
|
|
11
|
+
# NOTE: Um den Releasezyklus von Alpha nach Beta zu ändern, einfach die nachfolgend deklarierten Env Variablen switchen.
|
|
12
|
+
CI_TOOLS_ALPHA_BRANCH: next
|
|
13
|
+
CI_TOOLS_ALPHA_NPM_TAG: next
|
|
14
|
+
# CI_TOOLS_BETA_BRANCH: next
|
|
15
|
+
# CI_TOOLS_BETA_NPM_TAG: next
|
|
16
|
+
BOX_RELEASE_TAG: 2025-1
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
test:
|
|
20
|
+
name: 'Run Tests'
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
with:
|
|
25
|
+
fetch-depth: 0
|
|
26
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
27
|
+
|
|
28
|
+
- name: Use Node.js 22
|
|
29
|
+
uses: actions/setup-node@v4
|
|
30
|
+
with:
|
|
31
|
+
node-version: '22'
|
|
32
|
+
registry-url: 'https://registry.npmjs.org'
|
|
33
|
+
|
|
34
|
+
- name: Install Dependencies
|
|
35
|
+
run: npm ci
|
|
36
|
+
|
|
37
|
+
- name: Check if tests exist
|
|
38
|
+
id: check_tests
|
|
39
|
+
run: |
|
|
40
|
+
if grep -q '"test":' package.json && [ "$(npm pkg get scripts.test)" != '{}' ] && [ "$(npm pkg get scripts.test)" != 'null' ]; then
|
|
41
|
+
echo "has_tests=true" >> $GITHUB_OUTPUT
|
|
42
|
+
else
|
|
43
|
+
echo "has_tests=false" >> $GITHUB_OUTPUT
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
- name: Run tests
|
|
47
|
+
if: steps.check_tests.outputs.has_tests == 'true'
|
|
48
|
+
run: npm test
|
|
49
|
+
|
|
50
|
+
build_and_publish:
|
|
51
|
+
name: 'Build and publish sources'
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
needs: test
|
|
54
|
+
if: ${{ !(contains(github.actor, 'process-engine-ci') || contains(github.actor, 'admin')) }}
|
|
55
|
+
|
|
56
|
+
steps:
|
|
57
|
+
- uses: actions/checkout@v4
|
|
58
|
+
with:
|
|
59
|
+
fetch-depth: 0
|
|
60
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
61
|
+
|
|
62
|
+
- name: Use Node.js 22
|
|
63
|
+
uses: actions/setup-node@v4
|
|
64
|
+
with:
|
|
65
|
+
node-version: '22'
|
|
66
|
+
registry-url: 'https://registry.npmjs.org'
|
|
67
|
+
|
|
68
|
+
- name: Install CI Tools
|
|
69
|
+
env:
|
|
70
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
71
|
+
run: npm i -g @5minds/product_ci_tools@${{ env.CI_TOOLS_VERSION }}
|
|
72
|
+
|
|
73
|
+
- name: 'Install Dependencies'
|
|
74
|
+
env:
|
|
75
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
76
|
+
run: npm ci
|
|
77
|
+
|
|
78
|
+
- name: 'Prepare Version'
|
|
79
|
+
if: ${{ !startsWith(github.ref_name, 'renovate') }}
|
|
80
|
+
run: ci_tools prepare-version --allow-dirty-workdir
|
|
81
|
+
|
|
82
|
+
- name: 'Commit & Tag Version'
|
|
83
|
+
if: ${{ !startsWith(github.ref_name, 'renovate') }}
|
|
84
|
+
env:
|
|
85
|
+
GH_USER: ${{ github.actor }}
|
|
86
|
+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
87
|
+
run: |
|
|
88
|
+
ci_tools commit-and-tag-version --only-on-primary-branches
|
|
89
|
+
ci_tools update-github-release --only-on-primary-branches --use-title-and-text-from-git-tag
|
|
90
|
+
|
|
91
|
+
- name: 'Publish Version'
|
|
92
|
+
if: ${{ !startsWith(github.ref_name, 'renovate') }}
|
|
93
|
+
env:
|
|
94
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
95
|
+
run: ci_tools publish-npm-package --create-tag-from-branch-name
|
|
96
|
+
|
|
97
|
+
- name: Add Box-Release Tag
|
|
98
|
+
if: github.ref == 'refs/heads/main'
|
|
99
|
+
env:
|
|
100
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
101
|
+
run: |
|
|
102
|
+
VERSION="$(ci_tools get-version)"
|
|
103
|
+
PACKAGE_NAME="$(npm pkg get name | tr -d \")"
|
|
104
|
+
npm dist-tag add $PACKAGE_NAME@$VERSION ${{ env.BOX_RELEASE_TAG }}
|
package/.prettierrc.json
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# Node-RED OpenAPI3 Documentation Generator
|
|
2
|
+
|
|
3
|
+
This package provides a set of tools for generating OpenAPI3 documentation based on the HTTP nodes deployed in a flow.
|
|
4
|
+
|
|
5
|
+
It is a fork of the https://github.com/node-red/node-red-node-swagger repo with some significant updates of dependencies and restructuring due to the OpenAPI3-update. The package is not a complete implementation of all features of OpenAPI3 but some basics to generate correct .json files and Swagger-UI details.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
1. Install the node module
|
|
10
|
+
|
|
11
|
+
2. If you want to provide a template OpenAPI file in `settings.js`:
|
|
12
|
+
|
|
13
|
+
openapi: {
|
|
14
|
+
template: {
|
|
15
|
+
openapi: "3.0.0",
|
|
16
|
+
info: {
|
|
17
|
+
title: "My Node-RED API",
|
|
18
|
+
version: "0.0.1",
|
|
19
|
+
description: "API documentation generated by Node-RED"
|
|
20
|
+
},
|
|
21
|
+
servers: [
|
|
22
|
+
{
|
|
23
|
+
url: "http://localhost:1880/",
|
|
24
|
+
description: "Local server"
|
|
25
|
+
}
|
|
26
|
+
],
|
|
27
|
+
paths: {},
|
|
28
|
+
components: {
|
|
29
|
+
schemas: {},
|
|
30
|
+
responses: {},
|
|
31
|
+
parameters: {},
|
|
32
|
+
securitySchemes: {}
|
|
33
|
+
// Add other components here
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
3. This template will remain unchanged and serve as the basis for the OpenAPI documentation.
|
|
39
|
+
|
|
40
|
+
**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.
|
|
41
|
+
|
|
42
|
+
openapi: {
|
|
43
|
+
template: {
|
|
44
|
+
// ... (rest of your OpenAPI template)
|
|
45
|
+
},
|
|
46
|
+
components: {
|
|
47
|
+
schemas: {
|
|
48
|
+
MySchema: {
|
|
49
|
+
type: "object",
|
|
50
|
+
properties: {
|
|
51
|
+
name: {
|
|
52
|
+
type: "string"
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
securitySchemes: {
|
|
58
|
+
ApiKeyAuth: {
|
|
59
|
+
type: "apiKey",
|
|
60
|
+
in: "header",
|
|
61
|
+
name: "X-API-Key"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
// Add other reusable components here
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
4. After installing the package, you have the option to identify metadata for each HTTP-In node that will be used in the OpenAPI doc generation.
|
|
69
|
+
|
|
70
|
+
5. The generated OpenAPI documentation is then available at <http://localhost:1880/http-api/swagger.json>.
|
|
71
|
+
|
|
72
|
+
## Path OpenAPI Generation
|
|
73
|
+
|
|
74
|
+
Via the editor, you can define metadata for each particular HTTP-In node to be used in OpenAPI generation.
|
|
75
|
+
|
|
76
|
+
To do so:
|
|
77
|
+
|
|
78
|
+
1. Select an HTTP-In node in the editor.
|
|
79
|
+

|
|
80
|
+
|
|
81
|
+
2. From the config panel, you can select a user-defined OpenAPI doc from the dropdown. You may create a new metadata definition by selecting "Add new swagger-doc..." and clicking the edit button.
|
|
82
|
+

|
|
83
|
+
|
|
84
|
+
3. This will launch the OpenAPI config panel, where you have three distinct tabs that make up the OpenAPI documentation.
|
|
85
|
+
|
|
86
|
+
#### Info
|
|
87
|
+
|
|
88
|
+

|
|
89
|
+
|
|
90
|
+
This tab allows you to provide the basic information about the attached paths.
|
|
91
|
+
|
|
92
|
+
* Summary - A short summary of what the operation does. For maximum readability in the Swagger-UI, this field SHOULD be less than 120 characters.
|
|
93
|
+
* Description - A verbose explanation of the operation behavior. [GFM syntax](https://help.github.com/articles/github-flavored-markdown) can be used for rich text representation.
|
|
94
|
+
* Tags - A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier. These should be provided as a comma-separated list.
|
|
95
|
+
* Deprecated - Declares this operation to be deprecated. Usage of the declared operation should be refrained.
|
|
96
|
+
|
|
97
|
+
#### Parameters
|
|
98
|
+
|
|
99
|
+

|
|
100
|
+
|
|
101
|
+
This tab allows you to configure the parameters that can be used with the particular operation.
|
|
102
|
+
|
|
103
|
+
* Name - The name of the parameter. Parameter names are case sensitive.
|
|
104
|
+
* In - The location of the parameter. There are four supported locations of the parameter:
|
|
105
|
+
* _Query_ - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`.
|
|
106
|
+
* _Header_ - Custom headers that are expected as part of the request.
|
|
107
|
+
* Description - A brief description of the parameter. This could contain examples of use. [GFM syntax](https://help.github.com/articles/github-flavored-markdown) can be used for rich text representation.
|
|
108
|
+
* Required - Determines whether this parameter is mandatory.
|
|
109
|
+
* Type - The type of the parameter. Since the parameter is not located at the request body, it is limited to simple types (that is, not an object).
|
|
110
|
+
* Format - The extending format for the previously mentioned type.
|
|
111
|
+
|
|
112
|
+
If a body parameter is selected, the user will provide properties included in the body object, rather than specifying a type.
|
|
113
|
+
|
|
114
|
+
#### Responses
|
|
115
|
+
|
|
116
|
+

|
|
117
|
+
|
|
118
|
+
This tab allows you to define the applicable responses that a user may receive back from the operation.
|
|
119
|
+
|
|
120
|
+
* Code - You can either select to define the default response, or to provide a specific HTTP status code that the response will be applicable for. A default response is used to cover other undeclared responses.
|
|
121
|
+
* Description - A short description of the response. This could contain examples of use. [GFM syntax](https://help.github.com/articles/github-flavored-markdown) can be used for rich text representation.
|
|
122
|
+
* Properties - The properties are the components that build up the schema of the response.
|
|
123
|
+
* Name - The key name for the particular property.
|
|
124
|
+
* Type - The type of the property.
|
|
125
|
+
* Format - The extending format for the previously mentioned type.
|
|
126
|
+
|
|
127
|
+
If no responses are provided, a default response with the reply "success" will be used.
|
|
128
|
+
|
|
129
|
+
#### Request Body
|
|
130
|
+
|
|
131
|
+
This tab allows you to define the request body for the operation.
|
|
132
|
+
|
|
133
|
+
* Description - A brief description of the request body.
|
|
134
|
+
* Required - A checkbox to indicate if the request body is required.
|
|
135
|
+
* Content Type - The media type of the request body (e.g., application/json).
|
|
136
|
+
* JSON Schema - A text area where you can define the JSON schema for the request body.
|
|
137
|
+
Example JSON Schema:
|
|
138
|
+
```json
|
|
139
|
+
{
|
|
140
|
+
"type": "object",
|
|
141
|
+
"properties": {
|
|
142
|
+
"name": {
|
|
143
|
+
"type": "string",
|
|
144
|
+
"example": "John Doe"
|
|
145
|
+
},
|
|
146
|
+
"age": {
|
|
147
|
+
"type": "integer",
|
|
148
|
+
"example": 30
|
|
149
|
+
},
|
|
150
|
+
"email": {
|
|
151
|
+
"type": "string",
|
|
152
|
+
"format": "email",
|
|
153
|
+
"example": "john.doe@example.com"
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"required": ["name", "email"]
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## Swagger-UI
|
|
162
|
+
|
|
163
|
+

|
|
164
|
+
|
|
165
|
+
Swagger-UI is included in the plugin. Once loaded, the plugin will show a Swagger tab in the Node-RED sidebar. From here, you can see the dynamically generated OpenAPI documentation for the current flow. Additionally, you can use the test function to try out your API directly from the editor, providing any parameters you have defined in the docs for the HTTP-In nodes. The Swagger-UI will automatically refresh any time the flow is redeployed.
|
|
166
|
+
|
|
167
|
+
## Notes
|
|
168
|
+
|
|
169
|
+
- The `paths` entry of the OpenAPI documentation is generated based on the `HTTP In` nodes present in the flow.
|
|
170
|
+
- If an OpenAPI template is not provided, the example above is used as the default.
|
|
171
|
+
- If `basePath` is not set in the template, it is set to the value of `httpNodeRoot` if that value is something other than `/`.
|
|
172
|
+
|
|
173
|
+
###### 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)
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@5minds/node-red-openapi-generator",
|
|
3
|
+
"version": "1.1.2",
|
|
4
|
+
"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, based of the @digital-tvilling/node-red-openapi-generator.",
|
|
5
|
+
"license": "Apache",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/5minds/node-red-openapi-generator"
|
|
9
|
+
},
|
|
10
|
+
"authors": [
|
|
11
|
+
{
|
|
12
|
+
"name": "Diana Stefan",
|
|
13
|
+
"email": "diana.stefan@5Minds.de"
|
|
14
|
+
}
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"lint": "prettier --write --config ./.prettierrc.json \"**/*.{html,js}\""
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"node-red",
|
|
21
|
+
"swagger",
|
|
22
|
+
"open-api"
|
|
23
|
+
],
|
|
24
|
+
"node-red": {
|
|
25
|
+
"version": ">=4.2.0",
|
|
26
|
+
"nodes": {
|
|
27
|
+
"swagger": "swagger/swagger.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"conflicts": {
|
|
31
|
+
"node-red-node-swagger": "<0.3.0"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"swagger-ui-dist": "^5.29.0"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18.0.0"
|
|
38
|
+
}
|
|
39
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"swagger": {
|
|
3
|
+
"sidebar": {
|
|
4
|
+
"label": "swagger",
|
|
5
|
+
"name": "Swagger UI"
|
|
6
|
+
},
|
|
7
|
+
"label": {
|
|
8
|
+
"path": "Path",
|
|
9
|
+
"summary": "Summary",
|
|
10
|
+
"description": "Description",
|
|
11
|
+
"tags": "Tags",
|
|
12
|
+
"consumes": "Consumes",
|
|
13
|
+
"produces": "Produces",
|
|
14
|
+
"deprecated": "Deprecated",
|
|
15
|
+
"parameter": "parameter",
|
|
16
|
+
"parameters-help": "Parameters Help",
|
|
17
|
+
"response": "response",
|
|
18
|
+
"responses-help": "Responses Help",
|
|
19
|
+
"property": "property"
|
|
20
|
+
},
|
|
21
|
+
"placeholder": {
|
|
22
|
+
"tags": "Comma-separated list of Tags",
|
|
23
|
+
"consumes": "Comma-separated list of Mime Types",
|
|
24
|
+
"produces": "Comma-separated list of Mime Types"
|
|
25
|
+
},
|
|
26
|
+
"data-content": {
|
|
27
|
+
"summary": "A short summary of what the operation does. For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.",
|
|
28
|
+
"description": "A verbose explanation of the operation behavior. GitHub Flavored Markup syntax can be used for rich text representation.",
|
|
29
|
+
"tags": "A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.",
|
|
30
|
+
"consumes": "A list of MIME types the operation can consume.",
|
|
31
|
+
"produces": "A list of MIME types the operation can produce.",
|
|
32
|
+
"deprecated": "Declares this operation to be deprecated. Usage of the declared operation should be refrained."
|
|
33
|
+
},
|
|
34
|
+
"content": {
|
|
35
|
+
"parameter-info": "<div style=\"max-width: 450px\"><p>A list of parameters that are applicable for this operation.</p><p>To add a parameter, click the <span class='btn btn-mini' id='node-config-input-add-parameter'><i class='fa fa-plus'></i> parameter</span> button.</p><p>There are four possible parameter types.</p><ul><li>Query - Parameters that are appended to the URL. For example, in /items?id=###, the query parameter is id.</li><li>Header - Custom headers that are expected as part of the request.</li><li>Body - The payload that's appended to the HTTP request. Since there can only be one payload, there can only be one body parameter. The name of the body parameter has no effect on the parameter itself and is used for documentation purposes only.</li><li>Form - Used to describe the payload of an HTTP request when either application/x-www-form-urlencoded or multipart/form-data are used as the content type of the request (in Swagger's definition, the consumes property of an operation). This is the only parameter type that can be used to send files, thus supporting the file type.</li></ul></div>",
|
|
36
|
+
"response-info": "<div><p>The list of possible responses as they are returned from executing this operation.</p><p>You may supply responses for individual status codes, and/or a default response.</p><p>To add a parameter, click the <span class='btn btn-mini' id='node-config-input-add-parameter'><i class='fa fa-plus'></i> response</span> button.</p><p>If no responses are entered, a default response returning 'success' will be added for you.</p></div>",
|
|
37
|
+
"type": "The type of the attribute, limited to primitive types.",
|
|
38
|
+
"format": "The extending format for the previously mentioned type.",
|
|
39
|
+
"parameter-description": "A brief description of the parameter. This could contain examples of use. GitHub Flavored Markup syntax can be used for rich text representation.",
|
|
40
|
+
"required": "Determines whether this parameter is mandatory.",
|
|
41
|
+
"response-description": "A brief description of the response. This could contain examples of use. GitHub Flavored Markup syntax can be used for rich text representation."
|
|
42
|
+
},
|
|
43
|
+
"tabs-label": {
|
|
44
|
+
"info": "Info",
|
|
45
|
+
"parameters": "Parameters",
|
|
46
|
+
"responses": "Responses",
|
|
47
|
+
"requestBody": "Request Body"
|
|
48
|
+
},
|
|
49
|
+
"text": {
|
|
50
|
+
"type": "Type",
|
|
51
|
+
"format": "Format",
|
|
52
|
+
"name": "Name",
|
|
53
|
+
"in": "in",
|
|
54
|
+
"path": "path",
|
|
55
|
+
"description": "Description",
|
|
56
|
+
"required": "Required?",
|
|
57
|
+
"properties": "Properties",
|
|
58
|
+
"file": "file",
|
|
59
|
+
"code": "Code",
|
|
60
|
+
"default": "Default"
|
|
61
|
+
},
|
|
62
|
+
"helpBox": {
|
|
63
|
+
"title": "I see you're lacking Swagger doc...",
|
|
64
|
+
"swaggerIntro": "Swagger is a simple yet powerful way to document your REST API.",
|
|
65
|
+
"swaggerInfo": "The Swagger plug-in dynamically generates Swagger documentation based on input provided when setting up your HTTP endpoint nodes.",
|
|
66
|
+
"swaggerInstructions0": "After building your REST APIs in the editor, click the HTTP endpoint node. You can then attach additional Swagger documentation to that node by clicking the add button next to Docs.",
|
|
67
|
+
"swaggerInstructions1": "You are able to add additional details on the types of inputs and outputs expected from your endpoint by quickly navigating through the screens and providing some information.",
|
|
68
|
+
"swaggerInstructions2": "Once your flow is deployed, this tab will be automatically populated by a visual representation of your API.",
|
|
69
|
+
"swaggerOutro": "You can then use this Swagger-UI tab to effortlessly test your APIs."
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|