swagger_ui_generator 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +69 -0
  6. data/Rakefile +23 -0
  7. data/lib/generators/swagger_ui_generator/install/install_generator.rb +22 -0
  8. data/lib/generators/swagger_ui_generator/install/templates/public/api-docs.html.erb +73 -0
  9. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/css/highlight.default.css +135 -0
  10. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/css/screen.css +1070 -0
  11. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/backbone-min.js +38 -0
  12. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/handlebars-1.0.0.js +2278 -0
  13. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/highlight.7.3.pack.js +1 -0
  14. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/jquery-1.8.0.min.js +2 -0
  15. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/jquery.ba-bbq.min.js +18 -0
  16. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/jquery.slideto.min.js +1 -0
  17. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/jquery.wiggle.min.js +8 -0
  18. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/shred.bundle.js +2765 -0
  19. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/shred/content.js +193 -0
  20. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/swagger.js +1311 -0
  21. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/lib/underscore-min.js +32 -0
  22. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/swagger-ui.js +2129 -0
  23. data/lib/generators/swagger_ui_generator/install/templates/public/swagger/throbber.gif +0 -0
  24. data/lib/swagger_ui_generator.rb +5 -0
  25. data/lib/swagger_ui_generator/importer.rb +97 -0
  26. data/lib/swagger_ui_generator/version.rb +3 -0
  27. data/swagger_ui_generator.gemspec +28 -0
  28. data/test/lib/generators/swagger_ui_generator/install_generator_test.rb +73 -0
  29. data/test/test_helper.rb +19 -0
  30. data/vendor/swagger-ui/.gitignore +22 -0
  31. data/vendor/swagger-ui/.npmignore +7 -0
  32. data/vendor/swagger-ui/Cakefile +132 -0
  33. data/vendor/swagger-ui/README.md +110 -0
  34. data/vendor/swagger-ui/dist/css/highlight.default.css +135 -0
  35. data/vendor/swagger-ui/dist/css/screen.css +1070 -0
  36. data/vendor/swagger-ui/dist/images/logo_small.png +0 -0
  37. data/vendor/swagger-ui/dist/images/pet_store_api.png +0 -0
  38. data/vendor/swagger-ui/dist/images/throbber.gif +0 -0
  39. data/vendor/swagger-ui/dist/images/wordnik_api.png +0 -0
  40. data/vendor/swagger-ui/dist/index.html +78 -0
  41. data/vendor/swagger-ui/dist/lib/backbone-min.js +38 -0
  42. data/vendor/swagger-ui/dist/lib/handlebars-1.0.0.js +2278 -0
  43. data/vendor/swagger-ui/dist/lib/highlight.7.3.pack.js +1 -0
  44. data/vendor/swagger-ui/dist/lib/jquery-1.8.0.min.js +2 -0
  45. data/vendor/swagger-ui/dist/lib/jquery.ba-bbq.min.js +18 -0
  46. data/vendor/swagger-ui/dist/lib/jquery.slideto.min.js +1 -0
  47. data/vendor/swagger-ui/dist/lib/jquery.wiggle.min.js +8 -0
  48. data/vendor/swagger-ui/dist/lib/shred.bundle.js +2765 -0
  49. data/vendor/swagger-ui/dist/lib/shred/content.js +193 -0
  50. data/vendor/swagger-ui/dist/lib/swagger.js +1311 -0
  51. data/vendor/swagger-ui/dist/lib/underscore-min.js +32 -0
  52. data/vendor/swagger-ui/dist/swagger-ui.js +2129 -0
  53. data/vendor/swagger-ui/dist/swagger-ui.min.js +1 -0
  54. data/vendor/swagger-ui/lib/backbone-min.js +38 -0
  55. data/vendor/swagger-ui/lib/handlebars-1.0.0.js +2278 -0
  56. data/vendor/swagger-ui/lib/highlight.7.3.pack.js +1 -0
  57. data/vendor/swagger-ui/lib/jquery-1.8.0.min.js +2 -0
  58. data/vendor/swagger-ui/lib/jquery.ba-bbq.min.js +18 -0
  59. data/vendor/swagger-ui/lib/jquery.slideto.min.js +1 -0
  60. data/vendor/swagger-ui/lib/jquery.wiggle.min.js +8 -0
  61. data/vendor/swagger-ui/lib/shred.bundle.js +2765 -0
  62. data/vendor/swagger-ui/lib/shred/content.js +193 -0
  63. data/vendor/swagger-ui/lib/swagger.js +1311 -0
  64. data/vendor/swagger-ui/lib/underscore-min.js +32 -0
  65. data/vendor/swagger-ui/package.json +26 -0
  66. data/vendor/swagger-ui/src/main/coffeescript/SwaggerUi.coffee +101 -0
  67. data/vendor/swagger-ui/src/main/coffeescript/view/ContentTypeView.coffee +14 -0
  68. data/vendor/swagger-ui/src/main/coffeescript/view/HeaderView.coffee +37 -0
  69. data/vendor/swagger-ui/src/main/coffeescript/view/MainView.coffee +18 -0
  70. data/vendor/swagger-ui/src/main/coffeescript/view/OperationView.coffee +318 -0
  71. data/vendor/swagger-ui/src/main/coffeescript/view/ParameterContentTypeView.coffee +14 -0
  72. data/vendor/swagger-ui/src/main/coffeescript/view/ParameterView.coffee +57 -0
  73. data/vendor/swagger-ui/src/main/coffeescript/view/ResourceView.coffee +21 -0
  74. data/vendor/swagger-ui/src/main/coffeescript/view/ResponseContentTypeView.coffee +14 -0
  75. data/vendor/swagger-ui/src/main/coffeescript/view/SignatureView.coffee +51 -0
  76. data/vendor/swagger-ui/src/main/coffeescript/view/StatusCodeView.coffee +11 -0
  77. data/vendor/swagger-ui/src/main/html/css/highlight.default.css +135 -0
  78. data/vendor/swagger-ui/src/main/html/css/screen.css +1070 -0
  79. data/vendor/swagger-ui/src/main/html/images/logo_small.png +0 -0
  80. data/vendor/swagger-ui/src/main/html/images/pet_store_api.png +0 -0
  81. data/vendor/swagger-ui/src/main/html/images/throbber.gif +0 -0
  82. data/vendor/swagger-ui/src/main/html/images/wordnik_api.png +0 -0
  83. data/vendor/swagger-ui/src/main/html/index.html +78 -0
  84. data/vendor/swagger-ui/src/main/javascript/doc.js +184 -0
  85. data/vendor/swagger-ui/src/main/less/reset.less +50 -0
  86. data/vendor/swagger-ui/src/main/less/screen.less +67 -0
  87. data/vendor/swagger-ui/src/main/less/specs.less +1004 -0
  88. data/vendor/swagger-ui/src/main/template/content_type.handlebars +10 -0
  89. data/vendor/swagger-ui/src/main/template/main.handlebars +22 -0
  90. data/vendor/swagger-ui/src/main/template/operation.handlebars +85 -0
  91. data/vendor/swagger-ui/src/main/template/param.handlebars +30 -0
  92. data/vendor/swagger-ui/src/main/template/param_list.handlebars +25 -0
  93. data/vendor/swagger-ui/src/main/template/param_readonly.handlebars +15 -0
  94. data/vendor/swagger-ui/src/main/template/param_readonly_required.handlebars +15 -0
  95. data/vendor/swagger-ui/src/main/template/param_required.handlebars +31 -0
  96. data/vendor/swagger-ui/src/main/template/parameter_content_type.handlebars +10 -0
  97. data/vendor/swagger-ui/src/main/template/resource.handlebars +27 -0
  98. data/vendor/swagger-ui/src/main/template/response_content_type.handlebars +10 -0
  99. data/vendor/swagger-ui/src/main/template/signature.handlebars +18 -0
  100. data/vendor/swagger-ui/src/main/template/status_code.handlebars +2 -0
  101. data/vendor/swagger-ui/src/test/spec.html +26 -0
  102. data/vendor/swagger-ui/src/test/swagger-ui-spec.coffee +49 -0
  103. data/vendor/swagger-ui/swagger-ui.json +20 -0
  104. metadata +240 -0
