diff --git a/swagger/locales/en-US/swagger.json b/swagger/locales/en-US/swagger.json index b75741e..cd1fa7f 100644 --- a/swagger/locales/en-US/swagger.json +++ b/swagger/locales/en-US/swagger.json @@ -9,6 +9,7 @@ "summary": "Summary", "description": "Description", "tags": "Tags", + "operationId": "OperationId", "consumes": "Consumes", "produces": "Produces", "deprecated": "Deprecated", @@ -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." diff --git a/swagger/swagger.html b/swagger/swagger.html index 1b2e1dd..8021683 100644 --- a/swagger/swagger.html +++ b/swagger/swagger.html @@ -39,6 +39,10 @@ +
+ + +
@@ -94,6 +98,9 @@ tags: { value: "" }, + operationId: { + value:"" + }, consumes: { value: "" }, @@ -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")); diff --git a/swagger/swagger.js b/swagger/swagger.js index 28d06be..caedb1d 100644 --- a/swagger/swagger.js +++ b/swagger/swagger.js @@ -44,11 +44,17 @@ 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] = {}; @@ -56,6 +62,7 @@ module.exports = function(RED) { summary = name || method + " " + endPoint, description = "", tags = "", + operationId, consumes, produces, deprecated, @@ -75,11 +82,12 @@ module.exports = function(RED) { summary, description, tags: aryTags, + operationId, consumes: aryConsumes, produces: aryProduces, deprecated, parameters: [...parameters, ...additionalParams], - responses + responses, }; } }); @@ -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;