Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
kg-node-red-node-swagger
Advanced tools
A set of tools for generating Swagger API documentation based on the HTTP nodes deployed in a flow
This package provides a set of tools for generating Swagger api documentation based on the HTTP nodes deployed in a flow.
Install the node module
npm install node-red-node-swagger
Note: until this is published to npm, you will need to install from git:
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"
}
}
}
3. This template will remain unchanged and serve as the basis for the swagger doc.
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"
}
},
"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."
}
]
}
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.
Via the editor, you can define metadata for each particular HTTP-In node to be used in swagger generation.
To do so,
Select an HTTP-In node in the editor.
From the config panel, you can select a user-defined swagger doc from the dropdown. You may create a new metadata definition by selecting "Add new swagger-doc..." and clicking the edit button.
This will launch the swagger config panel, where you have three distinct tabs that make up the swagger documentation.
This tab allows you to provide the basic information about the attached paths.
This tab allows you to configure the parameters that can be used with the particular operation.
/items?id=###
, the query parameter is id
.application/x-www-form-urlencoded
or multipart/form-data
are used as the content type of the request. This is the only parameter type that can be used to send files, thus supporting the file
type. Since form parameters are sent in the payload, they cannot be declared together with a body parameter for the same operation. Form parameters have a different format based on the content-type used (for further details, consult http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4):If a body parameter is selected, the user will provide properties included in the body object, rather than specifying a type.
This tab allows you to define the applicable responses that a user may receive back from the operation.
If no responses are provided, a default response with the reply "success" will be used.
##Swagger-UI
Swagger-UI is including 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 swagger 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.
the paths
entry of the swagger is generated based on the HTTP In
nodes
present in the flow.
if a swagger template is not provided, the example above is used as the default.
if basePath
is not set in the template, it is set to the value of httpNodeRoot
if that value is something other than /
.
FAQs
A set of tools for generating Swagger API documentation based on the HTTP nodes deployed in a flow
The npm package kg-node-red-node-swagger receives a total of 3 weekly downloads. As such, kg-node-red-node-swagger popularity was classified as not popular.
We found that kg-node-red-node-swagger demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.