|
249 | 249 | */ |
250 | 250 | var generateTypeRow = function(opts, top) { |
251 | 251 | var row = $("<div/>"); |
252 | | - |
253 | 252 | row.addClass('node-swagger-type-row'); |
254 | 253 | row.css('margin-top', '3px'); |
255 | 254 | if(top){ |
|
281 | 280 | } |
282 | 281 | typeSelect.val(opts.type); |
283 | 282 | var formatLabel = $("<label/>", { |
284 | | - class: "node-swgger-type-format-label", |
| 283 | + class: "node-swagger-type-format-label", |
285 | 284 | style: "width: auto; margin-left:20px; margin-right: 10px;" |
286 | 285 | }).text(formatText).appendTo(row); |
287 | 286 | formatLabel.popover({ |
|
296 | 295 | style: "width: 150px;", |
297 | 296 | type: "text" |
298 | 297 | }).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])); |
| 298 | + |
| 299 | + if(!opts.propertyRow){ |
| 300 | + var collFormatSelect = $('<select/>', { |
| 301 | + class: "node-swagger-type-collection-format", |
| 302 | + style: "width: 150px;", |
| 303 | + type: "text" |
| 304 | + }).appendTo(row); |
| 305 | + var collformatoptions = ["csv", "ssv", "tsv", "pipes"]; |
| 306 | + if (top) { |
| 307 | + collformatoptions.push("multi"); |
| 308 | + } |
| 309 | + for (var i = 0; i < collformatoptions.length; i++) { |
| 310 | + collFormatSelect.append($("<option/>").val(collformatoptions[i]).text(collformatoptions[i])); |
| 311 | + } |
| 312 | + collFormatSelect.val(opts.collectionFormat || "csv"); |
310 | 313 | } |
311 | | - collFormatSelect.val(opts.collectionFormat || "csv"); |
312 | 314 |
|
313 | 315 | typeSelect.change(function() { |
314 | 316 | var t = $(this).val(); |
315 | 317 | if (t != "array") { |
316 | 318 | $(this).parent().find(".node-swagger-type-row").remove(); |
317 | 319 | $(this).parent().find(".node-swagger-type-format").show(); |
| 320 | + $(this).parent().find(".node-swagger-type-format-label").text(formatText); |
318 | 321 | $(this).parent().find(".node-swagger-type-collection-format").hide(); |
319 | | - |
| 322 | + |
320 | 323 | if (t == "ref") { |
321 | | - $(this).parent().find(".node-swgger-type-format-label").text(""); |
| 324 | + $(this).parent().find(".node-swagger-type-format-label").text(""); |
322 | 325 | } else { |
323 | | - $(this).parent().find(".node-swgger-type-format-label").text(formatText); |
| 326 | + $(this).parent().find(".node-swagger-type-format-label").text(formatText); |
324 | 327 | } |
325 | 328 |
|
326 | 329 |
|
327 | 330 | } else { |
328 | 331 | $(this).parent().find(".node-swagger-type-format").hide(); |
329 | 332 | $(this).parent().find(".node-swagger-type-collection-format").show(); |
| 333 | + if(opts.propertyRow){ |
| 334 | + $(this).parent().find(".node-swagger-type-format-label").text(""); |
| 335 | + if(!opts.items){ |
| 336 | + opts.items = {}; |
| 337 | + } |
| 338 | + opts.items.propertyRow = true; |
| 339 | + } |
330 | 340 | generateTypeRow(opts.items || {}, false).appendTo($(this).parent()); |
331 | 341 | } |
332 | 342 | }); |
|
374 | 384 | style: "margin-top: 3px; margin-left: 10px;" |
375 | 385 | }); |
376 | 386 | propList.appendTo(row); |
| 387 | + opts.propertyRow = true; |
377 | 388 | var typeRow = generateTypeRow(opts, true).appendTo(propList); |
378 | 389 | return row; |
379 | 390 | } |
|
854 | 865 | Recursive function used to generate the items object that is required for array objects |
855 | 866 | */ |
856 | 867 | var getArrayItems = function (row){ |
857 | | - console.log(row); |
858 | 868 | var items = {}; |
859 | 869 | var type = row.find('.node-swagger-type-select').val(); |
860 | 870 | items.type = type; |
861 | 871 | if(type == 'array'){ |
862 | 872 | 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; |
| 873 | + if(collFormat) |
| 874 | + items.collectionFormat = collFormat; |
884 | 875 | var nextRow = row.children(".node-swagger-type-row"); |
885 | 876 | items.items = getArrayItems(nextRow); |
886 | 877 | } else{ |
|
922 | 913 | current.type = ctype; |
923 | 914 | if (current.type == "array") { |
924 | 915 |
|
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; |
| 916 | + var collFormat = row.children(".node-swagger-type-collection-format").val(); |
| 917 | + if(collFormat) |
| 918 | + current.collectionFormat = collFormat; |
928 | 919 |
|
929 | 920 | var nextRow = row.children(".node-swagger-type-row"); |
930 | 921 |
|
931 | | - current.items = getArrayItemsSchema(nextRow); |
| 922 | + current.items = getArrayItems(nextRow); |
932 | 923 |
|
933 | 924 | } else { |
934 | 925 | var format = row.children(".node-swagger-type-format").val(); |
|
1012 | 1003 | current.type = ctype; |
1013 | 1004 | if (current.type == "array") { |
1014 | 1005 |
|
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; |
| 1006 | + var collFormat = row.children(".node-swagger-type-collection-format").val(); |
| 1007 | + if(collFormat) |
| 1008 | + current.collectionFormat = collFormat; |
1018 | 1009 |
|
1019 | 1010 | var nextRow = row.children(".node-swagger-type-row"); |
1020 | 1011 |
|
1021 | | - current.items = getArrayItemsSchema(nextRow); |
| 1012 | + current.items = getArrayItems(nextRow); |
1022 | 1013 |
|
1023 | 1014 | } else { |
1024 | 1015 | var format = row.children(".node-swagger-type-format").val(); |
|
0 commit comments