From: Alex Fan Date: Tue, 18 Nov 2014 23:07:44 +0000 (-0800) Subject: Bug-915: Adding static document generation. X-Git-Tag: release/lithium~836^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=0418261c9f3a985ee698dc2b039decbd50b3caf3 Bug-915: Adding static document generation. Currently the API Explorer can only be accessed from a running server. With this change, the API Explorer will be generated as static html pages at build time in the features folder. Change-Id: I0a898e1a3d9753fd2b046d690173838be057d6ea Signed-off-by: Alex Fan --- diff --git a/features/mdsal/pom.xml b/features/mdsal/pom.xml index 036d18fb85..6f43768a9d 100644 --- a/features/mdsal/pom.xml +++ b/features/mdsal/pom.xml @@ -380,6 +380,69 @@ + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + unpack-static-documentation + + unpack-dependencies + + generate-resources + + ${project.build.directory}/generated-resources/swagger-api-documentation + sal-rest-docgen + **/explorer/css/**/*, **/explorer/images/**/*, **/explorer/lib/**/*, **/explorer/static/**/*, + true + false + + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${yangtools.version} + + + org.opendaylight.yangtools + maven-sal-api-gen-plugin + ${yangtools.version} + jar + + + org.opendaylight.yangtools + yang-binding + ${yangtools.version} + jar + + + org.opendaylight.controller + sal-rest-docgen + ${mdsal.version} + jar + + + + + + generate-sources + + + src + + + org.opendaylight.controller.sal.rest.doc.impl.StaticDocGenerator + ${project.build.directory}/generated-resources/swagger-api-documentation/explorer/static + + + true + + + + diff --git a/opendaylight/md-sal/sal-rest-docgen/pom.xml b/opendaylight/md-sal/sal-rest-docgen/pom.xml index 3d3c52d7d1..53f1b2e692 100644 --- a/opendaylight/md-sal/sal-rest-docgen/pom.xml +++ b/opendaylight/md-sal/sal-rest-docgen/pom.xml @@ -72,6 +72,11 @@ yang-parser-impl + + org.opendaylight.yangtools + yang-maven-plugin-spi + + org.osgi org.osgi.core @@ -107,8 +112,12 @@ MD SAL Rest Api Doc Generator - *, - com.sun.jersey.spi.container.servlet, org.eclipse.jetty.servlets + !org.apache.maven.plugin.logging, + !org.apache.maven.project, + !org.opendaylight.yangtools.yang2sources.spi, + *, + com.sun.jersey.spi.container.servlet, org.eclipse.jetty.servlets + org.opendaylight.controller.sal.rest.doc.DocProvider /apidoc diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/StaticDocGenerator.java b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/StaticDocGenerator.java new file mode 100644 index 0000000000..b658102d6f --- /dev/null +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/java/org/opendaylight/controller/sal/rest/doc/impl/StaticDocGenerator.java @@ -0,0 +1,151 @@ +/* + * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ +package org.opendaylight.controller.sal.rest.doc.impl; + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; + +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.project.MavenProject; +import org.opendaylight.controller.sal.rest.doc.swagger.ApiDeclaration; +import org.opendaylight.controller.sal.rest.doc.swagger.Resource; +import org.opendaylight.controller.sal.rest.doc.swagger.ResourceList; +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.opendaylight.yangtools.yang2sources.spi.CodeGenerator; + +import javax.ws.rs.core.UriInfo; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * This class gathers all yang defined {@link Module}s and generates Swagger compliant documentation. + */ +public class StaticDocGenerator extends ApiDocGenerator implements CodeGenerator { + + private static final String DEFAULT_OUTPUT_BASE_DIR_PATH = "target" + File.separator + "generated-resources" + + File.separator + "swagger-api-documentation"; + + private static Logger _logger = LoggerFactory.getLogger(ApiDocGenerator.class); + + private MavenProject mavenProject; + private File projectBaseDir; + private Map additionalConfig; + private File resourceBaseDir; + private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + + /** + * + * @param context + * @param outputDir + * @param yangModules + * @return + * @throws IOException + */ + @Override + public Collection generateSources(SchemaContext context, File outputDir, Set yangModules) throws IOException { + List result = new ArrayList<>(); + + // Create Base Directory + final File outputBaseDir; + if (outputDir == null) { + outputBaseDir = new File(DEFAULT_OUTPUT_BASE_DIR_PATH); + } + else outputBaseDir = outputDir; + outputBaseDir.mkdirs(); + + // Create Resources directory + File resourcesDir = new File(outputBaseDir, "resources"); + resourcesDir.mkdirs(); + + // Create JS file + File resourcesJsFile = new File(outputBaseDir, "resources.js"); + resourcesJsFile.createNewFile(); + BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(resourcesJsFile)); + ObjectMapper mapper = new ObjectMapper(); + mapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); + + // Write resource listing to JS file + ResourceList resourceList = super.getResourceListing(null, context, ""); + String resourceListJson = mapper.writeValueAsString(resourceList); + resourceListJson = resourceListJson.replace("\'", "\\\'").replace("\\n", "\\\\n"); + bufferedWriter.write("function getSpec() {\n\treturn \'" + resourceListJson + "\';\n}\n\n"); + + // Write resources/APIs to JS file and to disk + bufferedWriter.write("function jsonFor(resource) {\n\tswitch(resource) {\n"); + for (Resource resource : resourceList.getApis()) { + int revisionIndex = resource.getPath().indexOf('('); + String name = resource.getPath().substring(0, revisionIndex); + String revision = resource.getPath().substring(revisionIndex + 1, resource.getPath().length() - 1); + ApiDeclaration apiDeclaration = super.getApiDeclaration(name, revision, null, context, ""); + String json = mapper.writeValueAsString(apiDeclaration); + // Manually insert models because org.json.JSONObject cannot be serialized by ObjectMapper + json = json.replace("\"models\":{}", "\"models\":" + apiDeclaration.getModels().toString().replace("\\\"", "\"")); + // Escape single quotes and new lines + json = json.replace("\'", "\\\'").replace("\\n", "\\\\n"); + bufferedWriter.write("\t\tcase \"" + name + "(" + revision + ")\": return \'" + json + "\';\n"); + + File resourceFile = new File(resourcesDir, name + "(" + revision + ").json"); + BufferedWriter resourceFileWriter = new BufferedWriter(new FileWriter(resourceFile)); + resourceFileWriter.write(json); + resourceFileWriter.close(); + result.add(resourceFile); + } + bufferedWriter.write("\t}\n\treturn \"\";\n}"); + bufferedWriter.close(); + + result.add(resourcesJsFile); + return result; + } + + @Override + protected String generatePath(UriInfo uriInfo, String name, String revision) { + if (uriInfo == null) { + return name + "(" + revision + ")"; + } + return super.generatePath(uriInfo, name, revision); + } + + @Override + protected String createBasePathFromUriInfo(UriInfo uriInfo) { + if (uriInfo == null) { + return RESTCONF_CONTEXT_ROOT; + } + return super.createBasePathFromUriInfo(uriInfo); + } + + @Override + public void setLog(Log log) { + } + + @Override + public void setAdditionalConfig(Map additionalConfig) { + this.additionalConfig = additionalConfig; + } + + @Override + public void setResourceBaseDir(File resourceBaseDir) { + this.resourceBaseDir = resourceBaseDir; + } + + @Override + public void setMavenProject(MavenProject mavenProject) { + this.mavenProject = mavenProject; + this.projectBaseDir = mavenProject.getBasedir(); + } +} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/README.txt b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/README.txt new file mode 100644 index 0000000000..7e72e8347c --- /dev/null +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/README.txt @@ -0,0 +1,79 @@ +This component offers Swagger documentation of the RestConf APIs. + +This Swagger documentation can be accessed in two ways: +I. Running server +Open a browser and go to http://:8181/apidoc/explorer/index.html + +II. Static documentation generation +By adding a reference to the StaticDocGenerator class in any pom.xml, +static documentation will be generated. This static documentation will +document all the RestConf APIs for the YANG files in that artifact and +all the YANG files in that artifact's dependencies. + +In order to generate static documentation for all resources, +this should be placed in a downstream project. + +Below is what you would add to the section under . + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + unpack-static-documentation + + unpack-dependencies + + generate-resources + + ${project.build.directory}/generated-resources/swagger-api-documentation + sal-rest-docgen + **/explorer/css/**/*, **/explorer/images/**/*, **/explorer/lib/**/*, **/explorer/static/**/*, + true + false + + + + + + org.opendaylight.yangtools + yang-maven-plugin + ${yangtools.version} + + + org.opendaylight.yangtools + maven-sal-api-gen-plugin + ${yangtools.version} + jar + + + org.opendaylight.yangtools + yang-binding + ${yangtools.version} + jar + + + org.opendaylight.controller + sal-rest-docgen + ${mdsal.version} + jar + + + + + + generate-sources + + + src + + + org.opendaylight.controller.sal.rest.doc.impl.StaticDocGenerator + ${project.build.directory}/generated-resources/swagger-api-documentation/explorer/static + + + true + + + + diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/fonts.css b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/fonts.css new file mode 100644 index 0000000000..4825d09352 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/fonts.css @@ -0,0 +1,16 @@ +/* latin */ +@font-face { + font-family: 'Droid Sans'; + font-style: normal; + font-weight: 400; + src: local('Droid Sans'), local('DroidSans'), url(http://fonts.gstatic.com/s/droidsans/v6/s-BiyweUPV0v-yRb-cjciAsYbbCjybiHxArTLjt7FRU.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; +} +/* latin */ +@font-face { + font-family: 'Droid Sans'; + font-style: normal; + font-weight: 700; + src: local('Droid Sans Bold'), local('DroidSans-Bold'), url(http://fonts.gstatic.com/s/droidsans/v6/EFpQQyG9GqCrobXxL-KRMX9tREKe1lLHLCwOC24WjMs.woff2) format('woff2'); + unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; +} \ No newline at end of file diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/index.html b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/index.html new file mode 100644 index 0000000000..6a7f6aaee8 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/index.html @@ -0,0 +1,109 @@ + + + + RestConf Documentation + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + +

OpenDaylight RestConf API + Documentation

+
+
+ + + + +
+ + +
+
+

Below are the list of APIs supported by the Controller.

+
+
+
+ +

+ + +
+ + +
+ +
 
+ + + diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/opendaylight.css b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/opendaylight.css new file mode 100644 index 0000000000..757938877f --- /dev/null +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/opendaylight.css @@ -0,0 +1,92 @@ +.fuelux [class^="icon-"], +.fuelux [class*=" icon-"] { + display: inline-block; + width: 14px; + height: 14px; + margin-top: 1px; + *margin-right: .3em; + line-height: 14px; + vertical-align: text-top; + background-position: 14px 14px; + background-repeat: no-repeat; +} + +.fuelux .icon-white, +.fuelux .nav-pills > .active > a > [class^="icon-"], +.fuelux .nav-pills > .active > a > [class*=" icon-"], +.fuelux .nav-list > .active > a > [class^="icon-"], +.fuelux .nav-list > .active > a > [class*=" icon-"], +.fuelux .navbar-inverse .nav > .active > a > [class^="icon-"], +.fuelux .navbar-inverse .nav > .active > a > [class*=" icon-"], +.fuelux .dropdown-menu > li > a:hover > [class^="icon-"], +.fuelux .dropdown-menu > li > a:focus > [class^="icon-"], +.fuelux .dropdown-menu > li > a:hover > [class*=" icon-"], +.fuelux .dropdown-menu > li > a:focus > [class*=" icon-"], +.fuelux .dropdown-menu > .active > a > [class^="icon-"], +.fuelux .dropdown-menu > .active > a > [class*=" icon-"], +.fuelux .dropdown-submenu:hover > a > [class^="icon-"], +.fuelux .dropdown-submenu:focus > a > [class^="icon-"], +.fuelux .dropdown-submenu:hover > a > [class*=" icon-"], +.fuelux .dropdown-submenu:focus > a > [class*=" icon-"] { +} + +.fuelux .icon-search { + background:url('../img/search.png') 0 0 no-repeat; + height: 16px; + line-height: 16px; + width: 16px; +} +.fuelux .icon-remove { + background:url('../img/searchremove.png') 0 0 no-repeat; + height: 16px; + line-height: 16px; + width: 16px; +} + +.fuelux .icon-chevron-up { + background:url('../img/sort_up.png') 0 0 no-repeat; + height: 16px; + line-height: 16px; + width: 16px; +} + +.fuelux .icon-chevron-down { + background:url('../img/sort_down.png') 0 0 no-repeat; + height: 16px; + line-height: 16px; + width: 16px; +} + +.fuelux .icon-chevron-left { + background:url('../img/nextpageleft.png') 0 0 no-repeat; + height: 16px; + line-height: 16px; + width: 16px; +} + +.fuelux .icon-chevron-right { + background:url('../img/nextpageright.png') 0 0 no-repeat; + height: 16px; + line-height: 16px; + width: 16px; +} + +.fuelux .icon-chevron-right { + background:url('../img/nextpageright.png') 0 0 no-repeat; + height: 16px; + line-height: 16px; + width: 16px; +} + +.tip { + background-color: white; + border: 1px solid #CCCCCC; + box-shadow: 2px 2px 8px #555555; + color: #111111; + font-family: Verdana,Geneva,Arial,Helvetica,sans-serif; + font-size: 14px; + opacity: 0.9; + padding: 7px; + width: 260px; + border-radius: 8px; +} diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/swagger-ui.js b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/swagger-ui.js new file mode 100644 index 0000000000..aabab7cc40 --- /dev/null +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/swagger-ui.js @@ -0,0 +1,2114 @@ +$(function() { + + // Helper function for vertically aligning DOM elements + // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/ + $.fn.vAlign = function() { + return this.each(function(i){ + var ah = $(this).height(); + var ph = $(this).parent().height(); + var mh = (ph - ah) / 2; + $(this).css('margin-top', mh); + }); + }; + + $.fn.stretchFormtasticInputWidthToParent = function() { + return this.each(function(i){ + var p_width = $(this).closest("form").innerWidth(); + var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10); + var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); + $(this).css('width', p_width - p_padding - this_padding); + }); + }; + + $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent(); + + // Vertically center these paragraphs + // Parent may need a min-height for this to work.. + $('ul.downplayed li div.content p').vAlign(); + + // When a sandbox form is submitted.. + $("form.sandbox").submit(function(){ + + var error_free = true; + + // Cycle through the forms required inputs + $(this).find("input.required").each(function() { + + // Remove any existing error styles from the input + $(this).removeClass('error'); + + // Tack the error style on if the input is empty.. + if ($(this).val() == '') { + $(this).addClass('error'); + $(this).wiggle(); + error_free = false; + } + + }); + + return error_free; + }); + +}); + +function clippyCopiedCallback(a) { + $('#api_key_copied').fadeIn().delay(1000).fadeOut(); + + // var b = $("#clippy_tooltip_" + a); + // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() { + // b.attr("title", "copy to clipboard") + // }, + // 500)) +} + +// Logging function that accounts for browsers that don't have window.console +function log() { + if (window.console) console.log.apply(console,arguments); +} +// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) +if (Function.prototype.bind && console && typeof console.log == "object") { + [ + "log","info","warn","error","assert","dir","clear","profile","profileEnd" + ].forEach(function (method) { + console[method] = this.bind(console[method], console); + }, Function.prototype.call); +} + +var Docs = { + + shebang: function() { + + // If shebang has an operation nickname in it.. + // e.g. /docs/#!/words/get_search + var fragments = $.param.fragment().split('/'); + fragments.shift(); // get rid of the bang + + switch (fragments.length) { + case 1: + // Expand all operations for the resource and scroll to it +// log('shebang resource:' + fragments[0]); + var dom_id = 'resource_' + fragments[0]; + + Docs.expandEndpointListForResource(fragments[0]); + $("#"+dom_id).slideto({highlight: false}); + break; + case 2: + // Refer to the endpoint DOM element, e.g. #words_get_search +// log('shebang endpoint: ' + fragments.join('_')); + + // Expand Resource + Docs.expandEndpointListForResource(fragments[0]); + $("#"+dom_id).slideto({highlight: false}); + + // Expand operation + var li_dom_id = fragments.join('_'); + var li_content_dom_id = li_dom_id + "_content"; + +// log("li_dom_id " + li_dom_id); +// log("li_content_dom_id " + li_content_dom_id); + + Docs.expandOperation($('#'+li_content_dom_id)); + $('#'+li_dom_id).slideto({highlight: false}); + break; + } + + }, + + toggleEndpointListForResource: function(resource) { + var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); + if (elem.is(':visible')) { + Docs.collapseEndpointListForResource(resource); + } else { + Docs.expandEndpointListForResource(resource); + } + }, + + // Expand resource + expandEndpointListForResource: function(resource) { + var resource = Docs.escapeResourceName(resource); + if (resource == '') { + $('.resource ul.endpoints').slideDown(); + return; + } + + $('li#resource_' + resource).addClass('active'); + + var elem = $('li#resource_' + resource + ' ul.endpoints'); + elem.slideDown(); + }, + + // Collapse resource and mark as explicitly closed + collapseEndpointListForResource: function(resource) { + var resource = Docs.escapeResourceName(resource); + $('li#resource_' + resource).removeClass('active'); + + var elem = $('li#resource_' + resource + ' ul.endpoints'); + elem.slideUp(); + }, + + expandOperationsForResource: function(resource) { + // Make sure the resource container is open.. + Docs.expandEndpointListForResource(resource); + + if (resource == '') { + $('.resource ul.endpoints li.operation div.content').slideDown(); + return; + } + + $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { + Docs.expandOperation($(this)); + }); + }, + + collapseOperationsForResource: function(resource) { + // Make sure the resource container is open.. + Docs.expandEndpointListForResource(resource); + + $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { + Docs.collapseOperation($(this)); + }); + }, + + escapeResourceName: function(resource) { + return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&"); + }, + + expandOperation: function(elem) { + elem.slideDown(); + }, + + collapseOperation: function(elem) { + elem.slideUp(); + } + +}; +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", self=this; + + function program1(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers.each.call(depth0, depth0.produces, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n"; + return buffer; + } + function program2(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program4(depth0,data) { + + + return "\n \n"; + } + + buffer += "\n\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['main'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; + + function program1(depth0,data) { + + var buffer = "", stack1, stack2; + buffer += "\n
" + + escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + + "
\n
"; + stack2 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.description)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1); + if(stack2 || stack2 === 0) { buffer += stack2; } + buffer += "
\n "; + stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); + if(stack2 || stack2 === 0) { buffer += stack2; } + buffer += "\n "; + stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data}); + if(stack2 || stack2 === 0) { buffer += stack2; } + buffer += "\n "; + stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license), {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data}); + if(stack2 || stack2 === 0) { buffer += stack2; } + buffer += "\n "; + return buffer; + } + function program2(depth0,data) { + + var buffer = "", stack1; + buffer += ""; + return buffer; + } + + function program4(depth0,data) { + + var buffer = "", stack1; + buffer += ""; + return buffer; + } + + function program6(depth0,data) { + + var buffer = "", stack1; + buffer += ""; + return buffer; + } + + function program8(depth0,data) { + + var buffer = "", stack1; + buffer += "\n , api version: "; + if (stack1 = helpers.apiVersion) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.apiVersion; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + "\n "; + return buffer; + } + + buffer += "
\n "; + stack1 = helpers['if'].call(depth0, depth0.info, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n
\n
\n
    \n
\n\n
\n
\n
\n

[ base url: "; + if (stack1 = helpers.basePath) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.basePath; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + "\n "; + stack1 = helpers['if'].call(depth0, depth0.apiVersion, {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "]

\n
\n
\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['operation'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; + + function program1(depth0,data) { + + var buffer = "", stack1; + buffer += "\n

Implementation Notes

\n

"; + if (stack1 = helpers.notes) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.notes; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "

\n "; + return buffer; + } + + function program3(depth0,data) { + + + return "\n

Response Class

\n

\n
\n
\n "; + } + + function program5(depth0,data) { + + + return "\n

Parameters

\n \n \n \n \n \n \n \n \n \n \n \n\n \n
ParameterValueDescriptionParameter TypeData Type
\n "; + } + + function program7(depth0,data) { + + + return "\n
\n

Error Status Codes

\n \n \n \n \n \n \n \n \n \n \n
HTTP Status CodeReason
\n "; + } + + function program9(depth0,data) { + + + return "\n "; + } + + function program11(depth0,data) { + + + return "\n
\n \n \n
\n "; + } + + buffer += "\n \n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['param'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; + + function program1(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(4, program4, data),fn:self.program(2, program2, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program2(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n
\n "; + return buffer; + } + + function program4(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program5(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program7(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n
\n
\n "; + return buffer; + } + + function program9(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(12, program12, data),fn:self.program(10, program10, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program10(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program12(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + buffer += ""; + if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + "\n\n\n "; + stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(9, program9, data),fn:self.program(1, program1, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n\n"; + if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n"; + if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n \n\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['param_list'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, stack2, self=this, functionType="function", escapeExpression=this.escapeExpression; + + function program1(depth0,data) { + + + return " multiple='multiple'"; + } + + function program3(depth0,data) { + + + return "\n "; + } + + function program5(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(8, program8, data),fn:self.program(6, program6, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program6(depth0,data) { + + + return "\n "; + } + + function program8(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.allowMultiple, {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program9(depth0,data) { + + + return "\n "; + } + + function program11(depth0,data) { + + + return "\n \n "; + } + + function program13(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.isDefault, {hash:{},inverse:self.program(16, program16, data),fn:self.program(14, program14, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program14(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program16(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + buffer += ""; + if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + "\n\n \n\n"; + if (stack2 = helpers.description) { stack2 = stack2.call(depth0, {hash:{},data:data}); } + else { stack2 = depth0.description; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; } + if(stack2 || stack2 === 0) { buffer += stack2; } + buffer += "\n"; + if (stack2 = helpers.paramType) { stack2 = stack2.call(depth0, {hash:{},data:data}); } + else { stack2 = depth0.paramType; stack2 = typeof stack2 === functionType ? stack2.apply(depth0) : stack2; } + if(stack2 || stack2 === 0) { buffer += stack2; } + buffer += "\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['param_readonly'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; + + function program1(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program3(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program4(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + "\n "; + return buffer; + } + + function program6(depth0,data) { + + + return "\n (empty)\n "; + } + + buffer += ""; + if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + "\n\n "; + stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n"; + if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n"; + if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['param_readonly_required'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; + + function program1(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program3(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(6, program6, data),fn:self.program(4, program4, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program4(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + "\n "; + return buffer; + } + + function program6(depth0,data) { + + + return "\n (empty)\n "; + } + + buffer += ""; + if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + "\n\n "; + stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(3, program3, data),fn:self.program(1, program1, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n"; + if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n"; + if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['param_required'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; + + function program1(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(4, program4, data),fn:self.program(2, program2, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program2(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program4(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program5(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program7(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n
\n
\n "; + return buffer; + } + + function program9(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(12, program12, data),fn:self.program(10, program10, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program10(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program12(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(15, program15, data),fn:self.program(13, program13, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } + function program13(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program15(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + buffer += ""; + if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + "\n\n "; + stack1 = helpers['if'].call(depth0, depth0.isBody, {hash:{},inverse:self.program(9, program9, data),fn:self.program(1, program1, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n\n "; + if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n"; + if (stack1 = helpers.paramType) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.paramType; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['parameter_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", self=this; + + function program1(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers.each.call(depth0, depth0.consumes, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n"; + return buffer; + } + function program2(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program4(depth0,data) { + + + return "\n \n"; + } + + stack1 = helpers['if'].call(depth0, depth0.consumes, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['resource'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, options, functionType="function", escapeExpression=this.escapeExpression, self=this, blockHelperMissing=helpers.blockHelperMissing; + + function program1(depth0,data) { + + + return " : "; + } + + buffer += "
\n

\n "; + if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + " "; + options = {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data}; + if (stack1 = helpers.description) { stack1 = stack1.call(depth0, options); } + else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if (!helpers.description) { stack1 = blockHelperMissing.call(depth0, stack1, options); } + if(stack1 || stack1 === 0) { buffer += stack1; } + if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n

\n \n
\n\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['response_content_type'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", self=this; + + function program1(depth0,data) { + + var buffer = "", stack1; + buffer += "\n "; + stack1 = helpers.each.call(depth0, depth0.produces, {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n"; + return buffer; + } + function program2(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } + + function program4(depth0,data) { + + + return "\n \n"; + } + + stack1 = helpers['if'].call(depth0, depth0.produces, {hash:{},inverse:self.program(4, program4, data),fn:self.program(1, program1, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['signature'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression; + + + buffer += "
\n\n
\n\n
\n
\n "; + if (stack1 = helpers.signature) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.signature; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n
\n\n
\n
";
+    if (stack1 = helpers.sampleJSON) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
+    else { stack1 = depth0.sampleJSON; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
+    buffer += escapeExpression(stack1)
+      + "
\n \n
\n
\n\n"; + return buffer; + }); +})(); + +(function() { + var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; + templates['status_code'] = template(function (Handlebars,depth0,helpers,partials,data) { + this.compilerInfo = [4,'>= 1.0.0']; + helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression; + + + buffer += ""; + if (stack1 = helpers.code) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.code; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + buffer += escapeExpression(stack1) + + "\n"; + if (stack1 = helpers.message) { stack1 = stack1.call(depth0, {hash:{},data:data}); } + else { stack1 = depth0.message; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; } + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n"; + return buffer; + }); +})(); + + + +// Generated by CoffeeScript 1.6.3 +(function() { + var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi, _ref, _ref1, _ref10, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9, + __hasProp = {}.hasOwnProperty, + __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }; + + SwaggerUi = (function(_super) { + __extends(SwaggerUi, _super); + + function SwaggerUi() { + _ref = SwaggerUi.__super__.constructor.apply(this, arguments); + return _ref; + } + + SwaggerUi.prototype.dom_id = "swagger_ui"; + + SwaggerUi.prototype.options = null; + + SwaggerUi.prototype.api = null; + + SwaggerUi.prototype.headerView = null; + + SwaggerUi.prototype.mainView = null; + + SwaggerUi.prototype.initialize = function(options) { + var _this = this; + if (options == null) { + options = {}; + } + if (options.dom_id != null) { + this.dom_id = options.dom_id; + delete options.dom_id; + } + if ($('#' + this.dom_id) == null) { + $('body').append('
'); + } + this.options = options; + this.options.success = function() { + return _this.render(); + }; + this.options.progress = function(d) { + return _this.showMessage(d); + }; + this.options.failure = function(d) { + return _this.onLoadFailure(d); + }; + this.headerView = new HeaderView({ + el: $('#header') + }); + return this.headerView.on('update-swagger-ui', function(data) { + return _this.updateSwaggerUi(data); + }); + }; + + SwaggerUi.prototype.updateSwaggerUi = function(data) { + this.options.url = data.url; + return this.load(); + }; + + SwaggerUi.prototype.load = function() { + var url, _ref1; + if ((_ref1 = this.mainView) != null) { + _ref1.clear(); + } + url = this.options.url; + if (url.indexOf("http") !== 0) { + url = this.buildUrl(window.location.href.toString(), url); + } + this.options.url = url; + this.headerView.update(url); + this.api = new SwaggerApi(this.options); + this.api.build(); + return this.api; + }; + + SwaggerUi.prototype.render = function() { + var _this = this; + this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...'); + this.mainView = new MainView({ + model: this.api, + el: $('#' + this.dom_id) + }).render(); + this.showMessage(); + switch (this.options.docExpansion) { + case "full": + Docs.expandOperationsForResource(''); + break; + case "list": + Docs.collapseOperationsForResource(''); + } + if (this.options.onComplete) { + this.options.onComplete(this.api, this); + } + return setTimeout(function() { + return Docs.shebang(); + }, 400); + }; + + SwaggerUi.prototype.buildUrl = function(base, url) { + var parts; + console.log("base is " + base); + parts = base.split("/"); + base = parts[0] + "//" + parts[2]; + if (url.indexOf("/") === 0) { + return base + url; + } else { + return base + "/" + url; + } + }; + + SwaggerUi.prototype.showMessage = function(data) { + if (data == null) { + data = ''; + } + $('#message-bar').removeClass('message-fail'); + $('#message-bar').addClass('message-success'); + return $('#message-bar').html(data); + }; + + SwaggerUi.prototype.onLoadFailure = function(data) { + var val; + if (data == null) { + data = ''; + } + $('#message-bar').removeClass('message-success'); + $('#message-bar').addClass('message-fail'); + val = $('#message-bar').html(data); + if (this.options.onFailure != null) { + this.options.onFailure(data); + } + return val; + }; + + return SwaggerUi; + + })(Backbone.Router); + + window.SwaggerUi = SwaggerUi; + + HeaderView = (function(_super) { + __extends(HeaderView, _super); + + function HeaderView() { + _ref1 = HeaderView.__super__.constructor.apply(this, arguments); + return _ref1; + } + + HeaderView.prototype.events = { + 'click #show-pet-store-icon': 'showPetStore', + 'click #show-wordnik-dev-icon': 'showWordnikDev', + 'click #explore': 'showCustom', + 'keyup #input_baseUrl': 'showCustomOnKeyup', + 'keyup #input_apiKey': 'showCustomOnKeyup' + }; + + HeaderView.prototype.initialize = function() {}; + + HeaderView.prototype.showPetStore = function(e) { + return this.trigger('update-swagger-ui', { + url: "http://petstore.swagger.wordnik.com/api/api-docs" + }); + }; + + HeaderView.prototype.showWordnikDev = function(e) { + return this.trigger('update-swagger-ui', { + url: "http://api.wordnik.com/v4/resources.json" + }); + }; + + HeaderView.prototype.showCustomOnKeyup = function(e) { + if (e.keyCode === 13) { + return this.showCustom(); + } + }; + + HeaderView.prototype.showCustom = function(e) { + if (e != null) { + e.preventDefault(); + } + return this.trigger('update-swagger-ui', { + url: $('#input_baseUrl').val(), + apiKey: $('#input_apiKey').val() + }); + }; + + HeaderView.prototype.update = function(url, apiKey, trigger) { + if (trigger == null) { + trigger = false; + } + $('#input_baseUrl').val(url); + if (trigger) { + return this.trigger('update-swagger-ui', { + url: url + }); + } + }; + + return HeaderView; + + })(Backbone.View); + + MainView = (function(_super) { + __extends(MainView, _super); + + function MainView() { + _ref2 = MainView.__super__.constructor.apply(this, arguments); + return _ref2; + } + + MainView.prototype.initialize = function() {}; + + MainView.prototype.render = function() { + var resource, _i, _len, _ref3; + $(this.el).html(Handlebars.templates.main(this.model)); + _ref3 = this.model.apisArray; + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { + resource = _ref3[_i]; + this.addResource(resource); + } + return this; + }; + + MainView.prototype.addResource = function(resource) { + var resourceView; + resourceView = new ResourceView({ + model: resource, + tagName: 'li', + id: 'resource_' + resource.name, + className: 'resource' + }); + return $('#resources').append(resourceView.render().el); + }; + + MainView.prototype.clear = function() { + return $(this.el).html(''); + }; + + return MainView; + + })(Backbone.View); + + ResourceView = (function(_super) { + __extends(ResourceView, _super); + + function ResourceView() { + _ref3 = ResourceView.__super__.constructor.apply(this, arguments); + return _ref3; + } + + ResourceView.prototype.initialize = function() {}; + + ResourceView.prototype.render = function() { + var operation, _i, _len, _ref4; + console.log(this.model.description); + $(this.el).html(Handlebars.templates.resource(this.model)); + this.number = 0; + _ref4 = this.model.operationsArray; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + operation = _ref4[_i]; + this.addOperation(operation); + } + return this; + }; + + ResourceView.prototype.addOperation = function(operation) { + var operationView; + operation.number = this.number; + operationView = new OperationView({ + model: operation, + tagName: 'li', + className: 'endpoint' + }); + $('.endpoints', $(this.el)).append(operationView.render().el); + return this.number++; + }; + + return ResourceView; + + })(Backbone.View); + + OperationView = (function(_super) { + __extends(OperationView, _super); + + function OperationView() { + _ref4 = OperationView.__super__.constructor.apply(this, arguments); + return _ref4; + } + + OperationView.prototype.invocationUrl = null; + + OperationView.prototype.events = { + 'submit .sandbox': 'submitOperation', + 'click .submit': 'submitOperation', + 'click .response_hider': 'hideResponse', + 'click .toggleOperation': 'toggleOperationContent' + }; + + OperationView.prototype.initialize = function() {}; + + OperationView.prototype.render = function() { + var contentTypeModel, isMethodSubmissionSupported, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7; + isMethodSubmissionSupported = true; + if (!isMethodSubmissionSupported) { + this.model.isReadOnly = true; + } + $(this.el).html(Handlebars.templates.operation(this.model)); + if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') { + signatureModel = { + sampleJSON: this.model.responseSampleJSON, + isParam: false, + signature: this.model.responseClassSignature + }; + responseSignatureView = new SignatureView({ + model: signatureModel, + tagName: 'div' + }); + $('.model-signature', $(this.el)).append(responseSignatureView.render().el); + } else { + $('.model-signature', $(this.el)).html(this.model.type); + } + contentTypeModel = { + isParam: false + }; + contentTypeModel.consumes = this.model.consumes; + contentTypeModel.produces = this.model.produces; + _ref5 = this.model.parameters; + for (_i = 0, _len = _ref5.length; _i < _len; _i++) { + param = _ref5[_i]; + type = param.type || param.dataType; + if (type.toLowerCase() === 'file') { + if (!contentTypeModel.consumes) { + console.log("set content type "); + contentTypeModel.consumes = 'multipart/form-data'; + } + } + } + responseContentTypeView = new ResponseContentTypeView({ + model: contentTypeModel + }); + $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el); + _ref6 = this.model.parameters; + for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { + param = _ref6[_j]; + this.addParameter(param, contentTypeModel.consumes); + } + _ref7 = this.model.responseMessages; + for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) { + statusCode = _ref7[_k]; + this.addStatusCode(statusCode); + } + return this; + }; + + OperationView.prototype.addParameter = function(param, consumes) { + var paramView; + param.consumes = consumes; + paramView = new ParameterView({ + model: param, + tagName: 'tr', + readOnly: this.model.isReadOnly + }); + return $('.operation-params', $(this.el)).append(paramView.render().el); + }; + + OperationView.prototype.addStatusCode = function(statusCode) { + var statusCodeView; + statusCodeView = new StatusCodeView({ + model: statusCode, + tagName: 'tr' + }); + return $('.operation-status', $(this.el)).append(statusCodeView.render().el); + }; + + OperationView.prototype.submitOperation = function(e) { + var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7; + if (e != null) { + e.preventDefault(); + } + form = $('.sandbox', $(this.el)); + error_free = true; + form.find("input.required").each(function() { + var _this = this; + $(this).removeClass("error"); + if (jQuery.trim($(this).val()) === "") { + $(this).addClass("error"); + $(this).wiggle({ + callback: function() { + return $(_this).focus(); + } + }); + return error_free = false; + } + }); + if (error_free) { + map = {}; + opts = { + parent: this + }; + isFileUpload = false; + _ref5 = form.find("input"); + for (_i = 0, _len = _ref5.length; _i < _len; _i++) { + o = _ref5[_i]; + if ((o.value != null) && jQuery.trim(o.value).length > 0) { + map[o.name] = o.value; + } + if (o.type === "file") { + isFileUpload = true; + } + } + _ref6 = form.find("textarea"); + for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { + o = _ref6[_j]; + if ((o.value != null) && jQuery.trim(o.value).length > 0) { + map["body"] = o.value; + } + } + _ref7 = form.find("select"); + for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) { + o = _ref7[_k]; + val = this.getSelectedValue(o); + if ((val != null) && jQuery.trim(val).length > 0) { + map[o.name] = val; + } + } + opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val(); + opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val(); + $(".response_throbber", $(this.el)).show(); + if (isFileUpload) { + return this.handleFileUpload(map, form); + } else { + return this.model["do"](map, opts, this.showCompleteStatus, this.showErrorStatus, this); + } + } + }; + + OperationView.prototype.success = function(response, parent) { + return parent.showCompleteStatus(response); + }; + + OperationView.prototype.handleFileUpload = function(map, form) { + var bodyParam, headerParams, o, obj, param, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7, + _this = this; + console.log("it's a file upload"); + _ref5 = form.serializeArray(); + for (_i = 0, _len = _ref5.length; _i < _len; _i++) { + o = _ref5[_i]; + if ((o.value != null) && jQuery.trim(o.value).length > 0) { + map[o.name] = o.value; + } + } + bodyParam = new FormData(); + _ref6 = this.model.parameters; + for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { + param = _ref6[_j]; + if (param.paramType === 'form') { + bodyParam.append(param.name, map[param.name]); + } + } + headerParams = {}; + _ref7 = this.model.parameters; + for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) { + param = _ref7[_k]; + if (param.paramType === 'header') { + headerParams[param.name] = map[param.name]; + } + } + console.log(headerParams); + $.each($('input[type~="file"]'), function(i, el) { + return bodyParam.append($(el).attr('name'), el.files[0]); + }); + console.log(bodyParam); + this.invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true); + $(".request_url", $(this.el)).html("
" + this.invocationUrl + "
"); + obj = { + type: this.model.method, + url: this.invocationUrl, + headers: headerParams, + data: bodyParam, + dataType: 'json', + contentType: false, + processData: false, + error: function(data, textStatus, error) { + return _this.showErrorStatus(_this.wrap(data), _this); + }, + success: function(data) { + return _this.showResponse(data, _this); + }, + complete: function(data) { + return _this.showCompleteStatus(_this.wrap(data), _this); + } + }; + if (window.authorizations) { + window.authorizations.apply(obj); + } + jQuery.ajax(obj); + return false; + }; + + OperationView.prototype.wrap = function(data) { + var o, + _this = this; + o = {}; + o.content = {}; + o.content.data = data.responseText; + o.getHeaders = function() { + return { + "Content-Type": data.getResponseHeader("Content-Type") + }; + }; + o.request = {}; + o.request.url = this.invocationUrl; + o.status = data.status; + return o; + }; + + OperationView.prototype.getSelectedValue = function(select) { + var opt, options, _i, _len, _ref5; + if (!select.multiple) { + return select.value; + } else { + options = []; + _ref5 = select.options; + for (_i = 0, _len = _ref5.length; _i < _len; _i++) { + opt = _ref5[_i]; + if (opt.selected) { + options.push(opt.value); + } + } + if (options.length > 0) { + return options.join(","); + } else { + return null; + } + } + }; + + OperationView.prototype.hideResponse = function(e) { + if (e != null) { + e.preventDefault(); + } + $(".response", $(this.el)).slideUp(); + return $(".response_hider", $(this.el)).fadeOut(); + }; + + OperationView.prototype.showResponse = function(response) { + var prettyJson; + prettyJson = JSON.stringify(response, null, "\t").replace(/\n/g, "
"); + return $(".response_body", $(this.el)).html(escape(prettyJson)); + }; + + OperationView.prototype.showErrorStatus = function(data, parent) { + return parent.showStatus(data); + }; + + OperationView.prototype.showCompleteStatus = function(data, parent) { + return parent.showStatus(data); + }; + + OperationView.prototype.formatXml = function(xml) { + var contexp, formatted, indent, lastType, lines, ln, pad, reg, transitions, wsexp, _fn, _i, _len; + reg = /(>)(<)(\/*)/g; + wsexp = /[ ]*(.*)[ ]+\n/g; + contexp = /(<.+>)(.+\n)/g; + xml = xml.replace(reg, '$1\n$2$3').replace(wsexp, '$1\n').replace(contexp, '$1\n$2'); + pad = 0; + formatted = ''; + lines = xml.split('\n'); + indent = 0; + lastType = 'other'; + transitions = { + 'single->single': 0, + 'single->closing': -1, + 'single->opening': 0, + 'single->other': 0, + 'closing->single': 0, + 'closing->closing': -1, + 'closing->opening': 0, + 'closing->other': 0, + 'opening->single': 1, + 'opening->closing': 0, + 'opening->opening': 1, + 'opening->other': 1, + 'other->single': 0, + 'other->closing': -1, + 'other->opening': 0, + 'other->other': 0 + }; + _fn = function(ln) { + var fromTo, j, key, padding, type, types, value; + types = { + single: Boolean(ln.match(/<.+\/>/)), + closing: Boolean(ln.match(/<\/.+>/)), + opening: Boolean(ln.match(/<[^!?].*>/)) + }; + type = ((function() { + var _results; + _results = []; + for (key in types) { + value = types[key]; + if (value) { + _results.push(key); + } + } + return _results; + })())[0]; + type = type === void 0 ? 'other' : type; + fromTo = lastType + '->' + type; + lastType = type; + padding = ''; + indent += transitions[fromTo]; + padding = ((function() { + var _j, _ref5, _results; + _results = []; + for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) { + _results.push(' '); + } + return _results; + })()).join(''); + if (fromTo === 'opening->closing') { + return formatted = formatted.substr(0, formatted.length - 1) + ln + '\n'; + } else { + return formatted += padding + ln + '\n'; + } + }; + for (_i = 0, _len = lines.length; _i < _len; _i++) { + ln = lines[_i]; + _fn(ln); + } + return formatted; + }; + + OperationView.prototype.showStatus = function(data) { + var code, content, contentType, headers, pre, response_body; + content = data.content.data; + headers = data.getHeaders(); + contentType = headers["Content-Type"]; + if (content === void 0) { + code = $('').text("no content"); + pre = $('
').append(code);
+      } else if (contentType.indexOf("application/json") === 0 || contentType.indexOf("application/hal+json") === 0) {
+        code = $('').text(JSON.stringify(JSON.parse(content), null, 2));
+        pre = $('
').append(code);
+      } else if (contentType.indexOf("application/xml") === 0) {
+        code = $('').text(this.formatXml(content));
+        pre = $('
').append(code);
+      } else if (contentType.indexOf("text/html") === 0) {
+        code = $('').html(content);
+        pre = $('
').append(code);
+      } else if (contentType.indexOf("image/") === 0) {
+        pre = $('').attr('src', data.request.url);
+      } else {
+        code = $('').text(content);
+        pre = $('
').append(code);
+      }
+      response_body = pre;
+      $(".request_url", $(this.el)).html("
" + data.request.url + "
"); + $(".response_code", $(this.el)).html("
" + data.status + "
"); + $(".response_body", $(this.el)).html(response_body); + $(".response_headers", $(this.el)).html("
" + JSON.stringify(data.getHeaders(), null, "  ").replace(/\n/g, "
") + "
"); + $(".response", $(this.el)).slideDown(); + $(".response_hider", $(this.el)).show(); + $(".response_throbber", $(this.el)).hide(); + return hljs.highlightBlock($('.response_body', $(this.el))[0]); + }; + + OperationView.prototype.toggleOperationContent = function() { + var elem; + elem = $('#' + Docs.escapeResourceName(this.model.resourceName) + "_" + this.model.nickname + "_" + this.model.method + "_" + this.model.number + "_content"); + if (elem.is(':visible')) { + return Docs.collapseOperation(elem); + } else { + return Docs.expandOperation(elem); + } + }; + + return OperationView; + + })(Backbone.View); + + StatusCodeView = (function(_super) { + __extends(StatusCodeView, _super); + + function StatusCodeView() { + _ref5 = StatusCodeView.__super__.constructor.apply(this, arguments); + return _ref5; + } + + StatusCodeView.prototype.initialize = function() {}; + + StatusCodeView.prototype.render = function() { + var template; + template = this.template(); + $(this.el).html(template(this.model)); + return this; + }; + + StatusCodeView.prototype.template = function() { + return Handlebars.templates.status_code; + }; + + return StatusCodeView; + + })(Backbone.View); + + ParameterView = (function(_super) { + __extends(ParameterView, _super); + + function ParameterView() { + _ref6 = ParameterView.__super__.constructor.apply(this, arguments); + return _ref6; + } + + ParameterView.prototype.initialize = function() {}; + + ParameterView.prototype.render = function() { + var contentTypeModel, isParam, parameterContentTypeView, responseContentTypeView, signatureModel, signatureView, template, type; + type = this.model.type || this.model.dataType; + if (this.model.paramType === 'body') { + this.model.isBody = true; + } + if (type.toLowerCase() === 'file') { + this.model.isFile = true; + } + template = this.template(); + $(this.el).html(template(this.model)); + signatureModel = { + sampleJSON: this.model.sampleJSON, + isParam: true, + signature: this.model.signature + }; + if (this.model.sampleJSON) { + signatureView = new SignatureView({ + model: signatureModel, + tagName: 'div' + }); + $('.model-signature', $(this.el)).append(signatureView.render().el); + } else { + $('.model-signature', $(this.el)).html(this.model.signature); + } + isParam = false; + if (this.model.isBody) { + isParam = true; + } + contentTypeModel = { + isParam: isParam + }; + contentTypeModel.consumes = this.model.consumes; + if (isParam) { + parameterContentTypeView = new ParameterContentTypeView({ + model: contentTypeModel + }); + $('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el); + } else { + responseContentTypeView = new ResponseContentTypeView({ + model: contentTypeModel + }); + $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el); + } + return this; + }; + + ParameterView.prototype.template = function() { + if (this.model.isList) { + return Handlebars.templates.param_list; + } else { + if (this.options.readOnly) { + if (this.model.required) { + return Handlebars.templates.param_readonly_required; + } else { + return Handlebars.templates.param_readonly; + } + } else { + if (this.model.required) { + return Handlebars.templates.param_required; + } else { + return Handlebars.templates.param; + } + } + } + }; + + return ParameterView; + + })(Backbone.View); + + SignatureView = (function(_super) { + __extends(SignatureView, _super); + + function SignatureView() { + _ref7 = SignatureView.__super__.constructor.apply(this, arguments); + return _ref7; + } + + SignatureView.prototype.events = { + 'click a.description-link': 'switchToDescription', + 'click a.snippet-link': 'switchToSnippet', + 'mousedown .snippet': 'snippetToTextArea' + }; + + SignatureView.prototype.initialize = function() {}; + + SignatureView.prototype.render = function() { + var template; + template = this.template(); + $(this.el).html(template(this.model)); + this.switchToDescription(); + this.isParam = this.model.isParam; + if (this.isParam) { + $('.notice', $(this.el)).text('Click to set as parameter value'); + } + return this; + }; + + SignatureView.prototype.template = function() { + return Handlebars.templates.signature; + }; + + SignatureView.prototype.switchToDescription = function(e) { + if (e != null) { + e.preventDefault(); + } + $(".snippet", $(this.el)).hide(); + $(".description", $(this.el)).show(); + $('.description-link', $(this.el)).addClass('selected'); + return $('.snippet-link', $(this.el)).removeClass('selected'); + }; + + SignatureView.prototype.switchToSnippet = function(e) { + if (e != null) { + e.preventDefault(); + } + $(".description", $(this.el)).hide(); + $(".snippet", $(this.el)).show(); + $('.snippet-link', $(this.el)).addClass('selected'); + return $('.description-link', $(this.el)).removeClass('selected'); + }; + + SignatureView.prototype.snippetToTextArea = function(e) { + var textArea; + if (this.isParam) { + if (e != null) { + e.preventDefault(); + } + textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode)); + if ($.trim(textArea.val()) === '') { + return textArea.val(this.model.sampleJSON); + } + } + }; + + return SignatureView; + + })(Backbone.View); + + ContentTypeView = (function(_super) { + __extends(ContentTypeView, _super); + + function ContentTypeView() { + _ref8 = ContentTypeView.__super__.constructor.apply(this, arguments); + return _ref8; + } + + ContentTypeView.prototype.initialize = function() {}; + + ContentTypeView.prototype.render = function() { + var template; + template = this.template(); + $(this.el).html(template(this.model)); + $('label[for=contentType]', $(this.el)).text('Response Content Type'); + return this; + }; + + ContentTypeView.prototype.template = function() { + return Handlebars.templates.content_type; + }; + + return ContentTypeView; + + })(Backbone.View); + + ResponseContentTypeView = (function(_super) { + __extends(ResponseContentTypeView, _super); + + function ResponseContentTypeView() { + _ref9 = ResponseContentTypeView.__super__.constructor.apply(this, arguments); + return _ref9; + } + + ResponseContentTypeView.prototype.initialize = function() {}; + + ResponseContentTypeView.prototype.render = function() { + var template; + template = this.template(); + $(this.el).html(template(this.model)); + $('label[for=responseContentType]', $(this.el)).text('Response Content Type'); + return this; + }; + + ResponseContentTypeView.prototype.template = function() { + return Handlebars.templates.response_content_type; + }; + + return ResponseContentTypeView; + + })(Backbone.View); + + ParameterContentTypeView = (function(_super) { + __extends(ParameterContentTypeView, _super); + + function ParameterContentTypeView() { + _ref10 = ParameterContentTypeView.__super__.constructor.apply(this, arguments); + return _ref10; + } + + ParameterContentTypeView.prototype.initialize = function() {}; + + ParameterContentTypeView.prototype.render = function() { + var template; + template = this.template(); + $(this.el).html(template(this.model)); + $('label[for=parameterContentType]', $(this.el)).text('Parameter content type:'); + return this; + }; + + ParameterContentTypeView.prototype.template = function() { + return Handlebars.templates.parameter_content_type; + }; + + return ParameterContentTypeView; + + })(Backbone.View); + +}).call(this); diff --git a/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/swagger.js b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/swagger.js new file mode 100644 index 0000000000..a03779011b --- /dev/null +++ b/opendaylight/md-sal/sal-rest-docgen/src/main/resources/explorer/static/swagger.js @@ -0,0 +1,1199 @@ +// Generated by CoffeeScript 1.6.3 +(function() { + var ApiKeyAuthorization, PasswordAuthorization, SwaggerApi, SwaggerAuthorizations, SwaggerHttp, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource, + __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; + + SwaggerApi = (function() { + SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json"; + + SwaggerApi.prototype.debug = false; + + SwaggerApi.prototype.basePath = null; + + SwaggerApi.prototype.authorizations = null; + + SwaggerApi.prototype.authorizationScheme = null; + + SwaggerApi.prototype.info = null; + + function SwaggerApi(url, options) { + if (options == null) { + options = {}; + } + if (url) { + if (url.url) { + options = url; + } else { + this.url = url; + } + } else { + options = url; + } + if (options.url != null) { + this.url = options.url; + } + if (options.success != null) { + this.success = options.success; + } + this.failure = options.failure != null ? options.failure : function() {}; + this.progress = options.progress != null ? options.progress : function() {}; + if (options.success != null) { + this.build(); + } + } + + SwaggerApi.prototype.build = function() { + var e, obj, + _this = this; + this.progress('fetching resource list: ' + this.url); + var response; + response = JSON.parse(getSpec()); + + _this.swaggerVersion = response.swaggerVersion; + if (_this.swaggerVersion === "1.2") { + setTimeout(function(){return _this.buildFromSpec(response);}, 500); + } else { + return setTimeout(function(){return _this.buildFrom1_1Spec(response);}, 500); + } + return this; + }; + + SwaggerApi.prototype.buildFromSpec = function(response) { + var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2; + if (response.apiVersion != null) { + this.apiVersion = response.apiVersion; + } + this.apis = {}; + this.apisArray = []; + this.produces = response.produces; + this.authSchemes = response.authorizations; + if (response.info != null) { + this.info = response.info; + } + isApi = false; + _ref = response.apis; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + api = _ref[_i]; + if (api.operations) { + _ref1 = api.operations; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + operation = _ref1[_j]; + isApi = true; + } + } + } + if (response.basePath) { + this.basePath = response.basePath; + } else if (this.url.indexOf('?') > 0) { + this.basePath = this.url.substring(0, this.url.lastIndexOf('?')); + } else { + this.basePath = this.url; + } + if (isApi) { + newName = response.resourcePath.replace(/\//g, ''); + this.resourcePath = response.resourcePath; + res = new SwaggerResource(response, this); + this.apis[newName] = res; + this.apisArray.push(res); + } else { + _ref2 = response.apis; + for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { + resource = _ref2[_k]; + res = new SwaggerResource(resource, this); + this.apis[res.name] = res; + this.apisArray.push(res); + } + } + if (this.success) { + this.success(); + } + return this; + }; + + SwaggerApi.prototype.buildFrom1_1Spec = function(response) { + var api, isApi, newName, operation, res, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2; + console.log("This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info"); + if (response.apiVersion != null) { + this.apiVersion = response.apiVersion; + } + this.apis = {}; + this.apisArray = []; + this.produces = response.produces; + if (response.info != null) { + this.info = response.info; + } + isApi = false; + _ref = response.apis; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + api = _ref[_i]; + if (api.operations) { + _ref1 = api.operations; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + operation = _ref1[_j]; + isApi = true; + } + } + } + if (response.basePath) { + this.basePath = response.basePath; + } else if (this.url.indexOf('?') > 0) { + this.basePath = this.url.substring(0, this.url.lastIndexOf('?')); + } else { + this.basePath = this.url; + } + if (isApi) { + newName = response.resourcePath.replace(/\//g, ''); + this.resourcePath = response.resourcePath; + res = new SwaggerResource(response, this); + this.apis[newName] = res; + this.apisArray.push(res); + } else { + _ref2 = response.apis; + for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { + resource = _ref2[_k]; + res = new SwaggerResource(resource, this); + this.apis[res.name] = res; + this.apisArray.push(res); + } + } + if (this.success) { + this.success(); + } + return this; + }; + + SwaggerApi.prototype.selfReflect = function() { + var resource, resource_name, _ref; + if (this.apis == null) { + return false; + } + _ref = this.apis; + for (resource_name in _ref) { + resource = _ref[resource_name]; + if (resource.ready == null) { + return false; + } + } + this.setConsolidatedModels(); + this.ready = true; + if (this.success != null) { + return this.success(); + } + }; + + SwaggerApi.prototype.fail = function(message) { + this.failure(message); + throw message; + }; + + SwaggerApi.prototype.setConsolidatedModels = function() { + var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results; + this.modelsArray = []; + this.models = {}; + _ref = this.apis; + for (resource_name in _ref) { + resource = _ref[resource_name]; + for (modelName in resource.models) { + if (this.models[modelName] == null) { + this.models[modelName] = resource.models[modelName]; + this.modelsArray.push(resource.models[modelName]); + } + } + } + _ref1 = this.modelsArray; + _results = []; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + model = _ref1[_i]; + _results.push(model.setReferencedModels(this.models)); + } + return _results; + }; + + SwaggerApi.prototype.help = function() { + var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2; + _ref = this.apis; + for (resource_name in _ref) { + resource = _ref[resource_name]; + console.log(resource_name); + _ref1 = resource.operations; + for (operation_name in _ref1) { + operation = _ref1[operation_name]; + console.log(" " + operation.nickname); + _ref2 = operation.parameters; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + parameter = _ref2[_i]; + console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description); + } + } + } + return this; + }; + + return SwaggerApi; + + })(); + + SwaggerResource = (function() { + SwaggerResource.prototype.api = null; + + SwaggerResource.prototype.produces = null; + + SwaggerResource.prototype.consumes = null; + + function SwaggerResource(resourceObj, api) { + var consumes, e, obj, parts, produces, + _this = this; + this.api = api; + this.api = this.api; + produces = []; + consumes = []; + this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path; + this.description = resourceObj.description; + parts = this.path.split("/"); + this.name = parts[parts.length - 1].replace('.{format}', ''); + this.basePath = this.api.basePath; + this.operations = {}; + this.operationsArray = []; + this.modelsArray = []; + this.models = {}; + if ((resourceObj.apis != null) && (this.api.resourcePath != null)) { + this.addApiDeclaration(resourceObj); + } else { + if (this.path == null) { + this.api.fail("SwaggerResources must have a path."); + } + if (this.path.substring(0, 4) === 'http') { + this.url = this.path.replace('{format}', 'json'); + } else { + this.url = this.api.basePath + this.path.replace('{format}', 'json'); + } + this.api.progress('fetching resource ' + this.name + ': ' + this.url); + var response; + var split = resourceObj.path.split("/"); + var resource = split[split.length-1]; + response = JSON.parse(jsonFor(resource)); + setTimeout(function(){return _this.addApiDeclaration(response);}, 500); + } + } + + SwaggerResource.prototype.addApiDeclaration = function(response) { + var endpoint, _i, _len, _ref; + if (response.produces != null) { + this.produces = response.produces; + } + if (response.consumes != null) { + this.consumes = response.consumes; + } + if ((response.basePath != null) && response.basePath.replace(/\s/g, '').length > 0) { + this.basePath = response.basePath; + } + this.addModels(response.models); + if (response.apis) { + _ref = response.apis; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + endpoint = _ref[_i]; + this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces); + } + } + this.api[this.name] = this; + this.ready = true; + return this.api.selfReflect(); + }; + + SwaggerResource.prototype.addModels = function(models) { + var model, modelName, swaggerModel, _i, _len, _ref, _results; + if (models != null) { + for (modelName in models) { + if (this.models[modelName] == null) { + swaggerModel = new SwaggerModel(modelName, models[modelName]); + this.modelsArray.push(swaggerModel); + this.models[modelName] = swaggerModel; + } + } + _ref = this.modelsArray; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + model = _ref[_i]; + _results.push(model.setReferencedModels(this.models)); + } + return _results; + } + }; + + SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, produces) { + var method, o, op, r, ref, responseMessages, type, _i, _j, _len, _len1, _results; + if (ops) { + _results = []; + for (_i = 0, _len = ops.length; _i < _len; _i++) { + o = ops[_i]; + consumes = this.consumes; + produces = this.produces; + if (o.consumes != null) { + consumes = o.consumes; + } else { + consumes = this.consumes; + } + if (o.produces != null) { + produces = o.produces; + } else { + produces = this.produces; + } + type = o.type || o.responseClass; + if (type === "array") { + ref = null; + if (o.items) { + ref = o.items["type"] || o.items["$ref"]; + } + type = "array[" + ref + "]"; + } + responseMessages = o.responseMessages; + method = o.method; + if (o.httpMethod) { + method = o.httpMethod; + } + if (o.supportedContentTypes) { + consumes = o.supportedContentTypes; + } + if (o.errorResponses) { + responseMessages = o.errorResponses; + for (_j = 0, _len1 = responseMessages.length; _j < _len1; _j++) { + r = responseMessages[_j]; + r.message = r.reason; + r.reason = null; + } + } + o.nickname = this.sanitize(o.nickname); + op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces); + this.operations[op.nickname] = op; + _results.push(this.operationsArray.push(op)); + } + return _results; + } + }; + + SwaggerResource.prototype.sanitize = function(nickname) { + var op; + op = nickname.replace(/[\s!@#$%^&*()_+=\[{\]};:<>|./?,\\'""-]/g, '_'); + op = op.replace(/((_){2,})/g, '_'); + op = op.replace(/^(_)*/g, ''); + op = op.replace(/([_])*$/g, ''); + return op; + }; + + SwaggerResource.prototype.help = function() { + var msg, operation, operation_name, parameter, _i, _len, _ref, _ref1, _results; + _ref = this.operations; + _results = []; + for (operation_name in _ref) { + operation = _ref[operation_name]; + msg = " " + operation.nickname; + _ref1 = operation.parameters; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + parameter = _ref1[_i]; + msg.concat(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description); + } + _results.push(msg); + } + return _results; + }; + + return SwaggerResource; + + })(); + + SwaggerModel = (function() { + function SwaggerModel(modelName, obj) { + var prop, propertyName, value; + this.name = obj.id != null ? obj.id : modelName; + this.properties = []; + for (propertyName in obj.properties) { + if (obj.required != null) { + for (value in obj.required) { + if (propertyName === obj.required[value]) { + obj.properties[propertyName].required = true; + } + } + } + prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]); + this.properties.push(prop); + } + } + + SwaggerModel.prototype.setReferencedModels = function(allModels) { + var prop, type, _i, _len, _ref, _results; + _ref = this.properties; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + prop = _ref[_i]; + type = prop.type || prop.dataType; + if (allModels[type] != null) { + _results.push(prop.refModel = allModels[type]); + } else if ((prop.refDataType != null) && (allModels[prop.refDataType] != null)) { + _results.push(prop.refModel = allModels[prop.refDataType]); + } else { + _results.push(void 0); + } + } + return _results; + }; + + SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) { + var classClose, classOpen, prop, propertiesStr, returnVal, strong, strongClose, stronger, _i, _j, _len, _len1, _ref, _ref1; + propertiesStr = []; + _ref = this.properties; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + prop = _ref[_i]; + propertiesStr.push(prop.toString()); + } + strong = ''; + stronger = ''; + strongClose = ''; + classOpen = strong + this.name + ' {' + strongClose; + classClose = strong + '}' + strongClose; + returnVal = classOpen + '
' + propertiesStr.join(',
') + '
' + classClose; + if (!modelsToIgnore) { + modelsToIgnore = []; + } + modelsToIgnore.push(this); + _ref1 = this.properties; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + prop = _ref1[_j]; + if ((prop.refModel != null) && (modelsToIgnore.indexOf(prop.refModel)) === -1) { + returnVal = returnVal + ('
' + prop.refModel.getMockSignature(modelsToIgnore)); + } + } + return returnVal; + }; + + SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) { + var prop, result, _i, _len, _ref; + result = {}; + modelsToIgnore = modelsToIgnore || []; + modelsToIgnore.push(this.name); + _ref = this.properties; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + prop = _ref[_i]; + result[prop.name] = prop.getSampleValue(modelsToIgnore); + } + modelsToIgnore.pop(this.name); + return result; + }; + + return SwaggerModel; + + })(); + + SwaggerModelProperty = (function() { + function SwaggerModelProperty(name, obj) { + this.name = name; + this.dataType = obj.type || obj.dataType || obj["$ref"]; + this.isCollection = this.dataType && (this.dataType.toLowerCase() === 'array' || this.dataType.toLowerCase() === 'list' || this.dataType.toLowerCase() === 'set'); + this.descr = obj.description; + this.required = obj.required; + if (obj.items != null) { + if (obj.items.type != null) { + this.refDataType = obj.items.type; + } + if (obj.items.$ref != null) { + this.refDataType = obj.items.$ref; + } + } + this.dataTypeWithRef = this.refDataType != null ? this.dataType + '[' + this.refDataType + ']' : this.dataType; + if (obj.allowableValues != null) { + this.valueType = obj.allowableValues.valueType; + this.values = obj.allowableValues.values; + if (this.values != null) { + this.valuesString = "'" + this.values.join("' or '") + "'"; + } + } + if (obj["enum"] != null) { + this.valueType = "string"; + this.values = obj["enum"]; + if (this.values != null) { + this.valueString = "'" + this.values.join("' or '") + "'"; + } + } + } + + SwaggerModelProperty.prototype.getSampleValue = function(modelsToIgnore) { + var result; + if ((this.refModel != null) && (modelsToIgnore.indexOf(this.refModel.name) === -1)) { + result = this.refModel.createJSONSample(modelsToIgnore); + } else { + if (this.isCollection) { + result = this.refDataType; + } else { + result = this.dataType; + } + } + if (this.isCollection) { + return [result]; + } else { + return result; + } + }; + + SwaggerModelProperty.prototype.toString = function() { + var req, str; + req = this.required ? 'propReq' : 'propOpt'; + str = '' + this.name + ' (' + this.dataTypeWithRef + ''; + if (!this.required) { + str += ', optional'; + } + str += ')'; + if (this.values != null) { + str += " = ['" + this.values.join("' or '") + "']"; + } + if (this.descr != null) { + str += ': ' + this.descr + ''; + } + return str; + }; + + return SwaggerModelProperty; + + })(); + + SwaggerOperation = (function() { + function SwaggerOperation(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces) { + var parameter, v, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _ref3, + _this = this; + this.nickname = nickname; + this.path = path; + this.method = method; + this.parameters = parameters != null ? parameters : []; + this.summary = summary; + this.notes = notes; + this.type = type; + this.responseMessages = responseMessages; + this.resource = resource; + this.consumes = consumes; + this.produces = produces; + this["do"] = __bind(this["do"], this); + if (this.nickname == null) { + this.resource.api.fail("SwaggerOperations must have a nickname."); + } + if (this.path == null) { + this.resource.api.fail("SwaggerOperation " + nickname + " is missing path."); + } + if (this.method == null) { + this.resource.api.fail("SwaggerOperation " + nickname + " is missing method."); + } + this.path = this.path.replace('{format}', 'json'); + this.method = this.method.toLowerCase(); + this.isGetMethod = this.method === "get"; + this.resourceName = this.resource.name; + if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') { + this.type = void 0; + } + if (this.type != null) { + this.responseClassSignature = this.getSignature(this.type, this.resource.models); + this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models); + } + this.responseMessages = this.responseMessages || []; + _ref1 = this.parameters; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + parameter = _ref1[_i]; + parameter.name = parameter.name || parameter.type || parameter.dataType; + type = parameter.type || parameter.dataType; + if (type.toLowerCase() === 'boolean') { + parameter.allowableValues = {}; + parameter.allowableValues.values = ["true", "false"]; + } + parameter.signature = this.getSignature(type, this.resource.models); + parameter.sampleJSON = this.getSampleJSON(type, this.resource.models); + if (parameter["enum"] != null) { + parameter.isList = true; + parameter.allowableValues = {}; + parameter.allowableValues.descriptiveValues = []; + _ref2 = parameter["enum"]; + for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) { + v = _ref2[_j]; + if ((parameter.defaultValue != null) && parameter.defaultValue === v) { + parameter.allowableValues.descriptiveValues.push({ + value: v, + isDefault: true + }); + } else { + parameter.allowableValues.descriptiveValues.push({ + value: v, + isDefault: false + }); + } + } + } + if (parameter.allowableValues != null) { + if (parameter.allowableValues.valueType === "RANGE") { + parameter.isRange = true; + } else { + parameter.isList = true; + } + if (parameter.allowableValues.values != null) { + parameter.allowableValues.descriptiveValues = []; + _ref3 = parameter.allowableValues.values; + for (_k = 0, _len2 = _ref3.length; _k < _len2; _k++) { + v = _ref3[_k]; + if ((parameter.defaultValue != null) && parameter.defaultValue === v) { + parameter.allowableValues.descriptiveValues.push({ + value: v, + isDefault: true + }); + } else { + parameter.allowableValues.descriptiveValues.push({ + value: v, + isDefault: false + }); + } + } + } + } + } + this.resource[this.nickname] = function(args, callback, error) { + return _this["do"](args, callback, error); + }; + this.resource[this.nickname].help = function() { + return _this.help(); + }; + } + + SwaggerOperation.prototype.isListType = function(type) { + if (type.indexOf('[') >= 0) { + return type.substring(type.indexOf('[') + 1, type.indexOf(']')); + } else { + return void 0; + } + }; + + SwaggerOperation.prototype.getSignature = function(type, models) { + var isPrimitive, listType; + listType = this.isListType(type); + isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true; + if (isPrimitive) { + return type; + } else { + if (listType != null) { + return models[listType].getMockSignature(); + } else { + return models[type].getMockSignature(); + } + } + }; + + SwaggerOperation.prototype.getSampleJSON = function(type, models) { + var isPrimitive, listType, val; + listType = this.isListType(type); + isPrimitive = ((listType != null) && models[listType]) || (models[type] != null) ? false : true; + val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[type].createJSONSample()); + if (val) { + val = listType ? [val] : val; + return JSON.stringify(val, null, 2); + } + }; + + SwaggerOperation.prototype["do"] = function(args, opts, callback, error) { + var key, param, params, possibleParams, req, requestContentType, responseContentType, value, _i, _len, _ref; + if (args == null) { + args = {}; + } + if (opts == null) { + opts = {}; + } + requestContentType = null; + responseContentType = null; + if ((typeof args) === "function") { + error = opts; + callback = args; + args = {}; + } + if ((typeof opts) === "function") { + error = callback; + callback = opts; + } + if (error == null) { + error = function(xhr, textStatus, error) { + return console.log(xhr, textStatus, error); + }; + } + if (callback == null) { + callback = function(data) { + var content; + content = null; + if (data.content != null) { + content = data.content.data; + } else { + content = "no data"; + } + return console.log("default callback: " + content); + }; + } + params = {}; + params.headers = []; + if (args.headers != null) { + params.headers = args.headers; + delete args.headers; + } + _ref = this.parameters; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + param = _ref[_i]; + if (param.paramType === "header") { + if (args[param.name]) { + params.headers[param.name] = args[param.name]; + } + } + } + if (args.body != null) { + params.body = args.body; + delete args.body; + } + possibleParams = (function() { + var _j, _len1, _ref1, _results; + _ref1 = this.parameters; + _results = []; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + param = _ref1[_j]; + if (param.paramType === "form" || param.paramType.toLowerCase() === "file") { + _results.push(param); + } + } + return _results; + }).call(this); + if (possibleParams) { + for (key in possibleParams) { + value = possibleParams[key]; + if (args[value.name]) { + params[value.name] = args[value.name]; + } + } + } + req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this); + if (opts.mock != null) { + return req; + } else { + return true; + } + }; + + SwaggerOperation.prototype.pathJson = function() { + return this.path.replace("{format}", "json"); + }; + + SwaggerOperation.prototype.pathXml = function() { + return this.path.replace("{format}", "xml"); + }; + + SwaggerOperation.prototype.urlify = function(args) { + var param, queryParams, reg, url, _i, _j, _len, _len1, _ref, _ref1; + url = this.resource.basePath + this.pathJson(); + _ref = this.parameters; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + param = _ref[_i]; + if (param.paramType === 'path') { + if (args[param.name]) { + reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi'); + url = url.replace(reg, encodeURIComponent(args[param.name])); + delete args[param.name]; + } else { + throw "" + param.name + " is a required path param."; + } + } + } + queryParams = ""; + _ref1 = this.parameters; + for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { + param = _ref1[_j]; + if (param.paramType === 'query') { + if (args[param.name]) { + if (queryParams !== "") { + queryParams += "&"; + } + queryParams += encodeURIComponent(param.name) + '=' + encodeURIComponent(args[param.name]); + } + } + } + if ((queryParams != null) && queryParams.length > 0) { + url += "?" + queryParams; + } + return url; + }; + + SwaggerOperation.prototype.supportHeaderParams = function() { + return this.resource.api.supportHeaderParams; + }; + + SwaggerOperation.prototype.supportedSubmitMethods = function() { + return this.resource.api.supportedSubmitMethods; + }; + + SwaggerOperation.prototype.getQueryParams = function(args) { + return this.getMatchingParams(['query'], args); + }; + + SwaggerOperation.prototype.getHeaderParams = function(args) { + return this.getMatchingParams(['header'], args); + }; + + SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args) { + var matchingParams, name, param, value, _i, _len, _ref, _ref1; + matchingParams = {}; + _ref = this.parameters; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + param = _ref[_i]; + if (args && args[param.name]) { + matchingParams[param.name] = args[param.name]; + } + } + _ref1 = this.resource.api.headers; + for (name in _ref1) { + value = _ref1[name]; + matchingParams[name] = value; + } + return matchingParams; + }; + + SwaggerOperation.prototype.help = function() { + var msg, parameter, _i, _len, _ref; + msg = ""; + _ref = this.parameters; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + parameter = _ref[_i]; + if (msg !== "") { + msg += "\n"; + } + msg += "* " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description; + } + return msg; + }; + + return SwaggerOperation; + + })(); + + SwaggerRequest = (function() { + function SwaggerRequest(type, url, params, opts, successCallback, errorCallback, operation, execution) { + var body, e, fields, headers, key, myHeaders, name, obj, param, parent, possibleParams, requestContentType, responseContentType, urlEncoded, value, values, + _this = this; + this.type = type; + this.url = url; + this.params = params; + this.opts = opts; + this.successCallback = successCallback; + this.errorCallback = errorCallback; + this.operation = operation; + this.execution = execution; + if (this.type == null) { + throw "SwaggerRequest type is required (get/post/put/delete)."; + } + if (this.url == null) { + throw "SwaggerRequest url is required."; + } + if (this.successCallback == null) { + throw "SwaggerRequest successCallback is required."; + } + if (this.errorCallback == null) { + throw "SwaggerRequest error callback is required."; + } + if (this.operation == null) { + throw "SwaggerRequest operation is required."; + } + this.type = this.type.toUpperCase(); + headers = params.headers; + myHeaders = {}; + body = params.body; + parent = params["parent"]; + requestContentType = "application/json"; + if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH")) { + if (this.opts.requestContentType) { + requestContentType = this.opts.requestContentType; + } + } else { + if (((function() { + var _i, _len, _ref, _results; + _ref = this.operation.parameters; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + param = _ref[_i]; + if (param.paramType === "form") { + _results.push(param); + } + } + return _results; + }).call(this)).length > 0) { + type = param.type || param.dataType; + if (((function() { + var _i, _len, _ref, _results; + _ref = this.operation.parameters; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + param = _ref[_i]; + if (type.toLowerCase() === "file") { + _results.push(param); + } + } + return _results; + }).call(this)).length > 0) { + requestContentType = "multipart/form-data"; + } else { + requestContentType = "application/x-www-form-urlencoded"; + } + } else if (this.type !== "DELETE") { + requestContentType = null; + } + } + if (requestContentType && this.operation.consumes) { + if (this.operation.consumes.indexOf(requestContentType) === -1) { + console.log("server doesn't consume " + requestContentType + ", try " + JSON.stringify(this.operation.consumes)); + if (this.requestContentType === null) { + requestContentType = this.operation.consumes[0]; + } + } + } + responseContentType = null; + if (this.type === "POST" || this.type === "GET" || this.type === "PATCH") { + if (this.opts.responseContentType) { + responseContentType = this.opts.responseContentType; + } else { + responseContentType = "application/json"; + } + } else { + responseContentType = null; + } + if (responseContentType && this.operation.produces) { + if (this.operation.produces.indexOf(responseContentType) === -1) { + console.log("server can't produce " + responseContentType); + } + } + if (requestContentType && requestContentType.indexOf("application/x-www-form-urlencoded") === 0) { + fields = {}; + possibleParams = (function() { + var _i, _len, _ref, _results; + _ref = this.operation.parameters; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + param = _ref[_i]; + if (param.paramType === "form") { + _results.push(param); + } + } + return _results; + }).call(this); + values = {}; + for (key in possibleParams) { + value = possibleParams[key]; + if (this.params[value.name]) { + values[value.name] = this.params[value.name]; + } + } + urlEncoded = ""; + for (key in values) { + value = values[key]; + if (urlEncoded !== "") { + urlEncoded += "&"; + } + urlEncoded += encodeURIComponent(key) + '=' + encodeURIComponent(value); + } + body = urlEncoded; + } + for (name in headers) { + myHeaders[name] = headers[name]; + } + if (requestContentType) { + myHeaders["Content-Type"] = requestContentType; + } + if (responseContentType) { + myHeaders["Accept"] = responseContentType; + } + if (!((headers != null) && (headers.mock != null))) { + obj = { + url: this.url, + method: this.type, + headers: myHeaders, + body: body, + on: { + error: function(response) { + return _this.errorCallback(response, _this.opts.parent); + }, + redirect: function(response) { + return _this.successCallback(response, _this.opts.parent); + }, + 307: function(response) { + return _this.successCallback(response, _this.opts.parent); + }, + response: function(response) { + return _this.successCallback(response, _this.opts.parent); + } + } + }; + e = {}; + if (typeof window !== 'undefined') { + e = window; + } else { + e = exports; + } + e.authorizations.apply(obj); + if (opts.mock == null) { + new SwaggerHttp().execute(obj); + } else { + console.log(obj); + return obj; + } + } + } + + SwaggerRequest.prototype.asCurl = function() { + var header_args, k, v; + header_args = (function() { + var _ref, _results; + _ref = this.headers; + _results = []; + for (k in _ref) { + v = _ref[k]; + _results.push("--header \"" + k + ": " + v + "\""); + } + return _results; + }).call(this); + return "curl " + (header_args.join(" ")) + " " + this.url; + }; + + return SwaggerRequest; + + })(); + + SwaggerHttp = (function() { + SwaggerHttp.prototype.Shred = null; + + SwaggerHttp.prototype.shred = null; + + SwaggerHttp.prototype.content = null; + + function SwaggerHttp() { + var identity, toString, + _this = this; + if (typeof window !== 'undefined') { + this.Shred = require("./shred"); + } else { + this.Shred = require("shred"); + } + this.shred = new this.Shred(); + identity = function(x) { + return x; + }; + toString = function(x) { + return x.toString(); + }; + if (typeof window !== 'undefined') { + this.content = require("./shred/content"); + this.content.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { + parser: identity, + stringify: toString + }); + } else { + this.Shred.registerProcessor(["application/json; charset=utf-8", "application/json", "json"], { + parser: identity, + stringify: toString + }); + } + } + + SwaggerHttp.prototype.execute = function(obj) { + return this.shred.request(obj); + }; + + return SwaggerHttp; + + })(); + + SwaggerAuthorizations = (function() { + SwaggerAuthorizations.prototype.authz = null; + + function SwaggerAuthorizations() { + this.authz = {}; + } + + SwaggerAuthorizations.prototype.add = function(name, auth) { + this.authz[name] = auth; + return auth; + }; + + SwaggerAuthorizations.prototype.apply = function(obj) { + var key, value, _ref, _results; + _ref = this.authz; + _results = []; + for (key in _ref) { + value = _ref[key]; + _results.push(value.apply(obj)); + } + return _results; + }; + + return SwaggerAuthorizations; + + })(); + + ApiKeyAuthorization = (function() { + ApiKeyAuthorization.prototype.type = null; + + ApiKeyAuthorization.prototype.name = null; + + ApiKeyAuthorization.prototype.value = null; + + function ApiKeyAuthorization(name, value, type) { + this.name = name; + this.value = value; + this.type = type; + } + + ApiKeyAuthorization.prototype.apply = function(obj) { + if (this.type === "query") { + if (obj.url.indexOf('?') > 0) { + obj.url = obj.url + "&" + this.name + "=" + this.value; + } else { + obj.url = obj.url + "?" + this.name + "=" + this.value; + } + return true; + } else if (this.type === "header") { + return obj.headers[this.name] = this.value; + } + }; + + return ApiKeyAuthorization; + + })(); + + PasswordAuthorization = (function() { + PasswordAuthorization.prototype.name = null; + + PasswordAuthorization.prototype.username = null; + + PasswordAuthorization.prototype.password = null; + + function PasswordAuthorization(name, username, password) { + this.name = name; + this.username = username; + this.password = password; + } + + PasswordAuthorization.prototype.apply = function(obj) { + return obj.headers["Authorization"] = "Basic " + btoa(this.username + ":" + this.password); + }; + + return PasswordAuthorization; + + })(); + + this.SwaggerApi = SwaggerApi; + + this.SwaggerResource = SwaggerResource; + + this.SwaggerOperation = SwaggerOperation; + + this.SwaggerRequest = SwaggerRequest; + + this.SwaggerModelProperty = SwaggerModelProperty; + + this.ApiKeyAuthorization = ApiKeyAuthorization; + + this.PasswordAuthorization = PasswordAuthorization; + + this.authorizations = new SwaggerAuthorizations(); + +}).call(this);