-
-
Notifications
You must be signed in to change notification settings - Fork 152
/
bundle.min.js
11 lines (11 loc) · 18.8 KB
/
bundle.min.js
1
2
3
4
5
6
7
8
9
10
11
/*!
* Swagger Parser v5.0.2 (July 31st 2018)
*
* http://bigstickcarpet.com/swagger-parser
*
* @author James Messinger (http://bigstickcarpet.com)
* @license MIT
*/
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){"use strict";var format=require("format-util"),slice=Array.prototype.slice,protectedProperties=["name","message","stack"],errorPrototypeProperties=["name","message","description","number","code","fileName","lineNumber","columnNumber","sourceURL","line","column","stack"];function create(e){return function(r,t,o,n){var a=[],c="";"string"==typeof r?(a=slice.call(arguments),r=t=void 0):"string"==typeof t?(a=slice.call(arguments,1),t=void 0):"string"==typeof o&&(a=slice.call(arguments,2)),a.length>0&&(c=module.exports.formatter.apply(null,a)),r&&r.message&&(c+=(c?" \n":"")+r.message);var i=new e(c);return extendError(i,r),extendToJSON(i),extend(i,t),i}}function extendError(e,r){extendStack(e,r),extend(e,r)}function extendToJSON(e){e.toJSON=errorToJSON,e.inspect=errorToString}function extend(e,r){if(r&&"object"==typeof r)for(var t=Object.keys(r),o=0;o<t.length;o++){var n=t[o];if(!(protectedProperties.indexOf(n)>=0))try{e[n]=r[n]}catch(e){}}}function errorToJSON(){var e={},r=Object.keys(this);r=r.concat(errorPrototypeProperties);for(var t=0;t<r.length;t++){var o=r[t],n=this[o],a=typeof n;"undefined"!==a&&"function"!==a&&(e[o]=n)}return e}function errorToString(){return JSON.stringify(this,null,2).replace(/\\n/g,"\n")}function extendStack(e,r){hasLazyStack(e)?r?lazyJoinStacks(e,r):lazyPopStack(e):e.stack=r?joinStacks(e.stack,r.stack):popStack(e.stack)}function joinStacks(e,r){return(e=popStack(e))&&r?e+"\n\n"+r:e||r}function popStack(e){if(e){var r=e.split("\n");if(r.length<2)return e;for(var t=0;t<r.length;t++){if(r[t].indexOf("onoFactory")>=0)return r.splice(t,1),r.join("\n")}return e}}module.exports=create(Error),module.exports.error=create(Error),module.exports.eval=create(EvalError),module.exports.range=create(RangeError),module.exports.reference=create(ReferenceError),module.exports.syntax=create(SyntaxError),module.exports.type=create(TypeError),module.exports.uri=create(URIError),module.exports.formatter=format;var supportsLazyStack=!(!Object.getOwnPropertyDescriptor||!Object.defineProperty||"undefined"!=typeof navigator&&/Android/.test(navigator.userAgent));function hasLazyStack(e){if(!supportsLazyStack)return!1;var r=Object.getOwnPropertyDescriptor(e,"stack");return!!r&&"function"==typeof r.get}function lazyJoinStacks(e,r){var t=Object.getOwnPropertyDescriptor(e,"stack");Object.defineProperty(e,"stack",{get:function(){return joinStacks(t.get.apply(e),r.stack)},enumerable:!1,configurable:!0})}function lazyPopStack(e){var r=Object.getOwnPropertyDescriptor(e,"stack");Object.defineProperty(e,"stack",{get:function(){return popStack(r.get.apply(e))},enumerable:!1,configurable:!0})}},{"format-util":2}],2:[function(require,module,exports){function format(e){var r=Array.prototype.slice.call(arguments,1);return r.length&&(e=e.replace(/(%?)(%([jds]))/g,function(e,t,a,n){var s=r.shift();switch(n){case"s":s=""+s;break;case"d":s=Number(s);break;case"j":s=JSON.stringify(s)}return t?(r.unshift(s),e):s})),r.length&&(e+=" "+r.join(" ")),""+(e=e.replace(/%{2,2}/g,"%"))}module.exports=format},{}],3:[function(require,module,exports){"use strict";function hasOwnProperty(r,e){return Object.prototype.hasOwnProperty.call(r,e)}module.exports=function(r,e,t,n){e=e||"&",t=t||"=";var o={};if("string"!=typeof r||0===r.length)return o;var a=/\+/g;r=r.split(e);var s=1e3;n&&"number"==typeof n.maxKeys&&(s=n.maxKeys);var p=r.length;s>0&&p>s&&(p=s);for(var y=0;y<p;++y){var u,c,i,l,f=r[y].replace(a,"%20"),v=f.indexOf(t);v>=0?(u=f.substr(0,v),c=f.substr(v+1)):(u=f,c=""),i=decodeURIComponent(u),l=decodeURIComponent(c),hasOwnProperty(o,i)?isArray(o[i])?o[i].push(l):o[i]=[o[i],l]:o[i]=l}return o};var isArray=Array.isArray||function(r){return"[object Array]"===Object.prototype.toString.call(r)}},{}],4:[function(require,module,exports){"use strict";var stringifyPrimitive=function(r){switch(typeof r){case"string":return r;case"boolean":return r?"true":"false";case"number":return isFinite(r)?r:"";default:return""}};module.exports=function(r,e,t,n){return e=e||"&",t=t||"=",null===r&&(r=void 0),"object"==typeof r?map(objectKeys(r),function(n){var i=encodeURIComponent(stringifyPrimitive(n))+t;return isArray(r[n])?map(r[n],function(r){return i+encodeURIComponent(stringifyPrimitive(r))}).join(e):i+encodeURIComponent(stringifyPrimitive(r[n]))}).join(e):n?encodeURIComponent(stringifyPrimitive(n))+t+encodeURIComponent(stringifyPrimitive(r)):""};var isArray=Array.isArray||function(r){return"[object Array]"===Object.prototype.toString.call(r)};function map(r,e){if(r.map)return r.map(e);for(var t=[],n=0;n<r.length;n++)t.push(e(r[n],n));return t}var objectKeys=Object.keys||function(r){var e=[];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&e.push(t);return e}},{}],5:[function(require,module,exports){"use strict";exports.decode=exports.parse=require("./decode"),exports.encode=exports.stringify=require("./encode")},{"./decode":3,"./encode":4}],6:[function(require,module,exports){"use strict";var debug="localhost"===location.hostname;function analytics(){debug||(ga("create","UA-68102273-1","auto"),ga("send","pageview"))}module.exports=analytics,analytics.trackEvent=function(e,o,n,t){debug?console.log("Reporting an event to Google Analytics: ",e,o,n,t):ga("send","event",e,o,n,t)},analytics.trackError=function(e){debug?console.error("Reporting an error to Google Analytics: ",e):ga("send","exception",{exDescription:e.message})}},{}],7:[function(require,module,exports){"use strict";var form=require("./form"),analytics=require("./analytics");function dropdowns(){setSelectedMethod(form.method.button.val()),onChange(form.allow.menu,setAllowLabel),onChange(form.refs.menu,setRefsLabel),onChange(form.validate.menu,setValidateLabel),trackCheckbox(form.allow.json),trackCheckbox(form.allow.yaml),trackCheckbox(form.allow.text),trackCheckbox(form.allow.empty),trackCheckbox(form.allow.unknown),trackCheckbox(form.refs.external),trackCheckbox(form.refs.circular),trackCheckbox(form.validate.schema),trackCheckbox(form.validate.spec),form.method.menu.find("a").on("click",function(e){form.method.menu.dropdown("toggle"),e.stopPropagation();var a=$(this).data("value");setSelectedMethod(a),trackButtonLabel(a)})}function onChange(e,a){var t=e.parent(".dropdown");e.find("a").on("click",function(e){e.stopPropagation()}),a(),t.on("hidden.bs.dropdown",a),t.on("shown.bs.dropdown",function(){analytics.trackEvent("options","shown",e.attr("id"))})}function setAllowLabel(){var e=getCheckedAndUnchecked(form.allow.json,form.allow.yaml,form.allow.text,form.allow.empty,form.allow.unknown);switch(e.checked.length){case 0:form.allow.label.text("No file types allowed");break;case 1:form.allow.label.text("Only allow "+e.checked[0]+" files");break;case 2:form.allow.label.text("Only allow "+e.checked[0]+" and "+e.checked[1]);break;case 3:form.allow.label.text("Don't allow "+e.unchecked[0]+" or "+e.unchecked[1]);break;case 4:form.allow.label.text("Don't allow "+e.unchecked[0]+" files");break;case 5:form.allow.label.text("Allow all file types")}}function setRefsLabel(){var e=getCheckedAndUnchecked(form.refs.external,form.refs.circular);switch(e.checked.length){case 0:form.refs.label.text("Only follow internal $refs");break;case 1:form.refs.label.text("Don't follow "+e.unchecked[0]+" $refs");break;case 2:form.refs.label.text("Follow all $refs")}}function setValidateLabel(){var e=getCheckedAndUnchecked(form.validate.schema,form.validate.spec);switch(e.checked.length){case 0:form.validate.label.text("Don't validate anything");break;case 1:form.validate.label.text("Don't validate Swagger "+e.unchecked[0]);break;case 2:form.validate.label.text("Validate everything")}}function setSelectedMethod(e){form.method.button.val(e.toLowerCase()),e=e[0].toUpperCase()+e.substr(1),form.method.button.text(e+" it!"),form.tabs.url.text(e+" a URL"),form.tabs.text.text(e+" Text")}function trackCheckbox(e){e.on("change",function(){var a=e.is(":checked")?1:0;analytics.trackEvent("options","changed",e.attr("name"),a)})}function trackButtonLabel(e){var a=["","parse","resolve","bundle","dereference","validate"].indexOf(e);analytics.trackEvent("options","changed","method",a)}function getCheckedAndUnchecked(e){for(var a=[],t=[],o=0;o<arguments.length;o++){var l=arguments[o];l.is(":checked")?a.push(l.data("value")):t.push(l.data("value"))}return{checked:a,unchecked:t}}module.exports=dropdowns},{"./analytics":6,"./form":9}],8:[function(require,module,exports){"use strict";var form=require("./form"),ono=require("ono"),ACE_THEME="ace/theme/terminal";function editors(){editors.textBox=form.textBox=ace.edit("text-box"),form.textBox.setTheme(ACE_THEME);var e=form.textBox.getSession();e.setMode("ace/mode/yaml"),e.setTabSize(2),editors.results=$("#results"),editors.tabs=editors.results.find(".nav-tabs"),editors.panes=editors.results.find(".tab-content")}function getShortTitle(e){var t=e.lastIndexOf("/");return-1!==t&&(e=e.substr(t+1)),e.length>15&&(e=e.substr(0,10)+"..."),e}function showResults(){var e=editors.results;setTimeout(function(){e[0].scrollIntoView(),e.addClass("animated").one("webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend",function(){e.removeClass("animated")})})}function toText(e){if(e instanceof Error)return{isJSON:!1,text:e.message+"\n\n"+e.stack};try{return{isJSON:!0,text:JSON.stringify(e,null,2)}}catch(e){return{isJSON:!1,text:"This API is valid, but it cannot be shown because it contains circular references\n\n"+e.stack}}}module.exports=editors,editors.clearResults=function(){editors.results.removeClass("error animated").addClass("hidden"),editors.tabs.children().remove(),editors.panes.children().remove()},editors.showResult=function(e,t){editors.results.removeClass("hidden"),editors.addResult(e||"Sample API",t),showResults()},editors.showError=function(e){editors.results.removeClass("hidden").addClass("error"),editors.addResult("Error!",e),showResults()},editors.addResult=function(e,t){var s=editors.tabs.children().length,r="results-tab-"+s+"-title",o="results-"+s,i=0===s?"active":"";editors.tabs.append('<li id="results-tab-'+s+'" class="'+i+'" role="presentation"> <a id="'+r+'" href="#results-pane-'+s+'" role="tab" aria-controls="results-pane-'+s+'" data-toggle="tab"></a></li>'),editors.panes.append('<div id="results-pane-'+s+'" class="tab-pane '+i+'" role="tabpanel"> <pre id="'+o+'" class="editor"></pre></div>');var n=getShortTitle(e);editors.tabs.find("#"+r).text(n).attr("title",e),t=toText(t),editors.panes.find("#"+o).text(t.text);var a=ace.edit(o);a.setTheme(ACE_THEME),a.session.setOption("useWorker",!1),t.isJSON&&a.getSession().setMode("ace/mode/json"),a.setReadOnly(!0)}},{"./form":9,ono:1}],9:[function(require,module,exports){"use strict";function form(){form.form=$("#swagger-parser-form"),form.allow={label:form.form.find("#allow-label"),menu:form.form.find("#allow-menu"),json:form.form.find("input[name=allow-json]"),yaml:form.form.find("input[name=allow-yaml]"),text:form.form.find("input[name=allow-text]"),empty:form.form.find("input[name=allow-empty]"),unknown:form.form.find("input[name=allow-unknown]")},form.refs={label:form.form.find("#refs-label"),menu:form.form.find("#refs-menu"),external:form.form.find("input[name=refs-external]"),circular:form.form.find("input[name=refs-circular]")},form.validate={label:form.form.find("#validate-label"),menu:form.form.find("#validate-menu"),schema:form.form.find("input[name=validate-schema]"),spec:form.form.find("input[name=validate-spec]")},form.tabs={url:form.form.find("#url-tab"),text:form.form.find("#text-tab")},form.method={button:form.form.find("button[name=method]"),menu:form.form.find("#method-menu")},form.samples={url:{container:form.form.find("#url-sample"),link:form.form.find("#url-sample-link")},text:{container:form.form.find("#text-sample"),link:form.form.find("#text-sample-link")}},form.url=form.form.find("input[name=url]"),form.textBox=null,form.bookmark=form.form.find("#bookmark")}module.exports=form,form.getOptions=function(){return{parse:{json:!!form.allow.json.is(":checked")&&{allowEmpty:form.allow.empty.is(":checked")},yaml:!!form.allow.yaml.is(":checked")&&{allowEmpty:form.allow.empty.is(":checked")},text:!!form.allow.text.is(":checked")&&{allowEmpty:form.allow.empty.is(":checked")},binary:!!form.allow.unknown.is(":checked")&&{allowEmpty:form.allow.empty.is(":checked")}},resolve:{external:form.refs.external.is(":checked")},dereference:{circular:form.refs.circular.is(":checked")},validate:{schema:form.validate.schema.is(":checked"),spec:form.validate.spec.is(":checked")}}},form.getAPI=function(){if(form.tabs.url.parent().attr("class").indexOf("active")>=0){var r=form.url.val();if(r)return r;throw new URIError("Please specify the URL of your Swagger/OpenAPI definition")}var e=form.textBox.getValue();if(form.allow.yaml.is(":checked"))return SwaggerParser.YAML.parse(e);if(form.allow.json.is(":checked"))return JSON.parse(e);throw new SyntaxError("Unable to parse the API. Neither YAML nor JSON are allowed.")}},{}],10:[function(require,module,exports){"use strict";var form=require("./form"),querystring=require("./querystring"),dropdowns=require("./dropdowns"),editors=require("./editors"),samples=require("./samples"),parser=require("./parser"),analytics=require("./analytics");$(function(){form(),querystring(),dropdowns(),editors(),samples(),parser(),analytics()})},{"./analytics":6,"./dropdowns":7,"./editors":8,"./form":9,"./parser":11,"./querystring":12,"./samples":13}],11:[function(require,module,exports){"use strict";var form=require("./form"),editors=require("./editors"),analytics=require("./analytics"),ono=require("ono"),swaggerParser=null,counters={parse:0,resolve:0,bundle:0,dereference:0,validate:0};function parser(){form.form.on("submit",function(r){r.preventDefault(),parseSwagger()}),$("#clear").on("click",function(){swaggerParser=null,editors.clearResults(),analytics.trackEvent("results","clear")})}function parseSwagger(){try{editors.clearResults(),swaggerParser=swaggerParser||new SwaggerParser;var r=form.getOptions(),e=form.method.button.val(),s=form.getAPI();swaggerParser[e](s,r).then(function(){var r=swaggerParser.$refs.values();Object.keys(r).forEach(function(e){editors.showResult(e,r[e])})}).catch(function(r){editors.showError(ono(r)),analytics.trackError(r)}),counters[e]++,analytics.trackEvent("button","click",e,counters[e])}catch(r){editors.showError(ono(r)),analytics.trackError(r)}}module.exports=parser},{"./analytics":6,"./editors":8,"./form":9,ono:1}],12:[function(require,module,exports){"use strict";var qs=require("querystring"),form=require("./form");function querystring(){setFormFields(),setBookmarkURL(),form.bookmark.on("click focus mouseenter",setBookmarkURL)}function setFormFields(){var e=qs.parse(window.location.search.substr(1));setCheckbox(form.allow.json,e["allow-json"]),setCheckbox(form.allow.yaml,e["allow-yaml"]),setCheckbox(form.allow.text,e["allow-text"]),setCheckbox(form.allow.empty,e["allow-empty"]),setCheckbox(form.allow.unknown,e["allow-unknown"]),setCheckbox(form.refs.external,e["refs-external"]),setCheckbox(form.refs.circular,e["refs-circular"]),setCheckbox(form.validate.schema,e["validate-schema"]),setCheckbox(form.validate.spec,e["validate-spec"]),e.url&&form.url.val(e.url),e.method&&(e.method=e.method.toLowerCase(),-1!==["parse","resolve","bundle","dereference","validate"].indexOf(e.method)&&form.method.button.val(e.method))}function setCheckbox(e,o){o&&"true"!==o&&"on"!==o||(o="yes"),e.val([o])}function setBookmarkURL(){var e={},o=form.getOptions();o.parse.json||(e["allow-json"]="no"),o.parse.yaml||(e["allow-yaml"]="no"),o.parse.text||(e["allow-text"]="no"),o.parse.json.allowEmpty||(e["allow-empty"]="no"),o.parse.binary||(e["allow-unknown"]="no"),o.resolve.external||(e["refs-external"]="no"),o.dereference.circular||(e["refs-circular"]="no"),o.validate.schema||(e["validate-schema"]="no"),o.validate.spec||(e["validate-spec"]="no");var r=form.method.button.val();"validate"===r||(e.method=r);var a=form.url.val();""===a||(e.url=a);var t="?"+qs.stringify(e);form.bookmark.attr("href",t)}module.exports=querystring},{"./form":9,querystring:5}],13:[function(require,module,exports){"use strict";var form=require("./form");function samples(){form.samples.url.link.on("click",function(e){e.preventDefault(),form.url.val(samples.url)}),form.samples.text.link.on("click",function(e){e.preventDefault(),form.textBox.setValue(samples.text,-1),form.samples.text.container.hide(),form.textBox.focus()}),form.textBox.on("input",function(){0===form.textBox.session.getValue().length?form.samples.text.container.show():form.samples.text.container.hide()})}module.exports=samples,samples.url="https://bigstickcarpet.com/swagger-parser/www/swagger.yaml",samples.text='swagger: "2.0"\ninfo:\n version: 1.0.0\n title: Swagger Petstore\n description: >\n A sample API that uses a petstore as an example\n to demonstrate features in the swagger-2.0 specification\nconsumes:\n - application/json\nproduces:\n - application/json\npaths:\n /pets:\n get:\n description: Returns all pets from the petstore\n responses:\n "200":\n description: pet response\n schema:\n type: array\n items:\n $ref: "#/definitions/pet"\n default:\n description: unexpected error\n schema:\n $ref: "#/definitions/errorModel"\n post:\n description: Creates a new pet in the store\n parameters:\n - name: pet\n in: body\n description: Pet to add to the store\n required: true\n schema:\n $ref: "#/definitions/pet"\n responses:\n "200":\n description: pet response\n schema:\n $ref: "#/definitions/pet"\n default:\n description: unexpected error\n schema:\n $ref: "#/definitions/errorModel"\n "/pets/{name}":\n get:\n description: Returns a single pet by name\n parameters:\n - name: name\n in: path\n description: Name of the pet to fetch\n required: true\n type: string\n responses:\n "200":\n description: pet response\n schema:\n $ref: "#/definitions/pet"\n default:\n description: unexpected error\n schema:\n $ref: "#/definitions/errorModel"\ndefinitions:\n pet:\n $ref: pet.yaml\n pet-owner:\n $ref: pet-owner.yaml\n errorModel:\n $ref: error.json\n'},{"./form":9}]},{},[10]);
//# sourceMappingURL=bundle.min.js.map
//# sourceMappingURL=bundle.min.js.map