@@ -0,0 +1,32 @@
1
+ // Underscore.js 1.3.3
2
+ // (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
3
+ // Underscore is freely distributable under the MIT license.
4
+ // Portions of Underscore are inspired or borrowed from Prototype,
5
+ // Oliver Steele's Functional, and John Resig's Micro-Templating.
6
+ // For all details and documentation:
7
+ // http://documentcloud.github.com/underscore
8
+ (function(){function r(a,c,d){if(a===c)return 0!==a||1/a==1/c;if(null==a||null==c)return a===c;a._chain&&(a=a._wrapped);c._chain&&(c=c._wrapped);if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return!1;switch(e){case "[object String]":return a==""+c;case "[object Number]":return a!=+a?c!=+c:0==a?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
9
+ c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if("object"!=typeof a||"object"!=typeof c)return!1;for(var f=d.length;f--;)if(d[f]==a)return!0;d.push(a);var f=0,g=!0;if("[object Array]"==e){if(f=a.length,g=f==c.length)for(;f--&&(g=f in a==f in c&&r(a[f],c[f],d)););}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return!1;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&r(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,h)&&!f--)break;
10
+ g=!f}}d.pop();return g}var s=this,I=s._,o={},k=Array.prototype,p=Object.prototype,i=k.slice,J=k.unshift,l=p.toString,K=p.hasOwnProperty,y=k.forEach,z=k.map,A=k.reduce,B=k.reduceRight,C=k.filter,D=k.every,E=k.some,q=k.indexOf,F=k.lastIndexOf,p=Array.isArray,L=Object.keys,t=Function.prototype.bind,b=function(a){return new m(a)};"undefined"!==typeof exports?("undefined"!==typeof module&&module.exports&&(exports=module.exports=b),exports._=b):s._=b;b.VERSION="1.3.3";var j=b.each=b.forEach=function(a,
11
+ c,d){if(a!=null)if(y&&a.forEach===y)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===o)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===o)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(z&&a.map===z)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(A&&
12
+ a.reduce===A){e&&(c=b.bind(c,e));return f?a.reduce(c,d):a.reduce(c)}j(a,function(a,b,i){if(f)d=c.call(e,d,a,b,i);else{d=a;f=true}});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(B&&a.reduceRight===B){e&&(c=b.bind(c,e));return f?a.reduceRight(c,d):a.reduceRight(c)}var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,
13
+ c,b){var e;G(a,function(a,g,h){if(c.call(b,a,g,h)){e=a;return true}});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(C&&a.filter===C)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(D&&a.every===D)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,
14
+ a,g,h)))return o});return!!e};var G=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(E&&a.some===E)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return o});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;if(q&&a.indexOf===q)return a.indexOf(c)!=-1;return b=G(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
15
+ function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a)&&a[0]===+a[0])return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&
16
+ (e={value:a,computed:b})});return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){d=Math.floor(Math.random()*(f+1));b[f]=b[d];b[d]=a});return b};b.sortBy=function(a,c,d){var e=b.isFunction(c)?c:function(a){return a[c]};return b.pluck(b.map(a,function(a,b,c){return{value:a,criteria:e.call(d,a,b,c)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c===void 0?1:d===void 0?-1:c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};
17
+ j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:b.isArray(a)||b.isArguments(a)?i.call(a):a.toArray&&b.isFunction(a.toArray)?a.toArray():b.values(a)};b.size=function(a){return b.isArray(a)?a.length:b.keys(a).length};b.first=b.head=b.take=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,
18
+ 0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,
19
+ e=[];a.length<3&&(c=true);b.reduce(d,function(d,g,h){if(c?b.last(d)!==g||!d.length:!b.include(d,g)){d.push(g);e.push(a[h])}return d},[]);return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1),true);return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=
20
+ i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,d){if(a==null)return-1;var e;if(d){d=b.sortedIndex(a,c);return a[d]===c?d:-1}if(q&&a.indexOf===q)return a.indexOf(c);d=0;for(e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(F&&a.lastIndexOf===F)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){if(arguments.length<=
21
+ 1){b=a||0;a=0}for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;){g[f++]=a;a=a+d}return g};var H=function(){};b.bind=function(a,c){var d,e;if(a.bind===t&&t)return t.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));H.prototype=a.prototype;var b=new H,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=
22
+ i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(null,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i,j=b.debounce(function(){h=
23
+ g=false},c);return function(){d=this;e=arguments;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);j()},c));g?h=true:i=a.apply(d,e);j();g=true;return i}};b.debounce=function(a,b,d){var e;return function(){var f=this,g=arguments;d&&!e&&a.apply(f,g);clearTimeout(e);e=setTimeout(function(){e=null;d||a.apply(f,g)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));
24
+ return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=L||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&
25
+ c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.pick=function(a){var c={};j(b.flatten(i.call(arguments,1)),function(b){b in a&&(c[b]=a[b])});return c};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return r(a,b,[])};b.isEmpty=
26
+ function(a){if(a==null)return true;if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=p||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};b.isArguments(arguments)||(b.isArguments=function(a){return!(!a||!b.has(a,"callee"))});b.isFunction=function(a){return l.call(a)=="[object Function]"};
27
+ b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isFinite=function(a){return b.isNumber(a)&&isFinite(a)};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,
28
+ b){return K.call(a,b)};b.noConflict=function(){s._=I;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.result=function(a,c){if(a==null)return null;var d=a[c];return b.isFunction(d)?d.call(a):d};b.mixin=function(a){j(b.functions(a),function(c){M(c,b[c]=a[c])})};var N=0;b.uniqueId=
29
+ function(a){var b=N++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var u=/.^/,n={"\\":"\\","'":"'",r:"\r",n:"\n",t:"\t",u2028:"\u2028",u2029:"\u2029"},v;for(v in n)n[n[v]]=v;var O=/\\|'|\r|\n|\t|\u2028|\u2029/g,P=/\\(\\|'|r|n|t|u2028|u2029)/g,w=function(a){return a.replace(P,function(a,b){return n[b]})};b.template=function(a,c,d){d=b.defaults(d||{},b.templateSettings);a="__p+='"+a.replace(O,function(a){return"\\"+n[a]}).replace(d.escape||
30
+ u,function(a,b){return"'+\n_.escape("+w(b)+")+\n'"}).replace(d.interpolate||u,function(a,b){return"'+\n("+w(b)+")+\n'"}).replace(d.evaluate||u,function(a,b){return"';\n"+w(b)+"\n;__p+='"})+"';\n";d.variable||(a="with(obj||{}){\n"+a+"}\n");var a="var __p='';var print=function(){__p+=Array.prototype.join.call(arguments, '')};\n"+a+"return __p;\n",e=new Function(d.variable||"obj","_",a);if(c)return e(c,b);c=function(a){return e.call(this,a,b)};c.source="function("+(d.variable||"obj")+"){\n"+a+"}";return c};
31
+ b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var x=function(a,c){return c?b(a).chain():a},M=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);J.call(a,this._wrapped);return x(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return x(d,
32
+ this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return x(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "swagger-ui",
3
+ "version": "2.0.8",
4
+ "description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
5
+ "scripts": {
6
+ "build": "PATH=$PATH:./node_modules/.bin cake dist",
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/wordnik/swagger-ui.git"
12
+ },
13
+ "author": {
14
+ "name": "Tony Tam",
15
+ "email": "fehguy@gmail.com",
16
+ "url": "http://developer.wordnik.com"
17
+ },
18
+ "license": "Apache",
19
+ "readmeFilename": "README.md",
20
+ "dependencies": {
21
+ "coffee-script": "~1.5.0",
22
+ "swagger-client": "2.0.14",
23
+ "handlebars": "~1.0.10",
24
+ "less": "~1.4.2"
25
+ }
26
+ }
@@ -0,0 +1,101 @@
1
+ class SwaggerUi extends Backbone.Router
2
+
3
+ # Defaults
4
+ dom_id: "swagger_ui"
5
+
6
+ # Attributes
7
+ options: null
8
+ api: null
9
+ headerView: null
10
+ mainView: null
11
+
12
+ # SwaggerUi accepts all the same options as SwaggerApi
13
+ initialize: (options={}) ->
14
+ # Allow dom_id to be overridden
15
+ if options.dom_id?
16
+ @dom_id = options.dom_id
17
+ delete options.dom_id
18
+
19
+ # Create an empty div which contains the dom_id
20
+ $('body').append('<div id="' + @dom_id + '"></div>') if not $('#' + @dom_id)?
21
+
22
+ @options = options
23
+
24
+ # Set the callbacks
25
+ @options.success = => @render()
26
+ @options.progress = (d) => @showMessage(d)
27
+ @options.failure = (d) => @onLoadFailure(d)
28
+
29
+ # Create view to handle the header inputs
30
+ @headerView = new HeaderView({el: $('#header')})
31
+
32
+ # Event handler for when the baseUrl/apiKey is entered by user
33
+ @headerView.on 'update-swagger-ui', (data) => @updateSwaggerUi(data)
34
+
35
+ # Event handler for when url/key is received from user
36
+ updateSwaggerUi: (data) ->
37
+ @options.url = data.url
38
+ @load()
39
+
40
+ # Create an api and render
41
+ load: ->
42
+ # Initialize the API object
43
+ @mainView?.clear()
44
+ url = @options.url
45
+ if url.indexOf("http") isnt 0
46
+ url = @buildUrl(window.location.href.toString(), url)
47
+
48
+ @options.url = url
49
+ @headerView.update(url)
50
+ @api = new SwaggerApi(@options)
51
+ @api.build()
52
+ @api
53
+
54
+ # This is bound to success handler for SwaggerApi
55
+ # so it gets called when SwaggerApi completes loading
56
+ render:() ->
57
+ @showMessage('Finished Loading Resource Information. Rendering Swagger UI...')
58
+ @mainView = new MainView({model: @api, el: $('#' + @dom_id)}).render()
59
+ @showMessage()
60
+ switch @options.docExpansion
61
+ when "full" then Docs.expandOperationsForResource('')
62
+ when "list" then Docs.collapseOperationsForResource('')
63
+ @options.onComplete(@api, @) if @options.onComplete
64
+ setTimeout(
65
+ =>
66
+ Docs.shebang()
67
+ 400
68
+ )
69
+
70
+ buildUrl: (base, url) ->
71
+ log "base is " + base
72
+ if url.indexOf("/") is 0
73
+ parts = base.split("/")
74
+ base = parts[0] + "//" + parts[2]
75
+ base + url
76
+ else
77
+ endOfPath = base.length
78
+ if base.indexOf("?") > -1
79
+ endOfPath = Math.min(endOfPath, base.indexOf("?"))
80
+ if base.indexOf("#") > -1
81
+ endOfPath = Math.min(endOfPath, base.indexOf("#"))
82
+ base = base.substring(0, endOfPath);
83
+ if base.indexOf( "/", base.length - 1 ) isnt -1
84
+ return base + url
85
+ return base + "/" + url
86
+
87
+ # Shows message on topbar of the ui
88
+ showMessage: (data = '') ->
89
+ $('#message-bar').removeClass 'message-fail'
90
+ $('#message-bar').addClass 'message-success'
91
+ $('#message-bar').html data
92
+
93
+ # shows message in red
94
+ onLoadFailure: (data = '') ->
95
+ $('#message-bar').removeClass 'message-success'
96
+ $('#message-bar').addClass 'message-fail'
97
+ val = $('#message-bar').html data
98
+ @options.onFailure(data) if @options.onFailure?
99
+ val
100
+
101
+ window.SwaggerUi = SwaggerUi
@@ -0,0 +1,14 @@
1
+ class ContentTypeView extends Backbone.View
2
+ initialize: ->
3
+
4
+ render: ->
5
+ template = @template()
6
+ $(@el).html(template(@model))
7
+
8
+ $('label[for=contentType]', $(@el)).text('Response Content Type')
9
+
10
+ @
11
+
12
+ template: ->
13
+ Handlebars.templates.content_type
14
+
@@ -0,0 +1,37 @@
1
+ class HeaderView extends Backbone.View
2
+ events: {
3
+ 'click #show-pet-store-icon' : 'showPetStore'
4
+ 'click #show-wordnik-dev-icon' : 'showWordnikDev'
5
+ 'click #explore' : 'showCustom'
6
+ 'keyup #input_baseUrl' : 'showCustomOnKeyup'
7
+ 'keyup #input_apiKey' : 'showCustomOnKeyup'
8
+ }
9
+
10
+ initialize: ->
11
+
12
+ showPetStore: (e) ->
13
+ @trigger(
14
+ 'update-swagger-ui'
15
+ {url:"http://petstore.swagger.wordnik.com/api/api-docs"}
16
+ )
17
+
18
+ showWordnikDev: (e) ->
19
+ @trigger(
20
+ 'update-swagger-ui'
21
+ {url:"http://api.wordnik.com/v4/resources.json"}
22
+ )
23
+
24
+ showCustomOnKeyup: (e) ->
25
+ @showCustom() if e.keyCode is 13
26
+
27
+ showCustom: (e) ->
28
+ e?.preventDefault()
29
+ @trigger(
30
+ 'update-swagger-ui'
31
+ {url: $('#input_baseUrl').val(), apiKey: $('#input_apiKey').val()}
32
+ )
33
+
34
+ update: (url, apiKey, trigger = false) ->
35
+ $('#input_baseUrl').val url
36
+ #$('#input_apiKey').val apiKey
37
+ @trigger 'update-swagger-ui', {url:url} if trigger
@@ -0,0 +1,18 @@
1
+ class MainView extends Backbone.View
2
+ initialize: ->
3
+
4
+ render: ->
5
+ # Render the outer container for resources
6
+ $(@el).html(Handlebars.templates.main(@model))
7
+
8
+ # Render each resource
9
+ @addResource resource for resource in @model.apisArray
10
+ @
11
+
12
+ addResource: (resource) ->
13
+ # Render a resource and add it to resources li
14
+ resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.name, className: 'resource'})
15
+ $('#resources').append resourceView.render().el
16
+
17
+ clear: ->
18
+ $(@el).html ''
@@ -0,0 +1,318 @@
1
+ class OperationView extends Backbone.View
2
+ invocationUrl: null
3
+
4
+ events: {
5
+ 'submit .sandbox' : 'submitOperation'
6
+ 'click .submit' : 'submitOperation'
7
+ 'click .response_hider' : 'hideResponse'
8
+ 'click .toggleOperation' : 'toggleOperationContent'
9
+ }
10
+
11
+ initialize: ->
12
+
13
+ render: ->
14
+ isMethodSubmissionSupported = true #jQuery.inArray(@model.method, @model.supportedSubmitMethods) >= 0
15
+ @model.isReadOnly = true unless isMethodSubmissionSupported
16
+
17
+ $(@el).html(Handlebars.templates.operation(@model))
18
+
19
+ if @model.responseClassSignature and @model.responseClassSignature != 'string'
20
+ signatureModel =
21
+ sampleJSON: @model.responseSampleJSON
22
+ isParam: false
23
+ signature: @model.responseClassSignature
24
+
25
+ responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
26
+ $('.model-signature', $(@el)).append responseSignatureView.render().el
27
+ else
28
+ $('.model-signature', $(@el)).html(@model.type)
29
+
30
+ contentTypeModel =
31
+ isParam: false
32
+
33
+ contentTypeModel.consumes = @model.consumes
34
+ contentTypeModel.produces = @model.produces
35
+
36
+ for param in @model.parameters
37
+ type = param.type || param.dataType
38
+ if type.toLowerCase() == 'file'
39
+ if !contentTypeModel.consumes
40
+ log "set content type "
41
+ contentTypeModel.consumes = 'multipart/form-data'
42
+
43
+ responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
44
+ $('.response-content-type', $(@el)).append responseContentTypeView.render().el
45
+
46
+ # Render each parameter
47
+ @addParameter param, contentTypeModel.consumes for param in @model.parameters
48
+
49
+ # Render each response code
50
+ @addStatusCode statusCode for statusCode in @model.responseMessages
51
+
52
+ @
53
+
54
+ addParameter: (param, consumes) ->
55
+ # Render a parameter
56
+ param.consumes = consumes
57
+ paramView = new ParameterView({model: param, tagName: 'tr', readOnly: @model.isReadOnly})
58
+ $('.operation-params', $(@el)).append paramView.render().el
59
+
60
+ addStatusCode: (statusCode) ->
61
+ # Render status codes
62
+ statusCodeView = new StatusCodeView({model: statusCode, tagName: 'tr'})
63
+ $('.operation-status', $(@el)).append statusCodeView.render().el
64
+
65
+ submitOperation: (e) ->
66
+ e?.preventDefault()
67
+ # Check for errors
68
+ form = $('.sandbox', $(@el))
69
+ error_free = true
70
+ form.find("input.required").each ->
71
+ $(@).removeClass "error"
72
+ if jQuery.trim($(@).val()) is ""
73
+ $(@).addClass "error"
74
+ $(@).wiggle
75
+ callback: => $(@).focus()
76
+ error_free = false
77
+
78
+ # if error free submit it
79
+ if error_free
80
+ map = {}
81
+ opts = {parent: @}
82
+
83
+ isFileUpload = false
84
+
85
+ for o in form.find("input")
86
+ if(o.value? && jQuery.trim(o.value).length > 0)
87
+ map[o.name] = o.value
88
+ if o.type is "file"
89
+ isFileUpload = true
90
+
91
+ for o in form.find("textarea")
92
+ if(o.value? && jQuery.trim(o.value).length > 0)
93
+ map["body"] = o.value
94
+
95
+ for o in form.find("select")
96
+ val = this.getSelectedValue o
97
+ if(val? && jQuery.trim(val).length > 0)
98
+ map[o.name] = val
99
+
100
+ opts.responseContentType = $("div select[name=responseContentType]", $(@el)).val()
101
+ opts.requestContentType = $("div select[name=parameterContentType]", $(@el)).val()
102
+
103
+ $(".response_throbber", $(@el)).show()
104
+ if isFileUpload
105
+ @handleFileUpload map, form
106
+ else
107
+ @model.do(map, opts, @showCompleteStatus, @showErrorStatus, @)
108
+
109
+ success: (response, parent) ->
110
+ parent.showCompleteStatus response
111
+
112
+ handleFileUpload: (map, form) ->
113
+ log "it's a file upload"
114
+ for o in form.serializeArray()
115
+ if(o.value? && jQuery.trim(o.value).length > 0)
116
+ map[o.name] = o.value
117
+
118
+ # requires HTML5 compatible browser
119
+ bodyParam = new FormData()
120
+
121
+ # add params
122
+ for param in @model.parameters
123
+ if param.paramType is 'form'
124
+ bodyParam.append(param.name, map[param.name])
125
+
126
+ # headers in operation
127
+ headerParams = {}
128
+ for param in @model.parameters
129
+ if param.paramType is 'header'
130
+ headerParams[param.name] = map[param.name]
131
+
132
+ log headerParams
133
+
134
+ # add files
135
+ for el in form.find('input[type~="file"]')
136
+ bodyParam.append($(el).attr('name'), el.files[0])
137
+
138
+ log(bodyParam)
139
+
140
+ @invocationUrl =
141
+ if @model.supportHeaderParams()
142
+ headerParams = @model.getHeaderParams(map)
143
+ @model.urlify(map, false)
144
+ else
145
+ @model.urlify(map, true)
146
+
147
+ $(".request_url", $(@el)).html "<pre>" + @invocationUrl + "</pre>"
148
+
149
+ obj =
150
+ type: @model.method
151
+ url: @invocationUrl
152
+ headers: headerParams
153
+ data: bodyParam
154
+ dataType: 'json'
155
+ contentType: false
156
+ processData: false
157
+ error: (data, textStatus, error) =>
158
+ @showErrorStatus(@wrap(data), @)
159
+ success: (data) =>
160
+ @showResponse(data, @)
161
+ complete: (data) =>
162
+ @showCompleteStatus(@wrap(data), @)
163
+
164
+ # apply authorizations
165
+ if window.authorizations
166
+ window.authorizations.apply obj
167
+
168
+ jQuery.ajax(obj)
169
+ false
170
+ # end of file-upload nastiness
171
+
172
+ # wraps a jquery response as a shred response
173
+
174
+ wrap: (data) ->
175
+ headers = {}
176
+ headerArray = data.getAllResponseHeaders().split(":")
177
+ for i in [0..headerArray.length/2] by (2)
178
+ headers[headerArray[i]] = headerArray[i+1]
179
+
180
+ o = {}
181
+ o.content = {}
182
+ o.content.data = data.responseText
183
+ o.headers = headers
184
+ o.request = {}
185
+ o.request.url = @invocationUrl
186
+ o.status = data.status
187
+ o
188
+
189
+ getSelectedValue: (select) ->
190
+ if !select.multiple
191
+ select.value
192
+ else
193
+ options = []
194
+ options.push opt.value for opt in select.options when opt.selected
195
+ if options.length > 0
196
+ options.join ","
197
+ else
198
+ null
199
+
200
+ # handler for hide response link
201
+ hideResponse: (e) ->
202
+ e?.preventDefault()
203
+ $(".response", $(@el)).slideUp()
204
+ $(".response_hider", $(@el)).fadeOut()
205
+
206
+
207
+ # Show response from server
208
+ showResponse: (response) ->
209
+ prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "<br>")
210
+ $(".response_body", $(@el)).html escape(prettyJson)
211
+
212
+ # Show error from server
213
+ showErrorStatus: (data, parent) ->
214
+ parent.showStatus data
215
+
216
+ # show the status codes
217
+ showCompleteStatus: (data, parent) ->
218
+ parent.showStatus data
219
+
220
+ # Adapted from http://stackoverflow.com/a/2893259/454004
221
+ formatXml: (xml) ->
222
+ reg = /(>)(<)(\/*)/g
223
+ wsexp = /[ ]*(.*)[ ]+\n/g
224
+ contexp = /(<.+>)(.+\n)/g
225
+ xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2')
226
+ pad = 0
227
+ formatted = ''
228
+ lines = xml.split('\n')
229
+ indent = 0
230
+ lastType = 'other'
231
+ # 4 types of tags - single, closing, opening, other (text, doctype, comment) - 4*4 = 16 transitions
232
+ transitions =
233
+ 'single->single': 0
234
+ 'single->closing': -1
235
+ 'single->opening': 0
236
+ 'single->other': 0
237
+ 'closing->single': 0
238
+ 'closing->closing': -1
239
+ 'closing->opening': 0
240
+ 'closing->other': 0
241
+ 'opening->single': 1
242
+ 'opening->closing': 0
243
+ 'opening->opening': 1
244
+ 'opening->other': 1
245
+ 'other->single': 0
246
+ 'other->closing': -1
247
+ 'other->opening': 0
248
+ 'other->other': 0
249
+
250
+ for ln in lines
251
+ do (ln) ->
252
+
253
+ types =
254
+ # is this line a single tag? ex. <br />
255
+ single: Boolean(ln.match(/<.+\/>/))
256
+ # is this a closing tag? ex. </a>
257
+ closing: Boolean(ln.match(/<\/.+>/))
258
+ # is this even a tag (that's not <!something>)
259
+ opening: Boolean(ln.match(/<[^!?].*>/))
260
+
261
+ [type] = (key for key, value of types when value)
262
+ type = if type is undefined then 'other' else type
263
+
264
+ fromTo = lastType + '->' + type
265
+ lastType = type
266
+ padding = ''
267
+
268
+ indent += transitions[fromTo]
269
+ padding = (' ' for j in [0...(indent)]).join('')
270
+ if fromTo == 'opening->closing'
271
+ #substr removes line break (\n) from prev loop
272
+ formatted = formatted.substr(0, formatted.length - 1) + ln + '\n'
273
+ else
274
+ formatted += padding + ln + '\n'
275
+
276
+ formatted
277
+
278
+
279
+ # puts the response data in UI
280
+ showStatus: (response) ->
281
+ content = response.data
282
+ headers = response.headers
283
+
284
+ # if server is nice, and sends content-type back, we can use it
285
+ contentType = if headers && headers["Content-Type"] then headers["Content-Type"].split(";")[0].trim() else null
286
+
287
+ if !content
288
+ code = $('<code />').text("no content")
289
+ pre = $('<pre class="json" />').append(code)
290
+ else if contentType is "application/json" || /\+json$/.test(contentType)
291
+ code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " "))
292
+ pre = $('<pre class="json" />').append(code)
293
+ else if contentType is "application/xml" || /\+xml$/.test(contentType)
294
+ code = $('<code />').text(@formatXml(content))
295
+ pre = $('<pre class="xml" />').append(code)
296
+ else if contentType is "text/html"
297
+ code = $('<code />').html(content)
298
+ pre = $('<pre class="xml" />').append(code)
299
+ else if /^image\//.test(contentType)
300
+ pre = $('<img>').attr('src',response.url)
301
+ else
302
+ # don't know what to render!
303
+ code = $('<code />').text(content)
304
+ pre = $('<pre class="json" />').append(code)
305
+
306
+ response_body = pre
307
+ $(".request_url", $(@el)).html "<pre>" + response.url + "</pre>"
308
+ $(".response_code", $(@el)).html "<pre>" + response.status + "</pre>"
309
+ $(".response_body", $(@el)).html response_body
310
+ $(".response_headers", $(@el)).html "<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>"
311
+ $(".response", $(@el)).slideDown()
312
+ $(".response_hider", $(@el)).show()
313
+ $(".response_throbber", $(@el)).hide()
314
+ hljs.highlightBlock($('.response_body', $(@el))[0])
315
+
316
+ toggleOperationContent: ->
317
+ elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.method + "_" + @model.number + "_content")
318
+ if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)