Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions swagger/locales/en-US/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"summary": "Summary",
"description": "Description",
"tags": "Tags",
"operationId": "OperationId",
"consumes": "Consumes",
"produces": "Produces",
"deprecated": "Deprecated",
Expand All @@ -27,6 +28,7 @@
"summary": "A short summary of what the operation does. For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.",
"description": "A verbose explanation of the operation behavior. GitHub Flavored Markup syntax can be used for rich text representation.",
"tags": "A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.",
"operationId": "Unique string used to identify the operation.",
"consumes": "A list of MIME types the operation can consume.",
"produces": "A list of MIME types the operation can produce.",
"deprecated": "Declares this operation to be deprecated. Usage of the declared operation should be refrained."
Expand Down
8 changes: 8 additions & 0 deletions swagger/swagger.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
<label id="node-config-input-tags-label" for="node-config-input-tags" class="popover-right" data-i18n="[data-content]swagger.data-content.tags"><span data-i18n="swagger.label.tags"></span></label>
<input type="text" id="node-config-input-tags" data-i18n="[placeholder]swagger.placeholder.tags">
</div>
<div class="form-row">
<label id="node-config-input-operationId-label" for="node-config-input-operationId" class="popover-right" data-i18n="[data-content]swagger.data-content.operationId"><span data-i18n="swagger.label.operationId"></span></label>
<input type="text" id="node-config-input-operationId" >
</div>
<div class="form-row">
<label id="node-config-input-consumes-label" for="node-config-input-consumes" class="popover-right" data-i18n="[data-content]swagger.data-content.consumes"><span data-i18n="swagger.label.consumes"></span></label>
<input type="text" id="node-config-input-consumes" data-i18n="[placeholder]swagger.placeholder.consumes">
Expand Down Expand Up @@ -94,6 +98,9 @@
tags: {
value: ""
},
operationId: {
value:""
},
consumes: {
value: ""
},
Expand Down Expand Up @@ -150,6 +157,7 @@
RED.popover.tooltip($('#node-config-input-summary-label'), this._("swagger.data-content.summary"));
RED.popover.tooltip($('#node-config-input-description-label'), this._("swagger.data-content.description"));
RED.popover.tooltip($('#node-config-input-tags-label'), this._("swagger.data-content.tags"));
RED.popover.tooltip($('#node-config-input-operationId-label'), this._("swagger.data-content.operationId"));
RED.popover.tooltip($('#node-config-input-consumes-label'), this._("swagger.data-content.consumes"));
RED.popover.tooltip($('#node-config-input-produces-label'), this._("swagger.data-content.produces"));
RED.popover.tooltip($('#node-config-input-deprecated-label'), this._("swagger.data-content.deprecated"));
Expand Down
13 changes: 11 additions & 2 deletions swagger/swagger.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,25 @@ module.exports = function(RED) {
resp.basePath = stripTerminalSlash(basePath);
resp.paths = {};

var nodeSwaggerDoc = [];
RED.nodes.eachNode(node => {
if (node.type === "swagger-doc") { nodeSwaggerDoc.push(node); }
});

RED.nodes.eachNode(node => {
const { name, type, method, swaggerDoc, url } = node;

if (type === "http in") {
const swagger = RED.nodes.getNode(swaggerDoc);

const swagger = RED.nodes.getNode(swaggerDoc) || nodeSwaggerDoc.filter(o => o.id == swaggerDoc)[0];
const endPoint = ensureLeadingSlash(url.replace(regexColons, convToSwaggerPath));
if (!resp.paths[endPoint]) resp.paths[endPoint] = {};

const {
summary = name || method + " " + endPoint,
description = "",
tags = "",
operationId,
consumes,
produces,
deprecated,
Expand All @@ -75,11 +82,12 @@ module.exports = function(RED) {
summary,
description,
tags: aryTags,
operationId,
consumes: aryConsumes,
produces: aryProduces,
deprecated,
parameters: [...parameters, ...additionalParams],
responses
responses,
};
}
});
Expand All @@ -91,6 +99,7 @@ module.exports = function(RED) {
this.summary = n.summary;
this.description = n.description;
this.tags = n.tags;
this.operationId = n.operationId
this.consumes = n.consumes;
this.produces = n.produces;
this.parameters = n.parameters;
Expand Down