|
117 | 117 | onpaletteadd: function() { |
118 | 118 | //setup swagger-ui |
119 | 119 | var swaggerUi; |
120 | | - var refreshInfoHeight = 75; |
121 | 120 | var content = $("<div/>",{ |
122 | 121 | id:"tab-swagger-ui", style:"position: relative; padding: 0px 4px; height: 100%; overflow: hidden" |
123 | 122 | }); |
124 | | - var refreshInfo = $("<div/>", { |
125 | | - style:"height: "+ refreshInfoHeight + "px; margin: 5px; text-align: center" |
126 | | - }); |
127 | 123 |
|
128 | 124 | RED.events.on("deploy",function() { |
129 | 125 | if (swaggerUi) { |
|
146 | 142 | swaggerFrame.load(function(){ |
147 | 143 | swaggerUi = document.getElementById('swagger-ui-frame').contentWindow.swaggerUi; |
148 | 144 | window.addEventListener('resize', function(event){ |
149 | | - swaggerFrame.css('height', content.height() - refreshInfoHeight - 45); |
| 145 | + swaggerFrame.css('height', content.height()); |
150 | 146 | }); |
151 | | - swaggerFrame.css('height', content.height() - refreshInfoHeight - 45); |
| 147 | + swaggerFrame.css('height', content.height()); |
152 | 148 | swaggerUi.load(); |
153 | 149 | }); |
154 | 150 | }, |
|
249 | 245 | */ |
250 | 246 | var generateTypeRow = function(opts, top) { |
251 | 247 | var row = $("<div/>"); |
252 | | - |
253 | 248 | row.addClass('node-swagger-type-row'); |
254 | 249 | row.css('margin-top', '3px'); |
255 | 250 | if(top){ |
|
281 | 276 | } |
282 | 277 | typeSelect.val(opts.type); |
283 | 278 | var formatLabel = $("<label/>", { |
284 | | - class: "node-swgger-type-format-label", |
| 279 | + class: "node-swagger-type-format-label", |
285 | 280 | style: "width: auto; margin-left:20px; margin-right: 10px;" |
286 | 281 | }).text(formatText).appendTo(row); |
287 | 282 | formatLabel.popover({ |
|
296 | 291 | style: "width: 150px;", |
297 | 292 | type: "text" |
298 | 293 | }).val(opts.format).appendTo(row); |
299 | | - var collFormatSelect = $('<select/>', { |
300 | | - class: "node-swagger-type-collection-format", |
301 | | - style: "width: 150px;", |
302 | | - type: "text" |
303 | | - }).appendTo(row); |
304 | | - var collformatoptions = ["csv", "ssv", "tsv", "pipes"]; |
305 | | - if (top) { |
306 | | - collformatoptions.push("multi"); |
307 | | - } |
308 | | - for (var i = 0; i < collformatoptions.length; i++) { |
309 | | - collFormatSelect.append($("<option/>").val(collformatoptions[i]).text(collformatoptions[i])); |
| 294 | + |
| 295 | + if(!opts.propertyRow){ |
| 296 | + var collFormatSelect = $('<select/>', { |
| 297 | + class: "node-swagger-type-collection-format", |
| 298 | + style: "width: 150px;", |
| 299 | + type: "text" |
| 300 | + }).appendTo(row); |
| 301 | + var collformatoptions = ["csv", "ssv", "tsv", "pipes"]; |
| 302 | + if (top) { |
| 303 | + collformatoptions.push("multi"); |
| 304 | + } |
| 305 | + for (var i = 0; i < collformatoptions.length; i++) { |
| 306 | + collFormatSelect.append($("<option/>").val(collformatoptions[i]).text(collformatoptions[i])); |
| 307 | + } |
| 308 | + collFormatSelect.val(opts.collectionFormat || "csv"); |
310 | 309 | } |
311 | | - collFormatSelect.val(opts.collectionFormat || "csv"); |
312 | 310 |
|
313 | 311 | typeSelect.change(function() { |
314 | 312 | var t = $(this).val(); |
315 | 313 | if (t != "array") { |
316 | 314 | $(this).parent().find(".node-swagger-type-row").remove(); |
317 | 315 | $(this).parent().find(".node-swagger-type-format").show(); |
| 316 | + $(this).parent().find(".node-swagger-type-format-label").text(formatText); |
318 | 317 | $(this).parent().find(".node-swagger-type-collection-format").hide(); |
319 | | - |
| 318 | + |
320 | 319 | if (t == "ref") { |
321 | | - $(this).parent().find(".node-swgger-type-format-label").text(""); |
| 320 | + $(this).parent().find(".node-swagger-type-format-label").text(""); |
322 | 321 | } else { |
323 | | - $(this).parent().find(".node-swgger-type-format-label").text(formatText); |
| 322 | + $(this).parent().find(".node-swagger-type-format-label").text(formatText); |
324 | 323 | } |
325 | 324 |
|
326 | 325 |
|
327 | 326 | } else { |
328 | 327 | $(this).parent().find(".node-swagger-type-format").hide(); |
329 | 328 | $(this).parent().find(".node-swagger-type-collection-format").show(); |
| 329 | + if(opts.propertyRow){ |
| 330 | + $(this).parent().find(".node-swagger-type-format-label").text(""); |
| 331 | + if(!opts.items){ |
| 332 | + opts.items = {}; |
| 333 | + } |
| 334 | + opts.items.propertyRow = true; |
| 335 | + } |
330 | 336 | generateTypeRow(opts.items || {}, false).appendTo($(this).parent()); |
331 | 337 | } |
332 | 338 | }); |
|
374 | 380 | style: "margin-top: 3px; margin-left: 10px;" |
375 | 381 | }); |
376 | 382 | propList.appendTo(row); |
| 383 | + opts.propertyRow = true; |
377 | 384 | var typeRow = generateTypeRow(opts, true).appendTo(propList); |
378 | 385 | return row; |
379 | 386 | } |
|
854 | 861 | Recursive function used to generate the items object that is required for array objects |
855 | 862 | */ |
856 | 863 | var getArrayItems = function (row){ |
857 | | - console.log(row); |
858 | 864 | var items = {}; |
859 | 865 | var type = row.find('.node-swagger-type-select').val(); |
860 | 866 | items.type = type; |
861 | 867 | if(type == 'array'){ |
862 | 868 | var collFormat = row.find('.node-swagger-type-collection-format').val(); |
863 | | - items.collectionFormat = collFormat; |
864 | | - var nextRow = row.children(".node-swagger-type-row"); |
865 | | - items.items = getArrayItems(nextRow); |
866 | | - } else{ |
867 | | - var format = row.find('.node-swagger-type-format').val(); |
868 | | - items.format = format; |
869 | | - } |
870 | | - return items; |
871 | | - } |
872 | | - |
873 | | - /** |
874 | | - Temporary placeholder to remove collectionFormat since swagger does not allow it |
875 | | - */ |
876 | | - var getArrayItemsSchema = function (row){ |
877 | | - console.log(row); |
878 | | - var items = {}; |
879 | | - var type = row.find('.node-swagger-type-select').val(); |
880 | | - items.type = type; |
881 | | - if(type == 'array'){ |
882 | | - //var collFormat = row.find('.node-swagger-type-collection-format').val(); |
883 | | - //items.collectionFormat = collFormat; |
| 869 | + if(collFormat) |
| 870 | + items.collectionFormat = collFormat; |
884 | 871 | var nextRow = row.children(".node-swagger-type-row"); |
885 | 872 | items.items = getArrayItems(nextRow); |
886 | 873 | } else{ |
|
922 | 909 | current.type = ctype; |
923 | 910 | if (current.type == "array") { |
924 | 911 |
|
925 | | - //commented out until we figure out what to do with collectionFormat in schema objects |
926 | | - //var collFormat = row.children(".node-swagger-type-collection-format").val(); |
927 | | - //current.collectionFormat = collFormat; |
| 912 | + var collFormat = row.children(".node-swagger-type-collection-format").val(); |
| 913 | + if(collFormat) |
| 914 | + current.collectionFormat = collFormat; |
928 | 915 |
|
929 | 916 | var nextRow = row.children(".node-swagger-type-row"); |
930 | 917 |
|
931 | | - current.items = getArrayItemsSchema(nextRow); |
| 918 | + current.items = getArrayItems(nextRow); |
932 | 919 |
|
933 | 920 | } else { |
934 | 921 | var format = row.children(".node-swagger-type-format").val(); |
|
1012 | 999 | current.type = ctype; |
1013 | 1000 | if (current.type == "array") { |
1014 | 1001 |
|
1015 | | - //commented out until we figure out what to do with collectionFormat in schema objects |
1016 | | - //var collFormat = row.children(".node-swagger-type-collection-format").val(); |
1017 | | - //current.collectionFormat = collFormat; |
| 1002 | + var collFormat = row.children(".node-swagger-type-collection-format").val(); |
| 1003 | + if(collFormat) |
| 1004 | + current.collectionFormat = collFormat; |
1018 | 1005 |
|
1019 | 1006 | var nextRow = row.children(".node-swagger-type-row"); |
1020 | 1007 |
|
1021 | | - current.items = getArrayItemsSchema(nextRow); |
| 1008 | + current.items = getArrayItems(nextRow); |
1022 | 1009 |
|
1023 | 1010 | } else { |
1024 | 1011 | var format = row.children(".node-swagger-type-format").val(); |
|
0 commit comments