diff --git a/tastypie_swagger/mapping.py b/tastypie_swagger/mapping.py index 1eea5b7..d56c35b 100644 --- a/tastypie_swagger/mapping.py +++ b/tastypie_swagger/mapping.py @@ -280,7 +280,7 @@ def build_parameters_from_extra_action(self, method, fields, resource_type): description='Primary key of resource')) for name, field in fields.items(): parameters.append(self.build_parameter( - paramType="query", + paramType=field.get("param_type", "query"), name=name, dataType=field.get("type", "string"), required=field.get("required", True), @@ -346,6 +346,7 @@ def build_extra_operation(self, extra_action): resource_type=extra_action.get("resource_type", "view")), 'responseClass': 'Object', #TODO this should be extended to allow the creation of a custom object. 'nickname': extra_action['name'], + 'notes': extra_action.get('notes', ''), } def build_detail_api(self): @@ -421,8 +422,10 @@ def build_property(self, name, type, description=""): def build_properties_from_fields(self, method='get'): properties = {} - + excludes = getattr(self.resource._meta, 'excludes', []) for name, field in self.schema['fields'].items(): + if name in excludes: + continue # Exclude fields from custom put / post object definition if method in ['post','put']: if name in self.WRITE_ACTION_IGNORED_FIELDS: diff --git a/tastypie_swagger/static/tastypie_swagger/css/hightlight.default.css b/tastypie_swagger/static/tastypie_swagger/css/highlight.default.css old mode 100644 new mode 100755 similarity index 100% rename from tastypie_swagger/static/tastypie_swagger/css/hightlight.default.css rename to tastypie_swagger/static/tastypie_swagger/css/highlight.default.css diff --git a/tastypie_swagger/static/tastypie_swagger/css/screen.css b/tastypie_swagger/static/tastypie_swagger/css/screen.css old mode 100644 new mode 100755 index d652574..1627ecd --- a/tastypie_swagger/static/tastypie_swagger/css/screen.css +++ b/tastypie_swagger/static/tastypie_swagger/css/screen.css @@ -1,1590 +1,1070 @@ -html, body, div, span, applet, object, iframe, -h1, h2, h3, h4, h5, h6, p, blockquote, pre, -a, abbr, acronym, address, big, cite, code, -del, dfn, em, img, ins, kbd, q, s, samp, -small, strike, strong, sub, sup, tt, var, -b, u, i, center, -dl, dt, dd, ol, ul, li, -fieldset, form, label, legend, -table, caption, tbody, tfoot, thead, tr, th, td, -article, aside, canvas, details, embed, -figure, figcaption, footer, header, hgroup, -menu, nav, output, ruby, section, summary, -time, mark, audio, video { - margin: 0; - padding: 0; - border: 0; - font-size: 100%; - font: inherit; - vertical-align: baseline; -} - +/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */ +html, +body, +div, +span, +applet, +object, +iframe, +h1, +h2, +h3, +h4, +h5, +h6, +p, +blockquote, +pre, +a, +abbr, +acronym, +address, +big, +cite, +code, +del, +dfn, +em, +img, +ins, +kbd, +q, +s, +samp, +small, +strike, +strong, +sub, +sup, +tt, +var, +b, +u, +i, +center, +dl, +dt, +dd, +ol, +ul, +li, +fieldset, +form, +label, +legend, +table, +caption, +tbody, +tfoot, +thead, +tr, +th, +td, +article, +aside, +canvas, +details, +embed, +figure, +figcaption, +footer, +header, +hgroup, +menu, +nav, +output, +ruby, +section, +summary, +time, +mark, +audio, +video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +menu, +nav, +section { + display: block; +} body { - line-height: 1; + line-height: 1; } - -ol, ul { - list-style: none; +ol, +ul { + list-style: none; +} +blockquote, +q { + quotes: none; +} +blockquote:before, +blockquote:after, +q:before, +q:after { + content: ''; + content: none; } - table { - border-collapse: collapse; - border-spacing: 0; -} - -caption, th, td { - text-align: left; - font-weight: normal; - vertical-align: middle; -} - -q, blockquote { - quotes: none; -} - -q:before, q:after, blockquote:before, blockquote:after { - content: ""; - content: none; -} - -a img { - border: none; -} - -article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary { - display: block; -} - -h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { - text-decoration: none; -} - -h1 a:hover, h2 a:hover, h3 a:hover, h4 a:hover, h5 a:hover, h6 a:hover { - text-decoration: underline; -} - -h1 span.divider, h2 span.divider, h3 span.divider, h4 span.divider, h5 span.divider, h6 span.divider { - color: #aaaaaa; -} - -h1 { - color: #547f00; - color: black; - font-size: 1.5em; - line-height: 1.3em; - padding: 10px 0 10px 0; - font-family: "Droid Sans", sans-serif; - font-weight: bold; -} - -h2 { - color: #89bf04; - color: black; - font-size: 1.3em; - padding: 10px 0 10px 0; -} - -h2 a { - color: black; -} - -h2 span.sub { - font-size: 0.7em; - color: #999999; - font-style: italic; -} - -h2 span.sub a { - color: #777777; -} - -h3 { - color: black; - font-size: 1.1em; - padding: 10px 0 10px 0; -} - -div.heading_with_menu { - float: none; - clear: both; - overflow: hidden; - display: block; -} - -div.heading_with_menu h1, div.heading_with_menu h2, div.heading_with_menu h3, div.heading_with_menu h4, div.heading_with_menu h5, div.heading_with_menu h6 { - display: block; - clear: none; - float: left; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - -ms-box-sizing: border-box; - box-sizing: border-box; - width: 60%; -} - -div.heading_with_menu ul { - display: block; - clear: none; - float: right; - -moz-box-sizing: border-box; - -webkit-box-sizing: border-box; - -ms-box-sizing: border-box; - box-sizing: border-box; - margin-top: 10px; -} - -.body-textarea { - width: 300px; - height: 100px; -} - -p { - line-height: 1.4em; - padding: 0 0 10px 0; - color: #333333; -} - -ol { - margin: 0px 0 10px 0; - padding: 0 0 0 18px; - list-style-type: decimal; -} - -ol li { - padding: 5px 0px; - font-size: 0.9em; - color: #333333; -} - -.markdown h3 { - color: #547f00; -} - -.markdown h4 { - color: #666666; -} - -.markdown pre { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - background-color: #fcf6db; - border: 1px solid black; - border-color: #e5e0c6; - padding: 10px; - margin: 0 0 10px 0; -} - -.markdown pre code { - line-height: 1.6em; -} - -.markdown p code, .markdown li code { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - background-color: #f0f0f0; - color: black; - padding: 1px 3px; -} - -.markdown ol, .markdown ul { - font-family: "Droid Sans", sans-serif; - margin: 5px 0 10px 0; - padding: 0 0 0 18px; - list-style-type: disc; -} - -.markdown ol li, .markdown ul li { - padding: 3px 0px; - line-height: 1.4em; - color: #333333; -} - -div.gist { - margin: 20px 0 25px 0 !important; -} - -p.big, div.big p { - font-size: 1em; - margin-bottom: 10px; -} - -span.weak { - color: #666666; -} - -span.blank, span.empty { - color: #888888; - font-style: italic; -} - -a { - color: #547f00; -} - -strong { - font-family: "Droid Sans", sans-serif; - font-weight: bold; - font-weight: bold; -} - -.code { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; -} - -pre { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - background-color: #fcf6db; - border: 1px solid black; - border-color: #e5e0c6; - padding: 10px; - /* white-space: pre-line */ -} - -pre code { - line-height: 1.6em; -} - -.required { - font-weight: bold; -} - -table.fullwidth { - width: 100%; -} - -table thead tr th { - padding: 5px; - font-size: 0.9em; - color: #666666; - border-bottom: 1px solid #999999; -} - -table tbody tr.offset { - background-color: #f5f5f5; -} - -table tbody tr td { - padding: 6px; - font-size: 0.9em; - border-bottom: 1px solid #cccccc; - vertical-align: top; - line-height: 1.3em; -} - -table tbody tr:last-child td { - border-bottom: none; -} - -table tbody tr.offset { - background-color: #f0f0f0; -} - -form.form_box { - background-color: #ebf3f9; - border: 1px solid black; - border-color: #c3d9ec; - padding: 10px; -} - -form.form_box label { - color: #0f6ab4 !important; -} - -form.form_box input[type=submit] { - display: block; - padding: 10px; -} - -form.form_box p { - font-size: 0.9em; - padding: 0 0 15px 0; - color: #7e7b6d; -} - -form.form_box p a { - color: #646257; -} - -form.form_box p strong { - color: black; -} - -form.form_box p.weak { - font-size: 0.8em; -} - -form.formtastic fieldset.inputs ol li p.inline-hints { - margin-left: 0; - font-style: italic; - font-size: 0.9em; - margin: 0; -} - -form.formtastic fieldset.inputs ol li label { - display: block; - clear: both; - width: auto; - padding: 0 0 3px 0; - color: #666666; -} - -form.formtastic fieldset.inputs ol li label abbr { - padding-left: 3px; - color: #888888; -} - -form.formtastic fieldset.inputs ol li.required label { - color: black; -} - -form.formtastic fieldset.inputs ol li.string input, form.formtastic fieldset.inputs ol li.url input, form.formtastic fieldset.inputs ol li.numeric input { - display: block; - padding: 4px; - width: auto; - clear: both; -} - -form.formtastic fieldset.inputs ol li.string input.title, form.formtastic fieldset.inputs ol li.url input.title, form.formtastic fieldset.inputs ol li.numeric input.title { - font-size: 1.3em; -} - -form.formtastic fieldset.inputs ol li.text textarea { - font-family: "Droid Sans", sans-serif; - height: 250px; - padding: 4px; - display: block; - clear: both; -} - -form.formtastic fieldset.inputs ol li.select select { - display: block; - clear: both; -} - -form.formtastic fieldset.inputs ol li.boolean { - float: none; - clear: both; - overflow: hidden; - display: block; -} - -form.formtastic fieldset.inputs ol li.boolean input { - display: block; - float: left; - clear: none; - margin: 0 5px 0 0; -} - -form.formtastic fieldset.inputs ol li.boolean label { - display: block; - float: left; - clear: none; - margin: 0; - padding: 0; -} - -form.formtastic fieldset.buttons { - margin: 0; - padding: 0; -} - -form.fullwidth ol li.string input, form.fullwidth ol li.url input, form.fullwidth ol li.text textarea, form.fullwidth ol li.numeric input { - width: 500px !important; -} - -body { - font-family: "Droid Sans", sans-serif; -} - -body #content_message { - margin: 10px 15px; - font-style: italic; - color: #999999; -} - -body #header { - background-color: #89bf04; - padding: 14px; -} - -body #header a#logo { - font-size: 1.5em; - font-weight: bold; - text-decoration: none; - background: transparent url(../images/logo_small.png) no-repeat left center; - padding: 20px 0 20px 40px; - color: white; -} - -body #header form#api_selector { - display: block; - clear: none; - float: right; -} - -body #header form#api_selector .input { - display: block; - clear: none; - float: left; - margin: 0 10px 0 0; -} - -body #header form#api_selector .input input { - font-size: 0.9em; - padding: 3px; - margin: 0; -} - -body #header form#api_selector .input input#input_baseUrl { - width: 400px; -} - -body #header form#api_selector .input input#input_apiKey { - width: 200px; -} - -body #header form#api_selector .input a#explore { - display: block; - text-decoration: none; - font-weight: bold; - padding: 6px 8px; - font-size: 0.9em; - color: white; - background-color: #547f00; - -moz-border-radius: 4px; - -webkit-border-radius: 4px; - -o-border-radius: 4px; - -ms-border-radius: 4px; - -khtml-border-radius: 4px; - border-radius: 4px; -} - -body #header form#api_selector .input a#explore:hover { - background-color: #547f00; -} - -body p#colophon { - margin: 0 15px 40px 15px; - padding: 10px 0; - font-size: 0.8em; - border-top: 1px solid #dddddd; - font-family: "Droid Sans", sans-serif; - color: #999999; - font-style: italic; -} - -body p#colophon a { - text-decoration: none; - color: #547f00; -} - -body ul#resources { - font-family: "Droid Sans", sans-serif; - font-size: 0.9em; -} - -body ul#resources li.resource { - border-bottom: 1px solid #dddddd; -} - -body ul#resources li.resource:last-child { - border-bottom: none; -} - -body ul#resources li.resource div.heading { - border: 1px solid transparent; - float: none; - clear: both; - overflow: hidden; - display: block; -} - -body ul#resources li.resource div.heading h2 { - color: #999999; - padding-left: 0px; - display: block; - clear: none; - float: left; - font-family: "Droid Sans", sans-serif; - font-weight: bold; -} - -body ul#resources li.resource div.heading h2 a { - color: #999999; -} - -body ul#resources li.resource div.heading h2 a:hover { - color: black; -} - -body ul#resources li.resource div.heading ul.options { - float: none; - clear: both; - overflow: hidden; - margin: 0; - padding: 0; - display: block; - clear: none; - float: right; - margin: 14px 10px 0 0; -} - -body ul#resources li.resource div.heading ul.options li { - float: left; - clear: none; - margin: 0; - padding: 2px 10px; - border-right: 1px solid #dddddd; -} - -body ul#resources li.resource div.heading ul.options li:first-child, body ul#resources li.resource div.heading ul.options li.first { - padding-left: 0; -} - -body ul#resources li.resource div.heading ul.options li:last-child, body ul#resources li.resource div.heading ul.options li.last { - padding-right: 0; - border-right: none; -} - -body ul#resources li.resource div.heading ul.options li { - color: #666666; - font-size: 0.9em; -} - -body ul#resources li.resource div.heading ul.options li a { - color: #aaaaaa; - text-decoration: none; -} - -body ul#resources li.resource div.heading ul.options li a:hover { - text-decoration: underline; - color: black; -} - -body ul#resources li.resource:hover div.heading h2 a, body ul#resources li.resource.active div.heading h2 a { - color: black; -} - -body ul#resources li.resource:hover div.heading ul.options li a, body ul#resources li.resource.active div.heading ul.options li a { - color: #555555; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 10px 0; - padding: 0 0 0 0px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 0 0; - padding: 0; - background-color: #e7f0f7; - border: 1px solid black; - border-color: #c3d9ec; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 { - display: block; - clear: none; - float: left; - width: auto; - margin: 0; - padding: 0; - line-height: 1.1em; - color: black; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span { - margin: 0; - padding: 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.http_method a { - text-transform: uppercase; - background-color: #0f6ab4; - text-decoration: none; - color: white; - display: inline-block; - width: 50px; - font-size: 0.7em; - text-align: center; - padding: 7px 0 4px 0; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - -o-border-radius: 2px; - -ms-border-radius: 2px; - -khtml-border-radius: 2px; - border-radius: 2px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.path { - padding-left: 10px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.path a { - color: black; - text-decoration: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.path a:hover { - text-decoration: underline; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options { - float: none; - clear: both; - overflow: hidden; - margin: 0; - padding: 0; - display: block; - clear: none; - float: right; - margin: 6px 10px 0 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li { - float: left; - clear: none; - margin: 0; - padding: 2px 10px; - border-right: 1px solid #dddddd; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li:first-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li.first { - padding-left: 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li:last-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li.last { - padding-right: 0; - border-right: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li { - border-right-color: #c3d9ec; - color: #0f6ab4; - font-size: 0.9em; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a { - color: #0f6ab4; - text-decoration: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a:hover, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a:active, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a.active { - text-decoration: underline; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content { - background-color: #ebf3f9; - border: 1px solid black; - border-color: #c3d9ec; - border-top: none; - padding: 10px; - -moz-border-radius-bottomleft: 6px; - -webkit-border-bottom-left-radius: 6px; - -o-border-bottom-left-radius: 6px; - -ms-border-bottom-left-radius: 6px; - -khtml-border-bottom-left-radius: 6px; - border-bottom-left-radius: 6px; - -moz-border-radius-bottomright: 6px; - -webkit-border-bottom-right-radius: 6px; - -o-border-bottom-right-radius: 6px; - -ms-border-bottom-right-radius: 6px; - -khtml-border-bottom-right-radius: 6px; - border-bottom-right-radius: 6px; - margin: 0 0 20px 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content h4 { - color: #0f6ab4; - font-size: 1.1em; - margin: 0; - padding: 15px 0 5px 0px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content form input[type='text'].error { - outline: 2px solid black; - outline-color: #cc0000; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header { - float: none; - clear: both; - overflow: hidden; - display: block; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header input.submit { - display: block; - clear: none; - float: left; - padding: 6px 8px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header img { - display: block; - display: block; - clear: none; - float: right; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a { - padding: 4px 0 0 10px; - color: #6fa5d2; - display: inline-block; - font-size: 0.9em; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.response div.block { - background-color: #fcf6db; - border: 1px solid black; - border-color: #e5e0c6; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.response div.block pre { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - padding: 10px; - font-size: 0.9em; - max-height: 400px; - overflow-y: auto; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 10px 0; - padding: 0 0 0 0px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 0 0; - padding: 0; - background-color: #e7f6ec; - border: 1px solid black; - border-color: #c3e8d1; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 { - display: block; - clear: none; - float: left; - width: auto; - margin: 0; - padding: 0; - line-height: 1.1em; - color: black; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span { - margin: 0; - padding: 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.http_method a { - text-transform: uppercase; - background-color: #10a54a; - text-decoration: none; - color: white; - display: inline-block; - width: 50px; - font-size: 0.7em; - text-align: center; - padding: 7px 0 4px 0; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - -o-border-radius: 2px; - -ms-border-radius: 2px; - -khtml-border-radius: 2px; - border-radius: 2px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.path { - padding-left: 10px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.path a { - color: black; - text-decoration: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.path a:hover { - text-decoration: underline; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options { - float: none; - clear: both; - overflow: hidden; - margin: 0; - padding: 0; - display: block; - clear: none; - float: right; - margin: 6px 10px 0 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li { - float: left; - clear: none; - margin: 0; - padding: 2px 10px; - border-right: 1px solid #dddddd; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li:first-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li.first { - padding-left: 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li:last-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li.last { - padding-right: 0; - border-right: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li { - border-right-color: #c3e8d1; - color: #10a54a; - font-size: 0.9em; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a { - color: #10a54a; - text-decoration: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a:hover, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a:active, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a.active { - text-decoration: underline; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content { - background-color: #ebf7f0; - border: 1px solid black; - border-color: #c3e8d1; - border-top: none; - padding: 10px; - -moz-border-radius-bottomleft: 6px; - -webkit-border-bottom-left-radius: 6px; - -o-border-bottom-left-radius: 6px; - -ms-border-bottom-left-radius: 6px; - -khtml-border-bottom-left-radius: 6px; - border-bottom-left-radius: 6px; - -moz-border-radius-bottomright: 6px; - -webkit-border-bottom-right-radius: 6px; - -o-border-bottom-right-radius: 6px; - -ms-border-bottom-right-radius: 6px; - -khtml-border-bottom-right-radius: 6px; - border-bottom-right-radius: 6px; - margin: 0 0 20px 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content h4 { - color: #10a54a; - font-size: 1.1em; - margin: 0; - padding: 15px 0 5px 0px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content form input[type='text'].error { - outline: 2px solid black; - outline-color: #cc0000; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header { - float: none; - clear: both; - overflow: hidden; - display: block; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header input.submit { - display: block; - clear: none; - float: left; - padding: 6px 8px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header img { - display: block; - display: block; - clear: none; - float: right; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header a { - padding: 4px 0 0 10px; - color: #6fc992; - display: inline-block; - font-size: 0.9em; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.response div.block { - background-color: #fcf6db; - border: 1px solid black; - border-color: #e5e0c6; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.response div.block pre { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - padding: 10px; - font-size: 0.9em; - max-height: 400px; - overflow-y: auto; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 10px 0; - padding: 0 0 0 0px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 0 0; - padding: 0; - background-color: #f9f2e9; - border: 1px solid black; - border-color: #f0e0ca; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 { - display: block; - clear: none; - float: left; - width: auto; - margin: 0; - padding: 0; - line-height: 1.1em; - color: black; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span { - margin: 0; - padding: 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.http_method a { - text-transform: uppercase; - background-color: #c5862b; - text-decoration: none; - color: white; - display: inline-block; - width: 50px; - font-size: 0.7em; - text-align: center; - padding: 7px 0 4px 0; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - -o-border-radius: 2px; - -ms-border-radius: 2px; - -khtml-border-radius: 2px; - border-radius: 2px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.path { - padding-left: 10px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.path a { - color: black; - text-decoration: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.path a:hover { - text-decoration: underline; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options { - float: none; - clear: both; - overflow: hidden; - margin: 0; - padding: 0; - display: block; - clear: none; - float: right; - margin: 6px 10px 0 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li { - float: left; - clear: none; - margin: 0; - padding: 2px 10px; - border-right: 1px solid #dddddd; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li:first-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li.first { - padding-left: 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li:last-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li.last { - padding-right: 0; - border-right: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li { - border-right-color: #f0e0ca; - color: #c5862b; - font-size: 0.9em; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a { - color: #c5862b; - text-decoration: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a:hover, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a:active, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a.active { - text-decoration: underline; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content { - background-color: #faf5ee; - border: 1px solid black; - border-color: #f0e0ca; - border-top: none; - padding: 10px; - -moz-border-radius-bottomleft: 6px; - -webkit-border-bottom-left-radius: 6px; - -o-border-bottom-left-radius: 6px; - -ms-border-bottom-left-radius: 6px; - -khtml-border-bottom-left-radius: 6px; - border-bottom-left-radius: 6px; - -moz-border-radius-bottomright: 6px; - -webkit-border-bottom-right-radius: 6px; - -o-border-bottom-right-radius: 6px; - -ms-border-bottom-right-radius: 6px; - -khtml-border-bottom-right-radius: 6px; - border-bottom-right-radius: 6px; - margin: 0 0 20px 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content h4 { - color: #c5862b; - font-size: 1.1em; - margin: 0; - padding: 15px 0 5px 0px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content form input[type='text'].error { - outline: 2px solid black; - outline-color: #cc0000; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header { - float: none; - clear: both; - overflow: hidden; - display: block; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header input.submit { - display: block; - clear: none; - float: left; - padding: 6px 8px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header img { - display: block; - display: block; - clear: none; - float: right; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header a { - padding: 4px 0 0 10px; - color: #dcb67f; - display: inline-block; - font-size: 0.9em; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.response div.block { - background-color: #fcf6db; - border: 1px solid black; - border-color: #e5e0c6; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.response div.block pre { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - padding: 10px; - font-size: 0.9em; - max-height: 400px; - overflow-y: auto; -} - - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 10px 0; - padding: 0 0 0 0px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 0 0; - padding: 0; - background-color: #FCE9E3; - border: 1px solid black; - border-color: #F5D5C3; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 { - display: block; - clear: none; - float: left; - width: auto; - margin: 0; - padding: 0; - line-height: 1.1em; - color: black; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span { - margin: 0; - padding: 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span.http_method a { - text-transform: uppercase; - background-color: #D38042; - text-decoration: none; - color: white; - display: inline-block; - width: 50px; - font-size: 0.7em; - text-align: center; - padding: 7px 0 4px 0; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - -o-border-radius: 2px; - -ms-border-radius: 2px; - -khtml-border-radius: 2px; - border-radius: 2px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span.path { - padding-left: 10px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span.path a { - color: black; - text-decoration: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span.path a:hover { - text-decoration: underline; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options { - float: none; - clear: both; - overflow: hidden; - margin: 0; - padding: 0; - display: block; - clear: none; - float: right; - margin: 6px 10px 0 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li { - float: left; - clear: none; - margin: 0; - padding: 2px 10px; - border-right: 1px solid #dddddd; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li:first-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li.first { - padding-left: 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li:last-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li.last { - padding-right: 0; - border-right: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li { - border-right-color: #f0cecb; - color: #D38042; - font-size: 0.9em; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li a { - color: #D38042; - text-decoration: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li a:hover, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li a:active, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li a.active { - text-decoration: underline; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content { - background-color: #faf0ef; - border: 1px solid black; - border-color: #f0cecb; - border-top: none; - padding: 10px; - -moz-border-radius-bottomleft: 6px; - -webkit-border-bottom-left-radius: 6px; - -o-border-bottom-left-radius: 6px; - -ms-border-bottom-left-radius: 6px; - -khtml-border-bottom-left-radius: 6px; - border-bottom-left-radius: 6px; - -moz-border-radius-bottomright: 6px; - -webkit-border-bottom-right-radius: 6px; - -o-border-bottom-right-radius: 6px; - -ms-border-bottom-right-radius: 6px; - -khtml-border-bottom-right-radius: 6px; - border-bottom-right-radius: 6px; - margin: 0 0 20px 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content h4 { - color: #D38042; - font-size: 1.1em; - margin: 0; - padding: 15px 0 5px 0px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content form input[type='text'].error { - outline: 2px solid black; - outline-color: #F5D5C3; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.sandbox_header { - float: none; - clear: both; - overflow: hidden; - display: block; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.sandbox_header input.submit { - display: block; - clear: none; - float: left; - padding: 6px 8px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.sandbox_header img { - display: block; - display: block; - clear: none; - float: right; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.sandbox_header a { - padding: 4px 0 0 10px; - color: #dcb67f; - display: inline-block; - font-size: 0.9em; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.response div.block { - background-color: #fcf6db; - border: 1px solid black; - border-color: #e5e0c6; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.response div.block pre { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - padding: 10px; - font-size: 0.9em; - max-height: 400px; - overflow-y: auto; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 10px 0; - padding: 0 0 0 0px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading { - float: none; - clear: both; - overflow: hidden; - display: block; - margin: 0 0 0 0; - padding: 0; - background-color: #f5e8e8; - border: 1px solid black; - border-color: #e8c6c7; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 { - display: block; - clear: none; - float: left; - width: auto; - margin: 0; - padding: 0; - line-height: 1.1em; - color: black; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span { - margin: 0; - padding: 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.http_method a { - text-transform: uppercase; - background-color: #a41e22; - text-decoration: none; - color: white; - display: inline-block; - width: 50px; - font-size: 0.7em; - text-align: center; - padding: 7px 0 4px 0; - -moz-border-radius: 2px; - -webkit-border-radius: 2px; - -o-border-radius: 2px; - -ms-border-radius: 2px; - -khtml-border-radius: 2px; - border-radius: 2px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.path { - padding-left: 10px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.path a { - color: black; - text-decoration: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.path a:hover { - text-decoration: underline; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options { - float: none; - clear: both; - overflow: hidden; - margin: 0; - padding: 0; - display: block; - clear: none; - float: right; - margin: 6px 10px 0 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li { - float: left; - clear: none; - margin: 0; - padding: 2px 10px; - border-right: 1px solid #dddddd; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li:first-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li.first { - padding-left: 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li:last-child, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li.last { - padding-right: 0; - border-right: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li { - border-right-color: #e8c6c7; - color: #a41e22; - font-size: 0.9em; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a { - color: #a41e22; - text-decoration: none; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a:hover, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a:active, body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a.active { - text-decoration: underline; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content { - background-color: #f7eded; - border: 1px solid black; - border-color: #e8c6c7; - border-top: none; - padding: 10px; - -moz-border-radius-bottomleft: 6px; - -webkit-border-bottom-left-radius: 6px; - -o-border-bottom-left-radius: 6px; - -ms-border-bottom-left-radius: 6px; - -khtml-border-bottom-left-radius: 6px; - border-bottom-left-radius: 6px; - -moz-border-radius-bottomright: 6px; - -webkit-border-bottom-right-radius: 6px; - -o-border-bottom-right-radius: 6px; - -ms-border-bottom-right-radius: 6px; - -khtml-border-bottom-right-radius: 6px; - border-bottom-right-radius: 6px; - margin: 0 0 20px 0; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content h4 { - color: #a41e22; - font-size: 1.1em; - margin: 0; - padding: 15px 0 5px 0px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content form input[type='text'].error { - outline: 2px solid black; - outline-color: #cc0000; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header { - float: none; - clear: both; - overflow: hidden; - display: block; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header input.submit { - display: block; - clear: none; - float: left; - padding: 6px 8px; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header img { - display: block; - display: block; - clear: none; - float: right; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header a { - padding: 4px 0 0 10px; - color: #c8787a; - display: inline-block; - font-size: 0.9em; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.response div.block { - background-color: #fcf6db; - border: 1px solid black; - border-color: #e5e0c6; -} - -body ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.response div.block pre { - font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; - padding: 10px; - font-size: 0.9em; - max-height: 400px; - overflow-y: auto; -} - - -.model-signature { - font-family: "Droid Sans", sans-serif; - font-size: 1em; - line-height: 1.5em; -} -.model-signature .description span { - font-size: 0.9em; - line-height: 1.5em; -} -.model-signature .description span:nth-child(odd) { color:#333; } -.model-signature .description span:nth-child(even) { color:#C5862B; } -.model-signature .signature-nav a { - text-decoration: none; - color: #AAA; -} - -.model-signature pre { - font-size: .85em; - line-height: 1.2em; - overflow: auto; - max-height: 200px; - cursor: pointer; -} - -.model-signature pre:hover { - background-color: #ffffdd; -} - -.model-signature .snippet small { - font-size: 0.75em; -} - -.model-signature .signature-container { - clear: both; -} - -.model-signature .signature-nav a:hover { - text-decoration: underline; - color: black; -} - -.model-signature .signature-nav .selected { - color: black; - text-decoration: none; -} - -.model-signature ul.signature-nav { - float: none; - clear: both; - overflow: hidden; - margin: 0; - padding: 0; - display: block; - clear: none; - float: right; - margin-right: 5px; - margin-bottom: 5px; -} - -.model-signature ul.signature-nav li { - float: left; - clear: none; - margin: 0; - padding: 2px 10px; - border-right: 1px solid #dddddd; -} - -.model-signature ul.signature-nav li:last-child { - padding-right: 0; - border-right: none; -} - -pre code { + border-collapse: collapse; + border-spacing: 0; +} +.swagger-ui-wrap { + line-height: 1; + font-family: "Droid Sans", sans-serif; + max-width: 960px; + margin-left: auto; + margin-right: auto; +} +.swagger-ui-wrap b, +.swagger-ui-wrap strong { + font-family: "Droid Sans", sans-serif; + font-weight: bold; +} +.swagger-ui-wrap q, +.swagger-ui-wrap blockquote { + quotes: none; +} +.swagger-ui-wrap p { + line-height: 1.4em; + padding: 0 0 10px; + color: #333333; +} +.swagger-ui-wrap q:before, +.swagger-ui-wrap q:after, +.swagger-ui-wrap blockquote:before, +.swagger-ui-wrap blockquote:after { + content: none; +} +.swagger-ui-wrap .heading_with_menu h1, +.swagger-ui-wrap .heading_with_menu h2, +.swagger-ui-wrap .heading_with_menu h3, +.swagger-ui-wrap .heading_with_menu h4, +.swagger-ui-wrap .heading_with_menu h5, +.swagger-ui-wrap .heading_with_menu h6 { + display: block; + clear: none; + float: left; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; + width: 60%; +} +.swagger-ui-wrap table { + border-collapse: collapse; + border-spacing: 0; +} +.swagger-ui-wrap table thead tr th { + padding: 5px; + font-size: 0.9em; + color: #666666; + border-bottom: 1px solid #999999; +} +.swagger-ui-wrap table tbody tr:last-child td { + border-bottom: none; +} +.swagger-ui-wrap table tbody tr.offset { + background-color: #f0f0f0; +} +.swagger-ui-wrap table tbody tr td { + padding: 6px; + font-size: 0.9em; + border-bottom: 1px solid #cccccc; + vertical-align: top; + line-height: 1.3em; +} +.swagger-ui-wrap ol { + margin: 0px 0 10px; + padding: 0 0 0 18px; + list-style-type: decimal; +} +.swagger-ui-wrap ol li { + padding: 5px 0px; + font-size: 0.9em; + color: #333333; +} +.swagger-ui-wrap ol, +.swagger-ui-wrap ul { + list-style: none; +} +.swagger-ui-wrap h1 a, +.swagger-ui-wrap h2 a, +.swagger-ui-wrap h3 a, +.swagger-ui-wrap h4 a, +.swagger-ui-wrap h5 a, +.swagger-ui-wrap h6 a { + text-decoration: none; +} +.swagger-ui-wrap h1 a:hover, +.swagger-ui-wrap h2 a:hover, +.swagger-ui-wrap h3 a:hover, +.swagger-ui-wrap h4 a:hover, +.swagger-ui-wrap h5 a:hover, +.swagger-ui-wrap h6 a:hover { + text-decoration: underline; +} +.swagger-ui-wrap h1 span.divider, +.swagger-ui-wrap h2 span.divider, +.swagger-ui-wrap h3 span.divider, +.swagger-ui-wrap h4 span.divider, +.swagger-ui-wrap h5 span.divider, +.swagger-ui-wrap h6 span.divider { + color: #aaaaaa; +} +.swagger-ui-wrap a { + color: #547f00; +} +.swagger-ui-wrap a img { + border: none; +} +.swagger-ui-wrap article, +.swagger-ui-wrap aside, +.swagger-ui-wrap details, +.swagger-ui-wrap figcaption, +.swagger-ui-wrap figure, +.swagger-ui-wrap footer, +.swagger-ui-wrap header, +.swagger-ui-wrap hgroup, +.swagger-ui-wrap menu, +.swagger-ui-wrap nav, +.swagger-ui-wrap section, +.swagger-ui-wrap summary { + display: block; +} +.swagger-ui-wrap pre { + font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; + background-color: #fcf6db; + border: 1px solid #e5e0c6; + padding: 10px; +} +.swagger-ui-wrap pre code { + line-height: 1.6em; background: none; } - -.content > .content-type > div > label { +.swagger-ui-wrap .content > .content-type > div > label { clear: both; display: block; color: #0F6AB4; font-size: 1.1em; margin: 0; - padding: 15px 0 5px 0px; + padding: 15px 0 5px; +} +.swagger-ui-wrap .content pre { + font-size: 12px; + margin-top: 5px; + padding: 5px; +} +.swagger-ui-wrap .icon-btn { + cursor: pointer; +} +.swagger-ui-wrap .info_title { + padding-bottom: 10px; + font-weight: bold; + font-size: 25px; +} +.swagger-ui-wrap p.big, +.swagger-ui-wrap div.big p { + font-size: 1em; + margin-bottom: 10px; +} +.swagger-ui-wrap form.fullwidth ol li.string input, +.swagger-ui-wrap form.fullwidth ol li.url input, +.swagger-ui-wrap form.fullwidth ol li.text textarea, +.swagger-ui-wrap form.fullwidth ol li.numeric input { + width: 500px !important; +} +.swagger-ui-wrap .info_license { + padding-bottom: 5px; +} +.swagger-ui-wrap .info_tos { + padding-bottom: 5px; +} +.swagger-ui-wrap .message-fail { + color: #cc0000; +} +.swagger-ui-wrap .info_contact { + padding-bottom: 5px; +} +.swagger-ui-wrap .info_description { + padding-bottom: 10px; + font-size: 15px; +} +.swagger-ui-wrap .markdown ol li, +.swagger-ui-wrap .markdown ul li { + padding: 3px 0px; + line-height: 1.4em; + color: #333333; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input, +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input, +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input { + display: block; + padding: 4px; + width: auto; + clear: both; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.string input.title, +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.url input.title, +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.numeric input.title { + font-size: 1.3em; +} +.swagger-ui-wrap table.fullwidth { + width: 100%; +} +.swagger-ui-wrap .model-signature { + font-family: "Droid Sans", sans-serif; + font-size: 1em; + line-height: 1.5em; +} +.swagger-ui-wrap .model-signature .signature-nav a { + text-decoration: none; + color: #AAA; +} +.swagger-ui-wrap .model-signature .signature-nav a:hover { + text-decoration: underline; + color: black; +} +.swagger-ui-wrap .model-signature .signature-nav .selected { + color: black; + text-decoration: none; +} +.swagger-ui-wrap .model-signature .propType { + color: #5555aa; +} +.swagger-ui-wrap .model-signature pre:hover { + background-color: #ffffdd; +} +.swagger-ui-wrap .model-signature pre { + font-size: .85em; + line-height: 1.2em; + overflow: auto; + max-height: 200px; + cursor: pointer; +} +.swagger-ui-wrap .model-signature ul.signature-nav { + display: block; + margin: 0; + padding: 0; +} +.swagger-ui-wrap .model-signature ul.signature-nav li:last-child { + padding-right: 0; + border-right: none; +} +.swagger-ui-wrap .model-signature ul.signature-nav li { + float: left; + margin: 0 5px 5px 0; + padding: 2px 5px 2px 0; + border-right: 1px solid #ddd; +} +.swagger-ui-wrap .model-signature .propOpt { + color: #555; +} +.swagger-ui-wrap .model-signature .snippet small { + font-size: 0.75em; +} +.swagger-ui-wrap .model-signature .propOptKey { + font-style: italic; +} +.swagger-ui-wrap .model-signature .description .strong { + font-weight: bold; + color: #000; + font-size: .9em; +} +.swagger-ui-wrap .model-signature .description div { + font-size: 0.9em; + line-height: 1.5em; + margin-left: 1em; +} +.swagger-ui-wrap .model-signature .description .stronger { + font-weight: bold; + color: #000; +} +.swagger-ui-wrap .model-signature .propName { + font-weight: bold; +} +.swagger-ui-wrap .model-signature .signature-container { + clear: both; +} +.swagger-ui-wrap .body-textarea { + width: 300px; + height: 100px; + border: 1px solid #aaa; +} +.swagger-ui-wrap .markdown p code, +.swagger-ui-wrap .markdown li code { + font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; + background-color: #f0f0f0; + color: black; + padding: 1px 3px; +} +.swagger-ui-wrap .required { + font-weight: bold; +} +.swagger-ui-wrap input.parameter { + width: 300px; + border: 1px solid #aaa; +} +.swagger-ui-wrap h1 { + color: black; + font-size: 1.5em; + line-height: 1.3em; + padding: 10px 0 10px 0; + font-family: "Droid Sans", sans-serif; + font-weight: bold; +} +.swagger-ui-wrap .heading_with_menu { + float: none; + clear: both; + overflow: hidden; + display: block; +} +.swagger-ui-wrap .heading_with_menu ul { + display: block; + clear: none; + float: right; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + -ms-box-sizing: border-box; + box-sizing: border-box; + margin-top: 10px; +} +.swagger-ui-wrap h2 { + color: black; + font-size: 1.3em; + padding: 10px 0 10px 0; +} +.swagger-ui-wrap h2 a { + color: black; +} +.swagger-ui-wrap h2 span.sub { + font-size: 0.7em; + color: #999999; + font-style: italic; +} +.swagger-ui-wrap h2 span.sub a { + color: #777777; +} +.swagger-ui-wrap span.weak { + color: #666666; +} +.swagger-ui-wrap .message-success { + color: #89BF04; +} +.swagger-ui-wrap caption, +.swagger-ui-wrap th, +.swagger-ui-wrap td { + text-align: left; + font-weight: normal; + vertical-align: middle; +} +.swagger-ui-wrap .code { + font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.text textarea { + font-family: "Droid Sans", sans-serif; + height: 250px; + padding: 4px; + display: block; + clear: both; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.select select { + display: block; + clear: both; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean { + float: none; + clear: both; + overflow: hidden; + display: block; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean label { + display: block; + float: left; + clear: none; + margin: 0; + padding: 0; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.boolean input { + display: block; + float: left; + clear: none; + margin: 0 5px 0 0; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li.required label { + color: black; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li label { + display: block; + clear: both; + width: auto; + padding: 0 0 3px; + color: #666666; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li label abbr { + padding-left: 3px; + color: #888888; +} +.swagger-ui-wrap form.formtastic fieldset.inputs ol li p.inline-hints { + margin-left: 0; + font-style: italic; + font-size: 0.9em; + margin: 0; +} +.swagger-ui-wrap form.formtastic fieldset.buttons { + margin: 0; + padding: 0; +} +.swagger-ui-wrap span.blank, +.swagger-ui-wrap span.empty { + color: #888888; + font-style: italic; +} +.swagger-ui-wrap .markdown h3 { + color: #547f00; +} +.swagger-ui-wrap .markdown h4 { + color: #666666; +} +.swagger-ui-wrap .markdown pre { + font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; + background-color: #fcf6db; + border: 1px solid #e5e0c6; + padding: 10px; + margin: 0 0 10px 0; +} +.swagger-ui-wrap .markdown pre code { + line-height: 1.6em; +} +.swagger-ui-wrap div.gist { + margin: 20px 0 25px 0 !important; +} +.swagger-ui-wrap ul#resources { + font-family: "Droid Sans", sans-serif; + font-size: 0.9em; +} +.swagger-ui-wrap ul#resources li.resource { + border-bottom: 1px solid #dddddd; +} +.swagger-ui-wrap ul#resources li.resource:hover div.heading h2 a, +.swagger-ui-wrap ul#resources li.resource.active div.heading h2 a { + color: black; +} +.swagger-ui-wrap ul#resources li.resource:hover div.heading ul.options li a, +.swagger-ui-wrap ul#resources li.resource.active div.heading ul.options li a { + color: #555555; +} +.swagger-ui-wrap ul#resources li.resource:last-child { + border-bottom: none; +} +.swagger-ui-wrap ul#resources li.resource div.heading { + border: 1px solid transparent; + float: none; + clear: both; + overflow: hidden; + display: block; +} +.swagger-ui-wrap ul#resources li.resource div.heading ul.options { + overflow: hidden; + padding: 0; + display: block; + clear: none; + float: right; + margin: 14px 10px 0 0; +} +.swagger-ui-wrap ul#resources li.resource div.heading ul.options li { + float: left; + clear: none; + margin: 0; + padding: 2px 10px; + border-right: 1px solid #dddddd; + color: #666666; + font-size: 0.9em; +} +.swagger-ui-wrap ul#resources li.resource div.heading ul.options li a { + color: #aaaaaa; + text-decoration: none; +} +.swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover { + text-decoration: underline; + color: black; +} +.swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:hover, +.swagger-ui-wrap ul#resources li.resource div.heading ul.options li a:active, +.swagger-ui-wrap ul#resources li.resource div.heading ul.options li a.active { + text-decoration: underline; +} +.swagger-ui-wrap ul#resources li.resource div.heading ul.options li:first-child, +.swagger-ui-wrap ul#resources li.resource div.heading ul.options li.first { + padding-left: 0; +} +.swagger-ui-wrap ul#resources li.resource div.heading ul.options li:last-child, +.swagger-ui-wrap ul#resources li.resource div.heading ul.options li.last { + padding-right: 0; + border-right: none; +} +.swagger-ui-wrap ul#resources li.resource div.heading ul.options:first-child, +.swagger-ui-wrap ul#resources li.resource div.heading ul.options.first { + padding-left: 0; +} +.swagger-ui-wrap ul#resources li.resource div.heading h2 { + color: #999999; + padding-left: 0; + display: block; + clear: none; + float: left; + font-family: "Droid Sans", sans-serif; + font-weight: bold; +} +.swagger-ui-wrap ul#resources li.resource div.heading h2 a { + color: #999999; +} +.swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover { + color: black; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation { + float: none; + clear: both; + overflow: hidden; + display: block; + margin: 0 0 10px; + padding: 0; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading { + float: none; + clear: both; + overflow: hidden; + display: block; + margin: 0; + padding: 0; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 { + display: block; + clear: none; + float: left; + width: auto; + margin: 0; + padding: 0; + line-height: 1.1em; + color: black; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path { + padding-left: 10px; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a { + color: black; + text-decoration: none; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.path a:hover { + text-decoration: underline; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span.http_method a { + text-transform: uppercase; + text-decoration: none; + color: white; + display: inline-block; + width: 50px; + font-size: 0.7em; + text-align: center; + padding: 7px 0 4px; + -moz-border-radius: 2px; + -webkit-border-radius: 2px; + -o-border-radius: 2px; + -ms-border-radius: 2px; + -khtml-border-radius: 2px; + border-radius: 2px; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading h3 span { + margin: 0; + padding: 0; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options { + overflow: hidden; + padding: 0; + display: block; + clear: none; + float: right; + margin: 6px 10px 0 0; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li { + float: left; + clear: none; + margin: 0; + padding: 2px 10px; + font-size: 0.9em; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.heading ul.options li a { + text-decoration: none; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content { + border-top: none; + padding: 10px; + -moz-border-radius-bottomleft: 6px; + -webkit-border-bottom-left-radius: 6px; + -o-border-bottom-left-radius: 6px; + -ms-border-bottom-left-radius: 6px; + -khtml-border-bottom-left-radius: 6px; + border-bottom-left-radius: 6px; + -moz-border-radius-bottomright: 6px; + -webkit-border-bottom-right-radius: 6px; + -o-border-bottom-right-radius: 6px; + -ms-border-bottom-right-radius: 6px; + -khtml-border-bottom-right-radius: 6px; + border-bottom-right-radius: 6px; + margin: 0 0 20px; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content h4 { + font-size: 1.1em; + margin: 0; + padding: 15px 0 5px; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header { + float: none; + clear: both; + overflow: hidden; + display: block; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header a { + padding: 4px 0 0 10px; + display: inline-block; + font-size: 0.9em; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header img { + display: block; + clear: none; + float: right; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit { + display: block; + clear: none; + float: left; + padding: 6px 8px; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error { + outline: 2px solid black; + outline-color: #cc0000; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.response div.block pre { + font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; + padding: 10px; + font-size: 0.9em; + max-height: 400px; + overflow-y: auto; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading { + background-color: #f9f2e9; + border: 1px solid #f0e0ca; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading h3 span.http_method a { + background-color: #c5862b; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #f0e0ca; + color: #c5862b; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li a { + color: #c5862b; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content { + background-color: #faf5ee; + border: 1px solid #f0e0ca; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content h4 { + color: #c5862b; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content div.sandbox_header a { + color: #dcb67f; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading { + background-color: #fcffcd; + border: 1px solid black; + border-color: #ffd20f; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading h3 span.http_method a { + text-transform: uppercase; + background-color: #ffd20f; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #ffd20f; + color: #ffd20f; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li a { + color: #ffd20f; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content { + background-color: #fcffcd; + border: 1px solid black; + border-color: #ffd20f; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content h4 { + color: #ffd20f; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content div.sandbox_header a { + color: #6fc992; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading { + background-color: #f5e8e8; + border: 1px solid #e8c6c7; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading h3 span.http_method a { + text-transform: uppercase; + background-color: #a41e22; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #e8c6c7; + color: #a41e22; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li a { + color: #a41e22; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content { + background-color: #f7eded; + border: 1px solid #e8c6c7; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content h4 { + color: #a41e22; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content div.sandbox_header a { + color: #c8787a; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading { + background-color: #e7f6ec; + border: 1px solid #c3e8d1; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading h3 span.http_method a { + background-color: #10a54a; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #c3e8d1; + color: #10a54a; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li a { + color: #10a54a; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content { + background-color: #ebf7f0; + border: 1px solid #c3e8d1; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content h4 { + color: #10a54a; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content div.sandbox_header a { + color: #6fc992; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading { + background-color: #FCE9E3; + border: 1px solid #F5D5C3; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading h3 span.http_method a { + background-color: #D38042; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #f0cecb; + color: #D38042; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li a { + color: #D38042; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content { + background-color: #faf0ef; + border: 1px solid #f0cecb; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content h4 { + color: #D38042; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content div.sandbox_header a { + color: #dcb67f; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading { + background-color: #e7f0f7; + border: 1px solid #c3d9ec; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading h3 span.http_method a { + background-color: #0f6ab4; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li { + border-right: 1px solid #dddddd; + border-right-color: #c3d9ec; + color: #0f6ab4; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li a { + color: #0f6ab4; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content { + background-color: #ebf3f9; + border: 1px solid #c3d9ec; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content h4 { + color: #0f6ab4; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content div.sandbox_header a { + color: #6fa5d2; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.content, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.content, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.content, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.content, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.content, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.content { + border-top: none; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li:last-child, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li:last-child, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li:last-child, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li:last-child, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li:last-child, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li:last-child, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.get div.heading ul.options li.last, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.post div.heading ul.options li.last, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.head div.heading ul.options li.last, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.put div.heading ul.options li.last, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.patch div.heading ul.options li.last, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation.delete div.heading ul.options li.last { + padding-right: 0; + border-right: none; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:hover, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a:active, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li a.active { + text-decoration: underline; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li:first-child, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations ul.options li.first { + padding-left: 0; +} +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations:first-child, +.swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations.first { + padding-left: 0; +} +.swagger-ui-wrap p#colophon { + margin: 0 15px 40px 15px; + padding: 10px 0; + font-size: 0.8em; + border-top: 1px solid #dddddd; + font-family: "Droid Sans", sans-serif; + color: #999999; + font-style: italic; +} +.swagger-ui-wrap p#colophon a { + text-decoration: none; + color: #547f00; +} +.swagger-ui-wrap h3 { + color: black; + font-size: 1.1em; + padding: 10px 0 10px 0; +} +.swagger-ui-wrap .markdown ol, +.swagger-ui-wrap .markdown ul { + font-family: "Droid Sans", sans-serif; + margin: 5px 0 10px; + padding: 0 0 0 18px; + list-style-type: disc; +} +.swagger-ui-wrap form.form_box { + background-color: #ebf3f9; + border: 1px solid #c3d9ec; + padding: 10px; +} +.swagger-ui-wrap form.form_box label { + color: #0f6ab4 !important; +} +.swagger-ui-wrap form.form_box input[type=submit] { + display: block; + padding: 10px; +} +.swagger-ui-wrap form.form_box p.weak { + font-size: 0.8em; +} +.swagger-ui-wrap form.form_box p { + font-size: 0.9em; + padding: 0 0 15px; + color: #7e7b6d; +} +.swagger-ui-wrap form.form_box p a { + color: #646257; +} +.swagger-ui-wrap form.form_box p strong { + color: black; +} +#header { + background-color: #89bf04; + padding: 14px; +} +#header a#logo { + font-size: 1.5em; + font-weight: bold; + text-decoration: none; + background: transparent url(../images/logo_small.png) no-repeat left center; + padding: 20px 0 20px 40px; + color: white; +} +#header form#api_selector { + display: block; + clear: none; + float: right; +} +#header form#api_selector .input { + display: block; + clear: none; + float: left; + margin: 0 10px 0 0; +} +#header form#api_selector .input input#input_apiKey { + width: 200px; +} +#header form#api_selector .input input#input_baseUrl { + width: 400px; +} +#header form#api_selector .input a#explore { + display: block; + text-decoration: none; + font-weight: bold; + padding: 6px 8px; + font-size: 0.9em; + color: white; + background-color: #547f00; + -moz-border-radius: 4px; + -webkit-border-radius: 4px; + -o-border-radius: 4px; + -ms-border-radius: 4px; + -khtml-border-radius: 4px; + border-radius: 4px; +} +#header form#api_selector .input a#explore:hover { + background-color: #547f00; +} +#header form#api_selector .input input { + font-size: 0.9em; + padding: 3px; + margin: 0; +} +#content_message { + margin: 10px 15px; + font-style: italic; + color: #999999; +} +#message-bar { + min-height: 30px; + text-align: center; + padding-top: 10px; } diff --git a/tastypie_swagger/static/tastypie_swagger/images/explorer_icons.png b/tastypie_swagger/static/tastypie_swagger/images/explorer_icons.png new file mode 100755 index 0000000..ed9d2ff Binary files /dev/null and b/tastypie_swagger/static/tastypie_swagger/images/explorer_icons.png differ diff --git a/tastypie_swagger/static/tastypie_swagger/images/logo_small.png b/tastypie_swagger/static/tastypie_swagger/images/logo_small.png old mode 100644 new mode 100755 diff --git a/tastypie_swagger/static/tastypie_swagger/images/pet_store_api.png b/tastypie_swagger/static/tastypie_swagger/images/pet_store_api.png old mode 100644 new mode 100755 diff --git a/tastypie_swagger/static/tastypie_swagger/images/throbber.gif b/tastypie_swagger/static/tastypie_swagger/images/throbber.gif old mode 100644 new mode 100755 diff --git a/tastypie_swagger/static/tastypie_swagger/images/wordnik_api.png b/tastypie_swagger/static/tastypie_swagger/images/wordnik_api.png old mode 100644 new mode 100755 diff --git a/tastypie_swagger/static/tastypie_swagger/js/lib/backbone-min.js b/tastypie_swagger/static/tastypie_swagger/js/lib/backbone-min.js old mode 100644 new mode 100755 diff --git a/tastypie_swagger/static/tastypie_swagger/js/lib/handlebars-1.0.0.js b/tastypie_swagger/static/tastypie_swagger/js/lib/handlebars-1.0.0.js new file mode 100755 index 0000000..c70f09d --- /dev/null +++ b/tastypie_swagger/static/tastypie_swagger/js/lib/handlebars-1.0.0.js @@ -0,0 +1,2278 @@ +/* + +Copyright (C) 2011 by Yehuda Katz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +*/ + +// lib/handlebars/browser-prefix.js +var Handlebars = {}; + +(function(Handlebars, undefined) { +; +// lib/handlebars/base.js + +Handlebars.VERSION = "1.0.0"; +Handlebars.COMPILER_REVISION = 4; + +Handlebars.REVISION_CHANGES = { + 1: '<= 1.0.rc.2', // 1.0.rc.2 is actually rev2 but doesn't report it + 2: '== 1.0.0-rc.3', + 3: '== 1.0.0-rc.4', + 4: '>= 1.0.0' +}; + +Handlebars.helpers = {}; +Handlebars.partials = {}; + +var toString = Object.prototype.toString, + functionType = '[object Function]', + objectType = '[object Object]'; + +Handlebars.registerHelper = function(name, fn, inverse) { + if (toString.call(name) === objectType) { + if (inverse || fn) { throw new Handlebars.Exception('Arg not supported with multiple helpers'); } + Handlebars.Utils.extend(this.helpers, name); + } else { + if (inverse) { fn.not = inverse; } + this.helpers[name] = fn; + } +}; + +Handlebars.registerPartial = function(name, str) { + if (toString.call(name) === objectType) { + Handlebars.Utils.extend(this.partials, name); + } else { + this.partials[name] = str; + } +}; + +Handlebars.registerHelper('helperMissing', function(arg) { + if(arguments.length === 2) { + return undefined; + } else { + throw new Error("Missing helper: '" + arg + "'"); + } +}); + +Handlebars.registerHelper('blockHelperMissing', function(context, options) { + var inverse = options.inverse || function() {}, fn = options.fn; + + var type = toString.call(context); + + if(type === functionType) { context = context.call(this); } + + if(context === true) { + return fn(this); + } else if(context === false || context == null) { + return inverse(this); + } else if(type === "[object Array]") { + if(context.length > 0) { + return Handlebars.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + return fn(context); + } +}); + +Handlebars.K = function() {}; + +Handlebars.createFrame = Object.create || function(object) { + Handlebars.K.prototype = object; + var obj = new Handlebars.K(); + Handlebars.K.prototype = null; + return obj; +}; + +Handlebars.logger = { + DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3, + + methodMap: {0: 'debug', 1: 'info', 2: 'warn', 3: 'error'}, + + // can be overridden in the host environment + log: function(level, obj) { + if (Handlebars.logger.level <= level) { + var method = Handlebars.logger.methodMap[level]; + if (typeof console !== 'undefined' && console[method]) { + console[method].call(console, obj); + } + } + } +}; + +Handlebars.log = function(level, obj) { Handlebars.logger.log(level, obj); }; + +Handlebars.registerHelper('each', function(context, options) { + var fn = options.fn, inverse = options.inverse; + var i = 0, ret = "", data; + + var type = toString.call(context); + if(type === functionType) { context = context.call(this); } + + if (options.data) { + data = Handlebars.createFrame(options.data); + } + + if(context && typeof context === 'object') { + if(context instanceof Array){ + for(var j = context.length; i 2) { + expected.push("'" + this.terminals_[p] + "'"); + } + if (this.lexer.showPosition) { + errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; + } else { + errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); + } + this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); + } + } + if (action[0] instanceof Array && action.length > 1) { + throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); + } + switch (action[0]) { + case 1: + stack.push(symbol); + vstack.push(this.lexer.yytext); + lstack.push(this.lexer.yylloc); + stack.push(action[1]); + symbol = null; + if (!preErrorSymbol) { + yyleng = this.lexer.yyleng; + yytext = this.lexer.yytext; + yylineno = this.lexer.yylineno; + yyloc = this.lexer.yylloc; + if (recovering > 0) + recovering--; + } else { + symbol = preErrorSymbol; + preErrorSymbol = null; + } + break; + case 2: + len = this.productions_[action[1]][1]; + yyval.$ = vstack[vstack.length - len]; + yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; + if (ranges) { + yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; + } + r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); + if (typeof r !== "undefined") { + return r; + } + if (len) { + stack = stack.slice(0, -1 * len * 2); + vstack = vstack.slice(0, -1 * len); + lstack = lstack.slice(0, -1 * len); + } + stack.push(this.productions_[action[1]][0]); + vstack.push(yyval.$); + lstack.push(yyval._$); + newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; + stack.push(newState); + break; + case 3: + return true; + } + } + return true; +} +}; +/* Jison generated lexer */ +var lexer = (function(){ +var lexer = ({EOF:1, +parseError:function parseError(str, hash) { + if (this.yy.parser) { + this.yy.parser.parseError(str, hash); + } else { + throw new Error(str); + } + }, +setInput:function (input) { + this._input = input; + this._more = this._less = this.done = false; + this.yylineno = this.yyleng = 0; + this.yytext = this.matched = this.match = ''; + this.conditionStack = ['INITIAL']; + this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0}; + if (this.options.ranges) this.yylloc.range = [0,0]; + this.offset = 0; + return this; + }, +input:function () { + var ch = this._input[0]; + this.yytext += ch; + this.yyleng++; + this.offset++; + this.match += ch; + this.matched += ch; + var lines = ch.match(/(?:\r\n?|\n).*/g); + if (lines) { + this.yylineno++; + this.yylloc.last_line++; + } else { + this.yylloc.last_column++; + } + if (this.options.ranges) this.yylloc.range[1]++; + + this._input = this._input.slice(1); + return ch; + }, +unput:function (ch) { + var len = ch.length; + var lines = ch.split(/(?:\r\n?|\n)/g); + + this._input = ch + this._input; + this.yytext = this.yytext.substr(0, this.yytext.length-len-1); + //this.yyleng -= len; + this.offset -= len; + var oldLines = this.match.split(/(?:\r\n?|\n)/g); + this.match = this.match.substr(0, this.match.length-1); + this.matched = this.matched.substr(0, this.matched.length-1); + + if (lines.length-1) this.yylineno -= lines.length-1; + var r = this.yylloc.range; + + this.yylloc = {first_line: this.yylloc.first_line, + last_line: this.yylineno+1, + first_column: this.yylloc.first_column, + last_column: lines ? + (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length: + this.yylloc.first_column - len + }; + + if (this.options.ranges) { + this.yylloc.range = [r[0], r[0] + this.yyleng - len]; + } + return this; + }, +more:function () { + this._more = true; + return this; + }, +less:function (n) { + this.unput(this.match.slice(n)); + }, +pastInput:function () { + var past = this.matched.substr(0, this.matched.length - this.match.length); + return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); + }, +upcomingInput:function () { + var next = this.match; + if (next.length < 20) { + next += this._input.substr(0, 20-next.length); + } + return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); + }, +showPosition:function () { + var pre = this.pastInput(); + var c = new Array(pre.length + 1).join("-"); + return pre + this.upcomingInput() + "\n" + c+"^"; + }, +next:function () { + if (this.done) { + return this.EOF; + } + if (!this._input) this.done = true; + + var token, + match, + tempMatch, + index, + col, + lines; + if (!this._more) { + this.yytext = ''; + this.match = ''; + } + var rules = this._currentRules(); + for (var i=0;i < rules.length; i++) { + tempMatch = this._input.match(this.rules[rules[i]]); + if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { + match = tempMatch; + index = i; + if (!this.options.flex) break; + } + } + if (match) { + lines = match[0].match(/(?:\r\n?|\n).*/g); + if (lines) this.yylineno += lines.length; + this.yylloc = {first_line: this.yylloc.last_line, + last_line: this.yylineno+1, + first_column: this.yylloc.last_column, + last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length}; + this.yytext += match[0]; + this.match += match[0]; + this.matches = match; + this.yyleng = this.yytext.length; + if (this.options.ranges) { + this.yylloc.range = [this.offset, this.offset += this.yyleng]; + } + this._more = false; + this._input = this._input.slice(match[0].length); + this.matched += match[0]; + token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]); + if (this.done && this._input) this.done = false; + if (token) return token; + else return; + } + if (this._input === "") { + return this.EOF; + } else { + return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), + {text: "", token: null, line: this.yylineno}); + } + }, +lex:function lex() { + var r = this.next(); + if (typeof r !== 'undefined') { + return r; + } else { + return this.lex(); + } + }, +begin:function begin(condition) { + this.conditionStack.push(condition); + }, +popState:function popState() { + return this.conditionStack.pop(); + }, +_currentRules:function _currentRules() { + return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules; + }, +topState:function () { + return this.conditionStack[this.conditionStack.length-2]; + }, +pushState:function begin(condition) { + this.begin(condition); + }}); +lexer.options = {}; +lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { + +var YYSTATE=YY_START +switch($avoiding_name_collisions) { +case 0: yy_.yytext = "\\"; return 14; +break; +case 1: + if(yy_.yytext.slice(-1) !== "\\") this.begin("mu"); + if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu"); + if(yy_.yytext) return 14; + +break; +case 2: return 14; +break; +case 3: + if(yy_.yytext.slice(-1) !== "\\") this.popState(); + if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1); + return 14; + +break; +case 4: yy_.yytext = yy_.yytext.substr(0, yy_.yyleng-4); this.popState(); return 15; +break; +case 5: return 25; +break; +case 6: return 16; +break; +case 7: return 20; +break; +case 8: return 19; +break; +case 9: return 19; +break; +case 10: return 23; +break; +case 11: return 22; +break; +case 12: this.popState(); this.begin('com'); +break; +case 13: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15; +break; +case 14: return 22; +break; +case 15: return 37; +break; +case 16: return 36; +break; +case 17: return 36; +break; +case 18: return 40; +break; +case 19: /*ignore whitespace*/ +break; +case 20: this.popState(); return 24; +break; +case 21: this.popState(); return 18; +break; +case 22: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 31; +break; +case 23: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\'/g,"'"); return 31; +break; +case 24: return 38; +break; +case 25: return 33; +break; +case 26: return 33; +break; +case 27: return 32; +break; +case 28: return 36; +break; +case 29: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 36; +break; +case 30: return 'INVALID'; +break; +case 31: return 5; +break; +} +}; +lexer.rules = [/^(?:\\\\(?=(\{\{)))/,/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:[\s\S]*?--\}\})/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{!--)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[}\/ ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:-?[0-9]+(?=[}\s]))/,/^(?:[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/]; +lexer.conditions = {"mu":{"rules":[5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31],"inclusive":false},"emu":{"rules":[3],"inclusive":false},"com":{"rules":[4],"inclusive":false},"INITIAL":{"rules":[0,1,2,31],"inclusive":true}}; +return lexer;})() +parser.lexer = lexer; +function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser; +return new Parser; +})();; +// lib/handlebars/compiler/base.js + +Handlebars.Parser = handlebars; + +Handlebars.parse = function(input) { + + // Just return if an already-compile AST was passed in. + if(input.constructor === Handlebars.AST.ProgramNode) { return input; } + + Handlebars.Parser.yy = Handlebars.AST; + return Handlebars.Parser.parse(input); +}; +; +// lib/handlebars/compiler/ast.js +Handlebars.AST = {}; + +Handlebars.AST.ProgramNode = function(statements, inverse) { + this.type = "program"; + this.statements = statements; + if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); } +}; + +Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) { + this.type = "mustache"; + this.escaped = !unescaped; + this.hash = hash; + + var id = this.id = rawParams[0]; + var params = this.params = rawParams.slice(1); + + // a mustache is an eligible helper if: + // * its id is simple (a single part, not `this` or `..`) + var eligibleHelper = this.eligibleHelper = id.isSimple; + + // a mustache is definitely a helper if: + // * it is an eligible helper, and + // * it has at least one parameter or hash segment + this.isHelper = eligibleHelper && (params.length || hash); + + // if a mustache is an eligible helper but not a definite + // helper, it is ambiguous, and will be resolved in a later + // pass or at runtime. +}; + +Handlebars.AST.PartialNode = function(partialName, context) { + this.type = "partial"; + this.partialName = partialName; + this.context = context; +}; + +Handlebars.AST.BlockNode = function(mustache, program, inverse, close) { + var verifyMatch = function(open, close) { + if(open.original !== close.original) { + throw new Handlebars.Exception(open.original + " doesn't match " + close.original); + } + }; + + verifyMatch(mustache.id, close); + this.type = "block"; + this.mustache = mustache; + this.program = program; + this.inverse = inverse; + + if (this.inverse && !this.program) { + this.isInverse = true; + } +}; + +Handlebars.AST.ContentNode = function(string) { + this.type = "content"; + this.string = string; +}; + +Handlebars.AST.HashNode = function(pairs) { + this.type = "hash"; + this.pairs = pairs; +}; + +Handlebars.AST.IdNode = function(parts) { + this.type = "ID"; + + var original = "", + dig = [], + depth = 0; + + for(var i=0,l=parts.length; i 0) { throw new Handlebars.Exception("Invalid path: " + original); } + else if (part === "..") { depth++; } + else { this.isScoped = true; } + } + else { dig.push(part); } + } + + this.original = original; + this.parts = dig; + this.string = dig.join('.'); + this.depth = depth; + + // an ID is simple if it only has one part, and that part is not + // `..` or `this`. + this.isSimple = parts.length === 1 && !this.isScoped && depth === 0; + + this.stringModeValue = this.string; +}; + +Handlebars.AST.PartialNameNode = function(name) { + this.type = "PARTIAL_NAME"; + this.name = name.original; +}; + +Handlebars.AST.DataNode = function(id) { + this.type = "DATA"; + this.id = id; +}; + +Handlebars.AST.StringNode = function(string) { + this.type = "STRING"; + this.original = + this.string = + this.stringModeValue = string; +}; + +Handlebars.AST.IntegerNode = function(integer) { + this.type = "INTEGER"; + this.original = + this.integer = integer; + this.stringModeValue = Number(integer); +}; + +Handlebars.AST.BooleanNode = function(bool) { + this.type = "BOOLEAN"; + this.bool = bool; + this.stringModeValue = bool === "true"; +}; + +Handlebars.AST.CommentNode = function(comment) { + this.type = "comment"; + this.comment = comment; +}; +; +// lib/handlebars/utils.js + +var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; + +Handlebars.Exception = function(message) { + var tmp = Error.prototype.constructor.apply(this, arguments); + + // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. + for (var idx = 0; idx < errorProps.length; idx++) { + this[errorProps[idx]] = tmp[errorProps[idx]]; + } +}; +Handlebars.Exception.prototype = new Error(); + +// Build out our basic SafeString type +Handlebars.SafeString = function(string) { + this.string = string; +}; +Handlebars.SafeString.prototype.toString = function() { + return this.string.toString(); +}; + +var escape = { + "&": "&", + "<": "<", + ">": ">", + '"': """, + "'": "'", + "`": "`" +}; + +var badChars = /[&<>"'`]/g; +var possible = /[&<>"'`]/; + +var escapeChar = function(chr) { + return escape[chr] || "&"; +}; + +Handlebars.Utils = { + extend: function(obj, value) { + for(var key in value) { + if(value.hasOwnProperty(key)) { + obj[key] = value[key]; + } + } + }, + + escapeExpression: function(string) { + // don't escape SafeStrings, since they're already safe + if (string instanceof Handlebars.SafeString) { + return string.toString(); + } else if (string == null || string === false) { + return ""; + } + + // Force a string conversion as this will be done by the append regardless and + // the regex test will do this transparently behind the scenes, causing issues if + // an object's to string has escaped characters in it. + string = string.toString(); + + if(!possible.test(string)) { return string; } + return string.replace(badChars, escapeChar); + }, + + isEmpty: function(value) { + if (!value && value !== 0) { + return true; + } else if(toString.call(value) === "[object Array]" && value.length === 0) { + return true; + } else { + return false; + } + } +}; +; +// lib/handlebars/compiler/compiler.js + +/*jshint eqnull:true*/ +var Compiler = Handlebars.Compiler = function() {}; +var JavaScriptCompiler = Handlebars.JavaScriptCompiler = function() {}; + +// the foundHelper register will disambiguate helper lookup from finding a +// function in a context. This is necessary for mustache compatibility, which +// requires that context functions in blocks are evaluated by blockHelperMissing, +// and then proceed as if the resulting value was provided to blockHelperMissing. + +Compiler.prototype = { + compiler: Compiler, + + disassemble: function() { + var opcodes = this.opcodes, opcode, out = [], params, param; + + for (var i=0, l=opcodes.length; i 0) { + this.source[1] = this.source[1] + ", " + locals.join(", "); + } + + // Generate minimizer alias mappings + if (!this.isChild) { + for (var alias in this.context.aliases) { + if (this.context.aliases.hasOwnProperty(alias)) { + this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias]; + } + } + } + + if (this.source[1]) { + this.source[1] = "var " + this.source[1].substring(2) + ";"; + } + + // Merge children + if (!this.isChild) { + this.source[1] += '\n' + this.context.programs.join('\n') + '\n'; + } + + if (!this.environment.isSimple) { + this.source.push("return buffer;"); + } + + var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"]; + + for(var i=0, l=this.environment.depths.list.length; i this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); } + return this.topStackName(); + }, + topStackName: function() { + return "stack" + this.stackSlot; + }, + flushInline: function() { + var inlineStack = this.inlineStack; + if (inlineStack.length) { + this.inlineStack = []; + for (var i = 0, len = inlineStack.length; i < len; i++) { + var entry = inlineStack[i]; + if (entry instanceof Literal) { + this.compileStack.push(entry); + } else { + this.pushStack(entry); + } + } + } + }, + isInline: function() { + return this.inlineStack.length; + }, + + popStack: function(wrapped) { + var inline = this.isInline(), + item = (inline ? this.inlineStack : this.compileStack).pop(); + + if (!wrapped && (item instanceof Literal)) { + return item.value; + } else { + if (!inline) { + this.stackSlot--; + } + return item; + } + }, + + topStack: function(wrapped) { + var stack = (this.isInline() ? this.inlineStack : this.compileStack), + item = stack[stack.length - 1]; + + if (!wrapped && (item instanceof Literal)) { + return item.value; + } else { + return item; + } + }, + + quotedString: function(str) { + return '"' + str + .replace(/\\/g, '\\\\') + .replace(/"/g, '\\"') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4 + .replace(/\u2029/g, '\\u2029') + '"'; + }, + + setupHelper: function(paramSize, name, missingParams) { + var params = []; + this.setupParams(paramSize, params, missingParams); + var foundHelper = this.nameLookup('helpers', name, 'helper'); + + return { + params: params, + name: foundHelper, + callParams: ["depth0"].concat(params).join(", "), + helperMissingParams: missingParams && ["depth0", this.quotedString(name)].concat(params).join(", ") + }; + }, + + // the params and contexts arguments are passed in arrays + // to fill in + setupParams: function(paramSize, params, useRegister) { + var options = [], contexts = [], types = [], param, inverse, program; + + options.push("hash:" + this.popStack()); + + inverse = this.popStack(); + program = this.popStack(); + + // Avoid setting fn and inverse if neither are set. This allows + // helpers to do a check for `if (options.fn)` + if (program || inverse) { + if (!program) { + this.context.aliases.self = "this"; + program = "self.noop"; + } + + if (!inverse) { + this.context.aliases.self = "this"; + inverse = "self.noop"; + } + + options.push("inverse:" + inverse); + options.push("fn:" + program); + } + + for(var i=0; i 0) { - return Handlebars.helpers.each(context, options); - } else { - return inverse(this); - } - } else { - return fn(context); - } -}); - -Handlebars.K = function() {}; - -Handlebars.createFrame = Object.create || function(object) { - Handlebars.K.prototype = object; - var obj = new Handlebars.K(); - Handlebars.K.prototype = null; - return obj; -}; - -Handlebars.registerHelper('each', function(context, options) { - var fn = options.fn, inverse = options.inverse; - var ret = "", data; - - if (options.data) { - data = Handlebars.createFrame(options.data); - } - - if(context && context.length > 0) { - for(var i=0, j=context.length; i 2) { - expected.push("'" + this.terminals_[p] + "'"); - } - if (this.lexer.showPosition) { - errStr = "Parse error on line " + (yylineno + 1) + ":\n" + this.lexer.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'"; - } else { - errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == 1?"end of input":"'" + (this.terminals_[symbol] || symbol) + "'"); - } - this.parseError(errStr, {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected}); - } - } - if (action[0] instanceof Array && action.length > 1) { - throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol); - } - switch (action[0]) { - case 1: - stack.push(symbol); - vstack.push(this.lexer.yytext); - lstack.push(this.lexer.yylloc); - stack.push(action[1]); - symbol = null; - if (!preErrorSymbol) { - yyleng = this.lexer.yyleng; - yytext = this.lexer.yytext; - yylineno = this.lexer.yylineno; - yyloc = this.lexer.yylloc; - if (recovering > 0) - recovering--; - } else { - symbol = preErrorSymbol; - preErrorSymbol = null; - } - break; - case 2: - len = this.productions_[action[1]][1]; - yyval.$ = vstack[vstack.length - len]; - yyval._$ = {first_line: lstack[lstack.length - (len || 1)].first_line, last_line: lstack[lstack.length - 1].last_line, first_column: lstack[lstack.length - (len || 1)].first_column, last_column: lstack[lstack.length - 1].last_column}; - if (ranges) { - yyval._$.range = [lstack[lstack.length - (len || 1)].range[0], lstack[lstack.length - 1].range[1]]; - } - r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack); - if (typeof r !== "undefined") { - return r; - } - if (len) { - stack = stack.slice(0, -1 * len * 2); - vstack = vstack.slice(0, -1 * len); - lstack = lstack.slice(0, -1 * len); - } - stack.push(this.productions_[action[1]][0]); - vstack.push(yyval.$); - lstack.push(yyval._$); - newState = table[stack[stack.length - 2]][stack[stack.length - 1]]; - stack.push(newState); - break; - case 3: - return true; - } - } - return true; -} -}; -/* Jison generated lexer */ -var lexer = (function(){ -var lexer = ({EOF:1, -parseError:function parseError(str, hash) { - if (this.yy.parser) { - this.yy.parser.parseError(str, hash); - } else { - throw new Error(str); - } - }, -setInput:function (input) { - this._input = input; - this._more = this._less = this.done = false; - this.yylineno = this.yyleng = 0; - this.yytext = this.matched = this.match = ''; - this.conditionStack = ['INITIAL']; - this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0}; - if (this.options.ranges) this.yylloc.range = [0,0]; - this.offset = 0; - return this; - }, -input:function () { - var ch = this._input[0]; - this.yytext += ch; - this.yyleng++; - this.offset++; - this.match += ch; - this.matched += ch; - var lines = ch.match(/(?:\r\n?|\n).*/g); - if (lines) { - this.yylineno++; - this.yylloc.last_line++; - } else { - this.yylloc.last_column++; - } - if (this.options.ranges) this.yylloc.range[1]++; - - this._input = this._input.slice(1); - return ch; - }, -unput:function (ch) { - var len = ch.length; - var lines = ch.split(/(?:\r\n?|\n)/g); - - this._input = ch + this._input; - this.yytext = this.yytext.substr(0, this.yytext.length-len-1); - //this.yyleng -= len; - this.offset -= len; - var oldLines = this.match.split(/(?:\r\n?|\n)/g); - this.match = this.match.substr(0, this.match.length-1); - this.matched = this.matched.substr(0, this.matched.length-1); - - if (lines.length-1) this.yylineno -= lines.length-1; - var r = this.yylloc.range; - - this.yylloc = {first_line: this.yylloc.first_line, - last_line: this.yylineno+1, - first_column: this.yylloc.first_column, - last_column: lines ? - (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length: - this.yylloc.first_column - len - }; - - if (this.options.ranges) { - this.yylloc.range = [r[0], r[0] + this.yyleng - len]; - } - return this; - }, -more:function () { - this._more = true; - return this; - }, -less:function (n) { - this.unput(this.match.slice(n)); - }, -pastInput:function () { - var past = this.matched.substr(0, this.matched.length - this.match.length); - return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, ""); - }, -upcomingInput:function () { - var next = this.match; - if (next.length < 20) { - next += this._input.substr(0, 20-next.length); - } - return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, ""); - }, -showPosition:function () { - var pre = this.pastInput(); - var c = new Array(pre.length + 1).join("-"); - return pre + this.upcomingInput() + "\n" + c+"^"; - }, -next:function () { - if (this.done) { - return this.EOF; - } - if (!this._input) this.done = true; - - var token, - match, - tempMatch, - index, - col, - lines; - if (!this._more) { - this.yytext = ''; - this.match = ''; - } - var rules = this._currentRules(); - for (var i=0;i < rules.length; i++) { - tempMatch = this._input.match(this.rules[rules[i]]); - if (tempMatch && (!match || tempMatch[0].length > match[0].length)) { - match = tempMatch; - index = i; - if (!this.options.flex) break; - } - } - if (match) { - lines = match[0].match(/(?:\r\n?|\n).*/g); - if (lines) this.yylineno += lines.length; - this.yylloc = {first_line: this.yylloc.last_line, - last_line: this.yylineno+1, - first_column: this.yylloc.last_column, - last_column: lines ? lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length}; - this.yytext += match[0]; - this.match += match[0]; - this.matches = match; - this.yyleng = this.yytext.length; - if (this.options.ranges) { - this.yylloc.range = [this.offset, this.offset += this.yyleng]; - } - this._more = false; - this._input = this._input.slice(match[0].length); - this.matched += match[0]; - token = this.performAction.call(this, this.yy, this, rules[index],this.conditionStack[this.conditionStack.length-1]); - if (this.done && this._input) this.done = false; - if (token) return token; - else return; - } - if (this._input === "") { - return this.EOF; - } else { - return this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(), - {text: "", token: null, line: this.yylineno}); - } - }, -lex:function lex() { - var r = this.next(); - if (typeof r !== 'undefined') { - return r; - } else { - return this.lex(); - } - }, -begin:function begin(condition) { - this.conditionStack.push(condition); - }, -popState:function popState() { - return this.conditionStack.pop(); - }, -_currentRules:function _currentRules() { - return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules; - }, -topState:function () { - return this.conditionStack[this.conditionStack.length-2]; - }, -pushState:function begin(condition) { - this.begin(condition); - }}); -lexer.options = {}; -lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) { - -var YYSTATE=YY_START -switch($avoiding_name_collisions) { -case 0: - if(yy_.yytext.slice(-1) !== "\\") this.begin("mu"); - if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1), this.begin("emu"); - if(yy_.yytext) return 14; - -break; -case 1: return 14; -break; -case 2: - if(yy_.yytext.slice(-1) !== "\\") this.popState(); - if(yy_.yytext.slice(-1) === "\\") yy_.yytext = yy_.yytext.substr(0,yy_.yyleng-1); - return 14; - -break; -case 3: return 24; -break; -case 4: return 16; -break; -case 5: return 20; -break; -case 6: return 19; -break; -case 7: return 19; -break; -case 8: return 23; -break; -case 9: return 23; -break; -case 10: yy_.yytext = yy_.yytext.substr(3,yy_.yyleng-5); this.popState(); return 15; -break; -case 11: return 22; -break; -case 12: return 35; -break; -case 13: return 34; -break; -case 14: return 34; -break; -case 15: return 37; -break; -case 16: /*ignore whitespace*/ -break; -case 17: this.popState(); return 18; -break; -case 18: this.popState(); return 18; -break; -case 19: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 29; -break; -case 20: yy_.yytext = yy_.yytext.substr(1,yy_.yyleng-2).replace(/\\"/g,'"'); return 29; -break; -case 21: yy_.yytext = yy_.yytext.substr(1); return 27; -break; -case 22: return 31; -break; -case 23: return 31; -break; -case 24: return 30; -break; -case 25: return 34; -break; -case 26: yy_.yytext = yy_.yytext.substr(1, yy_.yyleng-2); return 34; -break; -case 27: return 'INVALID'; -break; -case 28: return 5; -break; -} -}; -lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/,/^(?:[^\x00]+)/,/^(?:[^\x00]{2,}?(?=(\{\{|$)))/,/^(?:\{\{>)/,/^(?:\{\{#)/,/^(?:\{\{\/)/,/^(?:\{\{\^)/,/^(?:\{\{\s*else\b)/,/^(?:\{\{\{)/,/^(?:\{\{&)/,/^(?:\{\{![\s\S]*?\}\})/,/^(?:\{\{)/,/^(?:=)/,/^(?:\.(?=[} ]))/,/^(?:\.\.)/,/^(?:[\/.])/,/^(?:\s+)/,/^(?:\}\}\})/,/^(?:\}\})/,/^(?:"(\\["]|[^"])*")/,/^(?:'(\\[']|[^'])*')/,/^(?:@[a-zA-Z]+)/,/^(?:true(?=[}\s]))/,/^(?:false(?=[}\s]))/,/^(?:[0-9]+(?=[}\s]))/,/^(?:[a-zA-Z0-9_$-]+(?=[=}\s\/.]))/,/^(?:\[[^\]]*\])/,/^(?:.)/,/^(?:$)/]; -lexer.conditions = {"mu":{"rules":[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28],"inclusive":false},"emu":{"rules":[2],"inclusive":false},"INITIAL":{"rules":[0,1,28],"inclusive":true}}; -return lexer;})() -parser.lexer = lexer; -function Parser () { this.yy = {}; }Parser.prototype = parser;parser.Parser = Parser; -return new Parser; -})(); -if (typeof require !== 'undefined' && typeof exports !== 'undefined') { -exports.parser = handlebars; -exports.Parser = handlebars.Parser; -exports.parse = function () { return handlebars.parse.apply(handlebars, arguments); } -exports.main = function commonjsMain(args) { - if (!args[1]) - throw new Error('Usage: '+args[0]+' FILE'); - var source, cwd; - if (typeof process !== 'undefined') { - source = require('fs').readFileSync(require('path').resolve(args[1]), "utf8"); - } else { - source = require("file").path(require("file").cwd()).join(args[1]).read({charset: "utf-8"}); - } - return exports.parser.parse(source); -} -if (typeof module !== 'undefined' && require.main === module) { - exports.main(typeof process !== 'undefined' ? process.argv.slice(1) : require("system").args); -} -}; -; -// lib/handlebars/compiler/base.js -Handlebars.Parser = handlebars; - -Handlebars.parse = function(string) { - Handlebars.Parser.yy = Handlebars.AST; - return Handlebars.Parser.parse(string); -}; - -Handlebars.print = function(ast) { - return new Handlebars.PrintVisitor().accept(ast); -}; - -Handlebars.logger = { - DEBUG: 0, INFO: 1, WARN: 2, ERROR: 3, level: 3, - - // override in the host environment - log: function(level, str) {} -}; - -Handlebars.log = function(level, str) { Handlebars.logger.log(level, str); }; -; -// lib/handlebars/compiler/ast.js -(function() { - - Handlebars.AST = {}; - - Handlebars.AST.ProgramNode = function(statements, inverse) { - this.type = "program"; - this.statements = statements; - if(inverse) { this.inverse = new Handlebars.AST.ProgramNode(inverse); } - }; - - Handlebars.AST.MustacheNode = function(rawParams, hash, unescaped) { - this.type = "mustache"; - this.escaped = !unescaped; - this.hash = hash; - - var id = this.id = rawParams[0]; - var params = this.params = rawParams.slice(1); - - // a mustache is an eligible helper if: - // * its id is simple (a single part, not `this` or `..`) - var eligibleHelper = this.eligibleHelper = id.isSimple; - - // a mustache is definitely a helper if: - // * it is an eligible helper, and - // * it has at least one parameter or hash segment - this.isHelper = eligibleHelper && (params.length || hash); - - // if a mustache is an eligible helper but not a definite - // helper, it is ambiguous, and will be resolved in a later - // pass or at runtime. - }; - - Handlebars.AST.PartialNode = function(id, context) { - this.type = "partial"; - - // TODO: disallow complex IDs - - this.id = id; - this.context = context; - }; - - var verifyMatch = function(open, close) { - if(open.original !== close.original) { - throw new Handlebars.Exception(open.original + " doesn't match " + close.original); - } - }; - - Handlebars.AST.BlockNode = function(mustache, program, inverse, close) { - verifyMatch(mustache.id, close); - this.type = "block"; - this.mustache = mustache; - this.program = program; - this.inverse = inverse; - - if (this.inverse && !this.program) { - this.isInverse = true; - } - }; - - Handlebars.AST.ContentNode = function(string) { - this.type = "content"; - this.string = string; - }; - - Handlebars.AST.HashNode = function(pairs) { - this.type = "hash"; - this.pairs = pairs; - }; - - Handlebars.AST.IdNode = function(parts) { - this.type = "ID"; - this.original = parts.join("."); - - var dig = [], depth = 0; - - for(var i=0,l=parts.length; i": ">", - '"': """, - "'": "'", - "`": "`" - }; - - var badChars = /[&<>"'`]/g; - var possible = /[&<>"'`]/; - - var escapeChar = function(chr) { - return escape[chr] || "&"; - }; - - Handlebars.Utils = { - escapeExpression: function(string) { - // don't escape SafeStrings, since they're already safe - if (string instanceof Handlebars.SafeString) { - return string.toString(); - } else if (string == null || string === false) { - return ""; - } - - if(!possible.test(string)) { return string; } - return string.replace(badChars, escapeChar); - }, - - isEmpty: function(value) { - if (typeof value === "undefined") { - return true; - } else if (value === null) { - return true; - } else if (value === false) { - return true; - } else if(Object.prototype.toString.call(value) === "[object Array]" && value.length === 0) { - return true; - } else { - return false; - } - } - }; -})();; -// lib/handlebars/compiler/compiler.js - -/*jshint eqnull:true*/ -Handlebars.Compiler = function() {}; -Handlebars.JavaScriptCompiler = function() {}; - -(function(Compiler, JavaScriptCompiler) { - // the foundHelper register will disambiguate helper lookup from finding a - // function in a context. This is necessary for mustache compatibility, which - // requires that context functions in blocks are evaluated by blockHelperMissing, - // and then proceed as if the resulting value was provided to blockHelperMissing. - - Compiler.prototype = { - compiler: Compiler, - - disassemble: function() { - var opcodes = this.opcodes, opcode, out = [], params, param; - - for (var i=0, l=opcodes.length; i 0) { - this.source[1] = this.source[1] + ", " + locals.join(", "); - } - - // Generate minimizer alias mappings - if (!this.isChild) { - var aliases = []; - for (var alias in this.context.aliases) { - this.source[1] = this.source[1] + ', ' + alias + '=' + this.context.aliases[alias]; - } - } - - if (this.source[1]) { - this.source[1] = "var " + this.source[1].substring(2) + ";"; - } - - // Merge children - if (!this.isChild) { - this.source[1] += '\n' + this.context.programs.join('\n') + '\n'; - } - - if (!this.environment.isSimple) { - this.source.push("return buffer;"); - } - - var params = this.isChild ? ["depth0", "data"] : ["Handlebars", "depth0", "helpers", "partials", "data"]; - - for(var i=0, l=this.environment.depths.list.length; i this.stackVars.length) { this.stackVars.push("stack" + this.stackSlot); } - return "stack" + this.stackSlot; - }, - - popStack: function() { - var item = this.compileStack.pop(); - - if (item instanceof Literal) { - return item.value; - } else { - this.stackSlot--; - return item; - } - }, - - topStack: function() { - var item = this.compileStack[this.compileStack.length - 1]; - - if (item instanceof Literal) { - return item.value; - } else { - return item; - } - }, - - quotedString: function(str) { - return '"' + str - .replace(/\\/g, '\\\\') - .replace(/"/g, '\\"') - .replace(/\n/g, '\\n') - .replace(/\r/g, '\\r') + '"'; - }, - - setupHelper: function(paramSize, name) { - var params = []; - this.setupParams(paramSize, params); - var foundHelper = this.nameLookup('helpers', name, 'helper'); - - return { - params: params, - name: foundHelper, - callParams: ["depth0"].concat(params).join(", "), - helperMissingParams: ["depth0", this.quotedString(name)].concat(params).join(", ") - }; - }, - - // the params and contexts arguments are passed in arrays - // to fill in - setupParams: function(paramSize, params) { - var options = [], contexts = [], param, inverse, program; - - options.push("hash:" + this.popStack()); - - inverse = this.popStack(); - program = this.popStack(); - - // Avoid setting fn and inverse if neither are set. This allows - // helpers to do a check for `if (options.fn)` - if (program || inverse) { - if (!program) { - this.context.aliases.self = "this"; - program = "self.noop"; - } - - if (!inverse) { - this.context.aliases.self = "this"; - inverse = "self.noop"; - } - - options.push("inverse:" + inverse); - options.push("fn:" + program); - } - - for(var i=0; i= 0; i--) { + if (parts[i] === 'node_modules') continue; + var dir = parts.slice(0, i + 1).join('/') + '/node_modules'; + dirs.push(dir); + } + + return dirs; + } + }; +})(); + +require.alias = function (from, to) { + var path = require.modules.path(); + var res = null; + try { + res = require.resolve(from + '/package.json', '/'); + } + catch (err) { + res = require.resolve(from, '/'); + } + var basedir = path.dirname(res); + + var keys = (Object.keys || function (obj) { + var res = []; + for (var key in obj) res.push(key) + return res; + })(require.modules); + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + if (key.slice(0, basedir.length + 1) === basedir + '/') { + var f = key.slice(basedir.length); + require.modules[to + f] = require.modules[basedir + f]; + } + else if (key === basedir) { + require.modules[to] = require.modules[basedir]; + } + } +}; + +require.define = function (filename, fn) { + var dirname = require._core[filename] + ? '' + : require.modules.path().dirname(filename) + ; + + var require_ = function (file) { + return require(file, dirname) + }; + require_.resolve = function (name) { + return require.resolve(name, dirname); + }; + require_.modules = require.modules; + require_.define = require.define; + var module_ = { exports : {} }; + + require.modules[filename] = function () { + require.modules[filename]._cached = module_.exports; + fn.call( + module_.exports, + require_, + module_, + module_.exports, + dirname, + filename + ); + require.modules[filename]._cached = module_.exports; + return module_.exports; + }; +}; + +if (typeof process === 'undefined') process = {}; + +if (!process.nextTick) process.nextTick = (function () { + var queue = []; + var canPost = typeof window !== 'undefined' + && window.postMessage && window.addEventListener + ; + + if (canPost) { + window.addEventListener('message', function (ev) { + if (ev.source === window && ev.data === 'browserify-tick') { + ev.stopPropagation(); + if (queue.length > 0) { + var fn = queue.shift(); + fn(); + } + } + }, true); + } + + return function (fn) { + if (canPost) { + queue.push(fn); + window.postMessage('browserify-tick', '*'); + } + else setTimeout(fn, 0); + }; +})(); + +if (!process.title) process.title = 'browser'; + +if (!process.binding) process.binding = function (name) { + if (name === 'evals') return require('vm') + else throw new Error('No such module') +}; + +if (!process.cwd) process.cwd = function () { return '.' }; + +require.define("path", function (require, module, exports, __dirname, __filename) { + function filter (xs, fn) { + var res = []; + for (var i = 0; i < xs.length; i++) { + if (fn(xs[i], i, xs)) res.push(xs[i]); + } + return res; +} + +// resolves . and .. elements in a path array with directory names there +// must be no slashes, empty elements, or device names (c:\) in the array +// (so also no leading and trailing slashes - it does not distinguish +// relative and absolute paths) +function normalizeArray(parts, allowAboveRoot) { + // if the path tries to go above the root, `up` ends up > 0 + var up = 0; + for (var i = parts.length; i >= 0; i--) { + var last = parts[i]; + if (last == '.') { + parts.splice(i, 1); + } else if (last === '..') { + parts.splice(i, 1); + up++; + } else if (up) { + parts.splice(i, 1); + up--; + } + } + + // if the path is allowed to go above the root, restore leading ..s + if (allowAboveRoot) { + for (; up--; up) { + parts.unshift('..'); + } + } + + return parts; +} + +// Regex to split a filename into [*, dir, basename, ext] +// posix version +var splitPathRe = /^(.+\/(?!$)|\/)?((?:.+?)?(\.[^.]*)?)$/; + +// path.resolve([from ...], to) +// posix version +exports.resolve = function() { +var resolvedPath = '', + resolvedAbsolute = false; + +for (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) { + var path = (i >= 0) + ? arguments[i] + : process.cwd(); + + // Skip empty and invalid entries + if (typeof path !== 'string' || !path) { + continue; + } + + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path.charAt(0) === '/'; +} + +// At this point the path should be resolved to a full absolute path, but +// handle relative paths to be safe (might happen when process.cwd() fails) + +// Normalize the path +resolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) { + return !!p; + }), !resolvedAbsolute).join('/'); + + return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.'; +}; + +// path.normalize(path) +// posix version +exports.normalize = function(path) { +var isAbsolute = path.charAt(0) === '/', + trailingSlash = path.slice(-1) === '/'; + +// Normalize the path +path = normalizeArray(filter(path.split('/'), function(p) { + return !!p; + }), !isAbsolute).join('/'); + + if (!path && !isAbsolute) { + path = '.'; + } + if (path && trailingSlash) { + path += '/'; + } + + return (isAbsolute ? '/' : '') + path; +}; + + +// posix version +exports.join = function() { + var paths = Array.prototype.slice.call(arguments, 0); + return exports.normalize(filter(paths, function(p, index) { + return p && typeof p === 'string'; + }).join('/')); +}; + + +exports.dirname = function(path) { + var dir = splitPathRe.exec(path)[1] || ''; + var isWindows = false; + if (!dir) { + // No dirname + return '.'; + } else if (dir.length === 1 || + (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) { + // It is just a slash or a drive letter with a slash + return dir; + } else { + // It is a full dirname, strip trailing slash + return dir.substring(0, dir.length - 1); + } +}; + + +exports.basename = function(path, ext) { + var f = splitPathRe.exec(path)[2] || ''; + // TODO: make this comparison case-insensitive on windows? + if (ext && f.substr(-1 * ext.length) === ext) { + f = f.substr(0, f.length - ext.length); + } + return f; +}; + + +exports.extname = function(path) { + return splitPathRe.exec(path)[3] || ''; +}; + +}); + +require.define("/shred.js", function (require, module, exports, __dirname, __filename) { + // Shred is an HTTP client library intended to simplify the use of Node's +// built-in HTTP library. In particular, we wanted to make it easier to interact +// with HTTP-based APIs. +// +// See the [examples](./examples.html) for more details. + +// Ax is a nice logging library we wrote. You can use any logger, providing it +// has `info`, `warn`, `debug`, and `error` methods that take a string. +var Ax = require("ax") + , CookieJarLib = require( "cookiejar" ) + , CookieJar = CookieJarLib.CookieJar +; + +// Shred takes some options, including a logger and request defaults. + +var Shred = function(options) { + options = (options||{}); + this.agent = options.agent; + this.defaults = options.defaults||{}; + this.log = options.logger||(new Ax({ level: "info" })); + this._sharedCookieJar = new CookieJar(); + this.logCurl = options.logCurl || false; +}; + +// Most of the real work is done in the request and reponse classes. + +Shred.Request = require("./shred/request"); +Shred.Response = require("./shred/response"); + +// The `request` method kicks off a new request, instantiating a new `Request` +// object and passing along whatever default options we were given. + +Shred.prototype = { + request: function(options) { + options.logger = this.log; + options.logCurl = options.logCurl || this.logCurl; + options.cookieJar = ( 'cookieJar' in options ) ? options.cookieJar : this._sharedCookieJar; // let them set cookieJar = null + options.agent = options.agent || this.agent; + // fill in default options + for (var key in this.defaults) { + if (this.defaults.hasOwnProperty(key) && !options[key]) { + options[key] = this.defaults[key] + } + } + return new Shred.Request(options); + } +}; + +// Define a bunch of convenience methods so that you don't have to include +// a `method` property in your request options. + +"get put post delete".split(" ").forEach(function(method) { + Shred.prototype[method] = function(options) { + options.method = method; + return this.request(options); + }; +}); + + +module.exports = Shred; + +}); + +require.define("/node_modules/ax/package.json", function (require, module, exports, __dirname, __filename) { + module.exports = {"main":"./lib/ax.js"} +}); + +require.define("/node_modules/ax/lib/ax.js", function (require, module, exports, __dirname, __filename) { + var inspect = require("util").inspect + , fs = require("fs") +; + + +// this is a quick-and-dirty logger. there are other nicer loggers out there +// but the ones i found were also somewhat involved. this one has a Ruby +// logger type interface +// +// we can easily replace this, provide the info, debug, etc. methods are the +// same. or, we can change Haiku to use a more standard node.js interface + +var format = function(level,message) { + var debug = (level=="debug"||level=="error"); + if (!message) { return message.toString(); } + if (typeof(message) == "object") { + if (message instanceof Error && debug) { + return message.stack; + } else { + return inspect(message); + } + } else { + return message.toString(); + } +}; + +var noOp = function(message) { return this; } +var makeLogger = function(level,fn) { + return function(message) { + this.stream.write(this.format(level, message)+"\n"); + return this; + } +}; + +var Logger = function(options) { + var logger = this; + var options = options||{}; + + // Default options + options.level = options.level || "info"; + options.timestamp = options.timestamp || true; + options.prefix = options.prefix || ""; + logger.options = options; + + // Allows a prefix to be added to the message. + // + // var logger = new Ax({ module: 'Haiku' }) + // logger.warn('this is going to be awesome!'); + // //=> Haiku: this is going to be awesome! + // + if (logger.options.module){ + logger.options.prefix = logger.options.module; + } + + // Write to stderr or a file + if (logger.options.file){ + logger.stream = fs.createWriteStream(logger.options.file, {"flags": "a"}); + } else { + if(process.title === "node") + logger.stream = process.stderr; + else if(process.title === "browser") + logger.stream = function () { + // Work around weird console context issue: http://code.google.com/p/chromium/issues/detail?id=48662 + return console[logger.options.level].apply(console, arguments); + }; + } + + switch(logger.options.level){ + case 'debug': + ['debug', 'info', 'warn'].forEach(function (level) { + logger[level] = Logger.writer(level); + }); + case 'info': + ['info', 'warn'].forEach(function (level) { + logger[level] = Logger.writer(level); + }); + case 'warn': + logger.warn = Logger.writer('warn'); + } +} + +// Used to define logger methods +Logger.writer = function(level){ + return function(message){ + var logger = this; + + if(process.title === "node") + logger.stream.write(logger.format(level, message) + '\n'); + else if(process.title === "browser") + logger.stream(logger.format(level, message) + '\n'); + + }; +} + + +Logger.prototype = { + info: function(){}, + debug: function(){}, + warn: function(){}, + error: Logger.writer('error'), + format: function(level, message){ + if (! message) return ''; + + var logger = this + , prefix = logger.options.prefix + , timestamp = logger.options.timestamp ? " " + (new Date().toISOString()) : "" + ; + + return (prefix + timestamp + ": " + message); + } +}; + +module.exports = Logger; + +}); + +require.define("util", function (require, module, exports, __dirname, __filename) { + // todo + +}); + +require.define("fs", function (require, module, exports, __dirname, __filename) { + // nothing to see here... no file methods for the browser + +}); + +require.define("/node_modules/cookiejar/package.json", function (require, module, exports, __dirname, __filename) { + module.exports = {"main":"cookiejar.js"} +}); + +require.define("/node_modules/cookiejar/cookiejar.js", function (require, module, exports, __dirname, __filename) { + exports.CookieAccessInfo=CookieAccessInfo=function CookieAccessInfo(domain,path,secure,script) { + if(this instanceof CookieAccessInfo) { + this.domain=domain||undefined; + this.path=path||"/"; + this.secure=!!secure; + this.script=!!script; + return this; + } + else { + return new CookieAccessInfo(domain,path,secure,script) + } +} + +exports.Cookie=Cookie=function Cookie(cookiestr) { + if(cookiestr instanceof Cookie) { + return cookiestr; + } + else { + if(this instanceof Cookie) { + this.name = null; + this.value = null; + this.expiration_date = Infinity; + this.path = "/"; + this.domain = null; + this.secure = false; //how to define? + this.noscript = false; //httponly + if(cookiestr) { + this.parse(cookiestr) + } + return this; + } + return new Cookie(cookiestr) + } +} + +Cookie.prototype.toString = function toString() { + var str=[this.name+"="+this.value]; + if(this.expiration_date !== Infinity) { + str.push("expires="+(new Date(this.expiration_date)).toGMTString()); + } + if(this.domain) { + str.push("domain="+this.domain); + } + if(this.path) { + str.push("path="+this.path); + } + if(this.secure) { + str.push("secure"); + } + if(this.noscript) { + str.push("httponly"); + } + return str.join("; "); +} + +Cookie.prototype.toValueString = function toValueString() { + return this.name+"="+this.value; +} + +var cookie_str_splitter=/[:](?=\s*[a-zA-Z0-9_\-]+\s*[=])/g +Cookie.prototype.parse = function parse(str) { + if(this instanceof Cookie) { + var parts=str.split(";") + , pair=parts[0].match(/([^=]+)=((?:.|\n)*)/) + , key=pair[1] + , value=pair[2]; + this.name = key; + this.value = value; + + for(var i=1;i ", request.method.toUpperCase(), + request.url].join(" ") + return [ summary, "- Headers:", headers].join("\n"); +}; + +Request.prototype.format_headers = function () { + var array = [] + var headers = this._headers + for (var key in headers) { + if (headers.hasOwnProperty(key)) { + var value = headers[key] + array.push("\t" + key + ": " + value); + } + } + return array.join("\n"); +}; + +// Allow chainable 'on's: shred.get({ ... }).on( ... ). You can pass in a +// single function, a pair (event, function), or a hash: +// { event: function, event: function } +Request.prototype.on = function (eventOrHash, listener) { + var emitter = this.emitter; + // Pass in a single argument as a function then make it the default response handler + if (arguments.length === 1 && typeof(eventOrHash) === 'function') { + emitter.on('response', eventOrHash); + } else if (arguments.length === 1 && typeof(eventOrHash) === 'object') { + for (var key in eventOrHash) { + if (eventOrHash.hasOwnProperty(key)) { + emitter.on(key, eventOrHash[key]); + } + } + } else { + emitter.on(eventOrHash, listener); + } + return this; +}; + +// Add in the header methods. Again, these ensure we don't get the same header +// multiple times with different case conventions. +HeaderMixins.gettersAndSetters(Request); + +// `processOptions` is called from the constructor to handle all the work +// associated with making sure we do our best to ensure we have a valid request. + +var processOptions = function(request,options) { + + request.log.debug("Processing request options .."); + + // We'll use `request.emitter` to manage the `on` event handlers. + request.emitter = (new Emitter); + + request.agent = options.agent; + + // Set up the handlers ... + if (options.on) { + for (var key in options.on) { + if (options.on.hasOwnProperty(key)) { + request.emitter.on(key, options.on[key]); + } + } + } + + // Make sure we were give a URL or a host + if (!options.url && !options.host) { + request.emitter.emit("request_error", + new Error("No url or url options (host, port, etc.)")); + return; + } + + // Allow for the [use of a proxy](http://www.jmarshall.com/easy/http/#proxies). + + if (options.url) { + if (options.proxy) { + request.url = options.proxy; + request.path = options.url; + } else { + request.url = options.url; + } + } + + // Set the remaining options. + request.query = options.query||options.parameters||request.query ; + request.method = options.method; + request.setHeader("user-agent",options.agent||"Shred"); + request.setHeaders(options.headers); + + if (request.cookieJar) { + var cookies = request.cookieJar.getCookies( CookieAccessInfo( request.host, request.path ) ); + if (cookies.length) { + var cookieString = request.getHeader('cookie')||''; + for (var cookieIndex = 0; cookieIndex < cookies.length; ++cookieIndex) { + if ( cookieString.length && cookieString[ cookieString.length - 1 ] != ';' ) + { + cookieString += ';'; + } + cookieString += cookies[ cookieIndex ].name + '=' + cookies[ cookieIndex ].value + ';'; + } + request.setHeader("cookie", cookieString); + } + } + + // The content entity can be set either using the `body` or `content` attributes. + if (options.body||options.content) { + request.content = options.body||options.content; + } + request.timeout = options.timeout; + +}; + +// `createRequest` is also called by the constructor, after `processOptions`. +// This actually makes the request and processes the response, so `createRequest` +// is a bit of a misnomer. + +var createRequest = function(request) { + var timeout ; + + request.log.debug("Creating request .."); + request.log.debug(request); + + var reqParams = { + host: request.host, + port: request.port, + method: request.method, + path: request.path + (request.query ? '?'+request.query : ""), + headers: request.getHeaders(), + // Node's HTTP/S modules will ignore this, but we are using the + // browserify-http module in the browser for both HTTP and HTTPS, and this + // is how you differentiate the two. + scheme: request.scheme, + // Use a provided agent. 'Undefined' is the default, which uses a global + // agent. + agent: request.agent + }; + + if (request.logCurl) { + logCurl(request); + } + + var http = request.scheme == "http" ? HTTP : HTTPS; + + // Set up the real request using the selected library. The request won't be + // sent until we call `.end()`. + request._raw = http.request(reqParams, function(response) { + request.log.debug("Received response .."); + + // We haven't timed out and we have a response, so make sure we clear the + // timeout so it doesn't fire while we're processing the response. + clearTimeout(timeout); + + // Construct a Shred `Response` object from the response. This will stream + // the response, thus the need for the callback. We can access the response + // entity safely once we're in the callback. + response = new Response(response, request, function(response) { + + // Set up some event magic. The precedence is given first to + // status-specific handlers, then to responses for a given event, and then + // finally to the more general `response` handler. In the last case, we + // need to first make sure we're not dealing with a a redirect. + var emit = function(event) { + var emitter = request.emitter; + var textStatus = STATUS_CODES[response.status] ? STATUS_CODES[response.status].toLowerCase() : null; + if (emitter.listeners(response.status).length > 0 || emitter.listeners(textStatus).length > 0) { + emitter.emit(response.status, response); + emitter.emit(textStatus, response); + } else { + if (emitter.listeners(event).length>0) { + emitter.emit(event, response); + } else if (!response.isRedirect) { + emitter.emit("response", response); + //console.warn("Request has no event listener for status code " + response.status); + } + } + }; + + // Next, check for a redirect. We simply repeat the request with the URL + // given in the `Location` header. We fire a `redirect` event. + if (response.isRedirect) { + request.log.debug("Redirecting to " + + response.getHeader("Location")); + request.url = response.getHeader("Location"); + emit("redirect"); + createRequest(request); + + // Okay, it's not a redirect. Is it an error of some kind? + } else if (response.isError) { + emit("error"); + } else { + // It looks like we're good shape. Trigger the `success` event. + emit("success"); + } + }); + }); + + // We're still setting up the request. Next, we're going to handle error cases + // where we have no response. We don't emit an error event because that event + // takes a response. We don't response handlers to have to check for a null + // value. However, we [should introduce a different event + // type](https://github.com/spire-io/shred/issues/3) for this type of error. + request._raw.on("error", function(error) { + request.emitter.emit("request_error", error); + }); + + request._raw.on("socket", function(socket) { + request.emitter.emit("socket", socket); + }); + + // TCP timeouts should also trigger the "response_error" event. + request._raw.on('socket', function () { + request._raw.socket.on('timeout', function () { + // This should trigger the "error" event on the raw request, which will + // trigger the "response_error" on the shred request. + request._raw.abort(); + }); + }); + + + // We're almost there. Next, we need to write the request entity to the + // underlying request object. + if (request.content) { + request.log.debug("Streaming body: '" + + request.content.data.slice(0,59) + "' ... "); + request._raw.write(request.content.data); + } + + // Finally, we need to set up the timeout. We do this last so that we don't + // start the clock ticking until the last possible moment. + if (request.timeout) { + timeout = setTimeout(function() { + request.log.debug("Timeout fired, aborting request ..."); + request._raw.abort(); + request.emitter.emit("timeout", request); + },request.timeout); + } + + // The `.end()` method will cause the request to fire. Technically, it might + // have already sent the headers and body. + request.log.debug("Sending request ..."); + request._raw.end(); +}; + +// Logs the curl command for the request. +var logCurl = function (req) { + var headers = req.getHeaders(); + var headerString = ""; + + for (var key in headers) { + headerString += '-H "' + key + ": " + headers[key] + '" '; + } + + var bodyString = "" + + if (req.content) { + bodyString += "-d '" + req.content.body + "' "; + } + + var query = req.query ? '?' + req.query : ""; + + console.log("curl " + + "-X " + req.method.toUpperCase() + " " + + req.scheme + "://" + req.host + ":" + req.port + req.path + query + " " + + headerString + + bodyString + ); +}; + + +module.exports = Request; + +}); + +require.define("http", function (require, module, exports, __dirname, __filename) { + // todo + +}); + +require.define("https", function (require, module, exports, __dirname, __filename) { + // todo + +}); + +require.define("/shred/parseUri.js", function (require, module, exports, __dirname, __filename) { + // parseUri 1.2.2 +// (c) Steven Levithan +// MIT License + +function parseUri (str) { + var o = parseUri.options, + m = o.parser[o.strictMode ? "strict" : "loose"].exec(str), + uri = {}, + i = 14; + + while (i--) uri[o.key[i]] = m[i] || ""; + + uri[o.q.name] = {}; + uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) { + if ($1) uri[o.q.name][$1] = $2; + }); + + return uri; +}; + +parseUri.options = { + strictMode: false, + key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"], + q: { + name: "queryKey", + parser: /(?:^|&)([^&=]*)=?([^&]*)/g + }, + parser: { + strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, + loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ + } +}; + +module.exports = parseUri; + +}); + +require.define("events", function (require, module, exports, __dirname, __filename) { + if (!process.EventEmitter) process.EventEmitter = function () {}; + +var EventEmitter = exports.EventEmitter = process.EventEmitter; +var isArray = typeof Array.isArray === 'function' + ? Array.isArray + : function (xs) { + return Object.toString.call(xs) === '[object Array]' + } +; + +// By default EventEmitters will print a warning if more than +// 10 listeners are added to it. This is a useful default which +// helps finding memory leaks. +// +// Obviously not all Emitters should be limited to 10. This function allows +// that to be increased. Set to zero for unlimited. +var defaultMaxListeners = 10; +EventEmitter.prototype.setMaxListeners = function(n) { + if (!this._events) this._events = {}; + this._events.maxListeners = n; +}; + + +EventEmitter.prototype.emit = function(type) { + // If there is no 'error' event listener then throw. + if (type === 'error') { + if (!this._events || !this._events.error || + (isArray(this._events.error) && !this._events.error.length)) + { + if (arguments[1] instanceof Error) { + throw arguments[1]; // Unhandled 'error' event + } else { + throw new Error("Uncaught, unspecified 'error' event."); + } + return false; + } + } + + if (!this._events) return false; + var handler = this._events[type]; + if (!handler) return false; + + if (typeof handler == 'function') { + switch (arguments.length) { + // fast cases + case 1: + handler.call(this); + break; + case 2: + handler.call(this, arguments[1]); + break; + case 3: + handler.call(this, arguments[1], arguments[2]); + break; + // slower + default: + var args = Array.prototype.slice.call(arguments, 1); + handler.apply(this, args); + } + return true; + + } else if (isArray(handler)) { + var args = Array.prototype.slice.call(arguments, 1); + + var listeners = handler.slice(); + for (var i = 0, l = listeners.length; i < l; i++) { + listeners[i].apply(this, args); + } + return true; + + } else { + return false; + } +}; + +// EventEmitter is defined in src/node_events.cc +// EventEmitter.prototype.emit() is also defined there. +EventEmitter.prototype.addListener = function(type, listener) { + if ('function' !== typeof listener) { + throw new Error('addListener only takes instances of Function'); + } + + if (!this._events) this._events = {}; + + // To avoid recursion in the case that type == "newListeners"! Before + // adding it to the listeners, first emit "newListeners". + this.emit('newListener', type, listener); + + if (!this._events[type]) { + // Optimize the case of one listener. Don't need the extra array object. + this._events[type] = listener; + } else if (isArray(this._events[type])) { + + // Check for listener leak + if (!this._events[type].warned) { + var m; + if (this._events.maxListeners !== undefined) { + m = this._events.maxListeners; + } else { + m = defaultMaxListeners; + } + + if (m && m > 0 && this._events[type].length > m) { + this._events[type].warned = true; + console.error('(node) warning: possible EventEmitter memory ' + + 'leak detected. %d listeners added. ' + + 'Use emitter.setMaxListeners() to increase limit.', + this._events[type].length); + console.trace(); + } + } + + // If we've already got an array, just append. + this._events[type].push(listener); + } else { + // Adding the second element, need to change to array. + this._events[type] = [this._events[type], listener]; + } + + return this; +}; + +EventEmitter.prototype.on = EventEmitter.prototype.addListener; + +EventEmitter.prototype.once = function(type, listener) { + var self = this; + self.on(type, function g() { + self.removeListener(type, g); + listener.apply(this, arguments); + }); + + return this; +}; + +EventEmitter.prototype.removeListener = function(type, listener) { + if ('function' !== typeof listener) { + throw new Error('removeListener only takes instances of Function'); + } + + // does not use listeners(), so no side effect of creating _events[type] + if (!this._events || !this._events[type]) return this; + + var list = this._events[type]; + + if (isArray(list)) { + var i = list.indexOf(listener); + if (i < 0) return this; + list.splice(i, 1); + if (list.length == 0) + delete this._events[type]; + } else if (this._events[type] === listener) { + delete this._events[type]; + } + + return this; +}; + +EventEmitter.prototype.removeAllListeners = function(type) { + // does not use listeners(), so no side effect of creating _events[type] + if (type && this._events && this._events[type]) this._events[type] = null; + return this; +}; + +EventEmitter.prototype.listeners = function(type) { + if (!this._events) this._events = {}; + if (!this._events[type]) this._events[type] = []; + if (!isArray(this._events[type])) { + this._events[type] = [this._events[type]]; + } + return this._events[type]; +}; + +}); + +require.define("/node_modules/sprintf/package.json", function (require, module, exports, __dirname, __filename) { + module.exports = {"main":"./lib/sprintf"} +}); + +require.define("/node_modules/sprintf/lib/sprintf.js", function (require, module, exports, __dirname, __filename) { + /** +sprintf() for JavaScript 0.7-beta1 +http://www.diveintojavascript.com/projects/javascript-sprintf + +Copyright (c) Alexandru Marasteanu +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of sprintf() for JavaScript nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL Alexandru Marasteanu BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + +Changelog: +2010.11.07 - 0.7-beta1-node + - converted it to a node.js compatible module + +2010.09.06 - 0.7-beta1 + - features: vsprintf, support for named placeholders + - enhancements: format cache, reduced global namespace pollution + +2010.05.22 - 0.6: + - reverted to 0.4 and fixed the bug regarding the sign of the number 0 + Note: + Thanks to Raphael Pigulla (http://www.n3rd.org/) + who warned me about a bug in 0.5, I discovered that the last update was + a regress. I appologize for that. + +2010.05.09 - 0.5: + - bug fix: 0 is now preceeded with a + sign + - bug fix: the sign was not at the right position on padded results (Kamal Abdali) + - switched from GPL to BSD license + +2007.10.21 - 0.4: + - unit test and patch (David Baird) + +2007.09.17 - 0.3: + - bug fix: no longer throws exception on empty paramenters (Hans Pufal) + +2007.09.11 - 0.2: + - feature: added argument swapping + +2007.04.03 - 0.1: + - initial release +**/ + +var sprintf = (function() { + function get_type(variable) { + return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase(); + } + function str_repeat(input, multiplier) { + for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */} + return output.join(''); + } + + var str_format = function() { + if (!str_format.cache.hasOwnProperty(arguments[0])) { + str_format.cache[arguments[0]] = str_format.parse(arguments[0]); + } + return str_format.format.call(null, str_format.cache[arguments[0]], arguments); + }; + + str_format.format = function(parse_tree, argv) { + var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length; + for (i = 0; i < tree_length; i++) { + node_type = get_type(parse_tree[i]); + if (node_type === 'string') { + output.push(parse_tree[i]); + } + else if (node_type === 'array') { + match = parse_tree[i]; // convenience purposes only + if (match[2]) { // keyword argument + arg = argv[cursor]; + for (k = 0; k < match[2].length; k++) { + if (!arg.hasOwnProperty(match[2][k])) { + throw(sprintf('[sprintf] property "%s" does not exist', match[2][k])); + } + arg = arg[match[2][k]]; + } + } + else if (match[1]) { // positional argument (explicit) + arg = argv[match[1]]; + } + else { // positional argument (implicit) + arg = argv[cursor++]; + } + + if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) { + throw(sprintf('[sprintf] expecting number but found %s', get_type(arg))); + } + switch (match[8]) { + case 'b': arg = arg.toString(2); break; + case 'c': arg = String.fromCharCode(arg); break; + case 'd': arg = parseInt(arg, 10); break; + case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break; + case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break; + case 'o': arg = arg.toString(8); break; + case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break; + case 'u': arg = Math.abs(arg); break; + case 'x': arg = arg.toString(16); break; + case 'X': arg = arg.toString(16).toUpperCase(); break; + } + arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg); + pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' '; + pad_length = match[6] - String(arg).length; + pad = match[6] ? str_repeat(pad_character, pad_length) : ''; + output.push(match[5] ? arg + pad : pad + arg); + } + } + return output.join(''); + }; + + str_format.cache = {}; + + str_format.parse = function(fmt) { + var _fmt = fmt, match = [], parse_tree = [], arg_names = 0; + while (_fmt) { + if ((match = /^[^\x25]+/.exec(_fmt)) !== null) { + parse_tree.push(match[0]); + } + else if ((match = /^\x25{2}/.exec(_fmt)) !== null) { + parse_tree.push('%'); + } + else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) { + if (match[2]) { + arg_names |= 1; + var field_list = [], replacement_field = match[2], field_match = []; + if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') { + if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) { + field_list.push(field_match[1]); + } + else { + throw('[sprintf] huh?'); + } + } + } + else { + throw('[sprintf] huh?'); + } + match[2] = field_list; + } + else { + arg_names |= 2; + } + if (arg_names === 3) { + throw('[sprintf] mixing positional and named placeholders is not (yet) supported'); + } + parse_tree.push(match); + } + else { + throw('[sprintf] huh?'); + } + _fmt = _fmt.substring(match[0].length); + } + return parse_tree; + }; + + return str_format; +})(); + +var vsprintf = function(fmt, argv) { + argv.unshift(fmt); + return sprintf.apply(null, argv); +}; + +exports.sprintf = sprintf; +exports.vsprintf = vsprintf; +}); + +require.define("/shred/response.js", function (require, module, exports, __dirname, __filename) { + // The `Response object` encapsulates a Node.js HTTP response. + +var Content = require("./content") + , HeaderMixins = require("./mixins/headers") + , CookieJarLib = require( "cookiejar" ) + , Cookie = CookieJarLib.Cookie +; + +// Browser doesn't have zlib. +var zlib = null; +try { + zlib = require('zlib'); +} catch (e) { + console.warn("no zlib library"); +} + +// Iconv doesn't work in browser +var Iconv = null; +try { + Iconv = require('iconv-lite'); +} catch (e) { + console.warn("no iconv library"); +} + +// Construct a `Response` object. You should never have to do this directly. The +// `Request` object handles this, getting the raw response object and passing it +// in here, along with the request. The callback allows us to stream the response +// and then use the callback to let the request know when it's ready. +var Response = function(raw, request, callback) { + var response = this; + this._raw = raw; + + // The `._setHeaders` method is "private"; you can't otherwise set headers on + // the response. + this._setHeaders.call(this,raw.headers); + + // store any cookies + if (request.cookieJar && this.getHeader('set-cookie')) { + var cookieStrings = this.getHeader('set-cookie'); + var cookieObjs = [] + , cookie; + + for (var i = 0; i < cookieStrings.length; i++) { + var cookieString = cookieStrings[i]; + if (!cookieString) { + continue; + } + + if (!cookieString.match(/domain\=/i)) { + cookieString += '; domain=' + request.host; + } + + if (!cookieString.match(/path\=/i)) { + cookieString += '; path=' + request.path; + } + + try { + cookie = new Cookie(cookieString); + if (cookie) { + cookieObjs.push(cookie); + } + } catch (e) { + console.warn("Tried to set bad cookie: " + cookieString); + } + } + + request.cookieJar.setCookies(cookieObjs); + } + + this.request = request; + this.client = request.client; + this.log = this.request.log; + + // Stream the response content entity and fire the callback when we're done. + // Store the incoming data in a array of Buffers which we concatinate into one + // buffer at the end. We need to use buffers instead of strings here in order + // to preserve binary data. + var chunkBuffers = []; + var dataLength = 0; + raw.on("data", function(chunk) { + chunkBuffers.push(chunk); + dataLength += chunk.length; + }); + raw.on("end", function() { + var body; + if (typeof Buffer === 'undefined') { + // Just concatinate into a string + body = chunkBuffers.join(''); + } else { + // Initialize new buffer and add the chunks one-at-a-time. + body = new Buffer(dataLength); + for (var i = 0, pos = 0; i < chunkBuffers.length; i++) { + chunkBuffers[i].copy(body, pos); + pos += chunkBuffers[i].length; + } + } + + var setBodyAndFinish = function (body) { + response._body = new Content({ + body: body, + type: response.getHeader("Content-Type") + }); + callback(response); + } + + if (zlib && response.getHeader("Content-Encoding") === 'gzip'){ + zlib.gunzip(body, function (err, gunzippedBody) { + if (Iconv && response.request.encoding){ + body = Iconv.fromEncoding(gunzippedBody,response.request.encoding); + } else { + body = gunzippedBody.toString(); + } + setBodyAndFinish(body); + }) + } + else{ + if (response.request.encoding){ + body = Iconv.fromEncoding(body,response.request.encoding); + } + setBodyAndFinish(body); + } + }); +}; + +// The `Response` object can be pretty overwhelming to view using the built-in +// Node.js inspect method. We want to make it a bit more manageable. This +// probably goes [too far in the other +// direction](https://github.com/spire-io/shred/issues/2). + +Response.prototype = { + inspect: function() { + var response = this; + var headers = this.format_headers(); + var summary = [" ", response.status].join(" ") + return [ summary, "- Headers:", headers].join("\n"); + }, + format_headers: function () { + var array = [] + var headers = this._headers + for (var key in headers) { + if (headers.hasOwnProperty(key)) { + var value = headers[key] + array.push("\t" + key + ": " + value); + } + } + return array.join("\n"); + } +}; + +// `Response` object properties, all of which are read-only: +Object.defineProperties(Response.prototype, { + +// - **status**. The HTTP status code for the response. + status: { + get: function() { return this._raw.statusCode; }, + enumerable: true + }, + +// - **content**. The HTTP content entity, if any. Provided as a [content +// object](./content.html), which will attempt to convert the entity based upon +// the `content-type` header. The converted value is available as +// `content.data`. The original raw content entity is available as +// `content.body`. + body: { + get: function() { return this._body; } + }, + content: { + get: function() { return this.body; }, + enumerable: true + }, + +// - **isRedirect**. Is the response a redirect? These are responses with 3xx +// status and a `Location` header. + isRedirect: { + get: function() { + return (this.status>299 + &&this.status<400 + &&this.getHeader("Location")); + }, + enumerable: true + }, + +// - **isError**. Is the response an error? These are responses with status of +// 400 or greater. + isError: { + get: function() { + return (this.status === 0 || this.status > 399) + }, + enumerable: true + } +}); + +// Add in the [getters for accessing the normalized headers](./headers.js). +HeaderMixins.getters(Response); +HeaderMixins.privateSetters(Response); + +// Work around Mozilla bug #608735 [https://bugzil.la/608735], which causes +// getAllResponseHeaders() to return {} if the response is a CORS request. +// xhr.getHeader still works correctly. +var getHeader = Response.prototype.getHeader; +Response.prototype.getHeader = function (name) { + return (getHeader.call(this,name) || + (typeof this._raw.getHeader === 'function' && this._raw.getHeader(name))); +}; + +module.exports = Response; + +}); + +require.define("/shred/content.js", function (require, module, exports, __dirname, __filename) { + +// The purpose of the `Content` object is to abstract away the data conversions +// to and from raw content entities as strings. For example, you want to be able +// to pass in a Javascript object and have it be automatically converted into a +// JSON string if the `content-type` is set to a JSON-based media type. +// Conversely, you want to be able to transparently get back a Javascript object +// in the response if the `content-type` is a JSON-based media-type. + +// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5). + +// The `Content` constructor takes an options object, which *must* have either a +// `body` or `data` property and *may* have a `type` property indicating the +// media type. If there is no `type` attribute, a default will be inferred. +var Content = function(options) { + this.body = options.body; + this.data = options.data; + this.type = options.type; +}; + +Content.prototype = { + // Treat `toString()` as asking for the `content.body`. That is, the raw content entity. + // + // toString: function() { return this.body; } + // + // Commented out, but I've forgotten why. :/ +}; + + +// `Content` objects have the following attributes: +Object.defineProperties(Content.prototype,{ + +// - **type**. Typically accessed as `content.type`, reflects the `content-type` +// header associated with the request or response. If not passed as an options +// to the constructor or set explicitly, it will infer the type the `data` +// attribute, if possible, and, failing that, will default to `text/plain`. + type: { + get: function() { + if (this._type) { + return this._type; + } else { + if (this._data) { + switch(typeof this._data) { + case "string": return "text/plain"; + case "object": return "application/json"; + } + } + } + return "text/plain"; + }, + set: function(value) { + this._type = value; + return this; + }, + enumerable: true + }, + +// - **data**. Typically accessed as `content.data`, reflects the content entity +// converted into Javascript data. This can be a string, if the `type` is, say, +// `text/plain`, but can also be a Javascript object. The conversion applied is +// based on the `processor` attribute. The `data` attribute can also be set +// directly, in which case the conversion will be done the other way, to infer +// the `body` attribute. + data: { + get: function() { + if (this._body) { + return this.processor.parser(this._body); + } else { + return this._data; + } + }, + set: function(data) { + if (this._body&&data) Errors.setDataWithBody(this); + this._data = data; + return this; + }, + enumerable: true + }, + +// - **body**. Typically accessed as `content.body`, reflects the content entity +// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the +// `data` attribute, the `body` attribute will be inferred and vice-versa. If +// you attempt to set both, an exception is raised. + body: { + get: function() { + if (this._data) { + return this.processor.stringify(this._data); + } else { + return this.processor.stringify(this._body); + } + }, + set: function(body) { + if (this._data&&body) Errors.setBodyWithData(this); + this._body = body; + return this; + }, + enumerable: true + }, + +// - **processor**. The functions that will be used to convert to/from `data` and +// `body` attributes. You can add processors. The two that are built-in are for +// `text/plain`, which is basically an identity transformation and +// `application/json` and other JSON-based media types (including custom media +// types with `+json`). You can add your own processors. See below. + processor: { + get: function() { + var processor = Content.processors[this.type]; + if (processor) { + return processor; + } else { + // Return the first processor that matches any part of the + // content type. ex: application/vnd.foobar.baz+json will match json. + var main = this.type.split(";")[0]; + var parts = main.split(/\+|\//); + for (var i=0, l=parts.length; i < l; i++) { + processor = Content.processors[parts[i]] + } + return processor || {parser:identity,stringify:toString}; + } + }, + enumerable: true + }, + +// - **length**. Typically accessed as `content.length`, returns the length in +// bytes of the raw content entity. + length: { + get: function() { + if (typeof Buffer !== 'undefined') { + return Buffer.byteLength(this.body); + } + return this.body.length; + } + } +}); + +Content.processors = {}; + +// The `registerProcessor` function allows you to add your own processors to +// convert content entities. Each processor consists of a Javascript object with +// two properties: +// - **parser**. The function used to parse a raw content entity and convert it +// into a Javascript data type. +// - **stringify**. The function used to convert a Javascript data type into a +// raw content entity. +Content.registerProcessor = function(types,processor) { + +// You can pass an array of types that will trigger this processor, or just one. +// We determine the array via duck-typing here. + if (types.forEach) { + types.forEach(function(type) { + Content.processors[type] = processor; + }); + } else { + // If you didn't pass an array, we just use what you pass in. + Content.processors[types] = processor; + } +}; + +// Register the identity processor, which is used for text-based media types. +var identity = function(x) { return x; } + , toString = function(x) { return x.toString(); } +Content.registerProcessor( + ["text/html","text/plain","text"], + { parser: identity, stringify: toString }); + +// Register the JSON processor, which is used for JSON-based media types. +Content.registerProcessor( + ["application/json; charset=utf-8","application/json","json"], + { + parser: function(string) { + return JSON.parse(string); + }, + stringify: function(data) { + return JSON.stringify(data); }}); + +// Error functions are defined separately here in an attempt to make the code +// easier to read. +var Errors = { + setDataWithBody: function(object) { + throw new Error("Attempt to set data attribute of a content object " + + "when the body attributes was already set."); + }, + setBodyWithData: function(object) { + throw new Error("Attempt to set body attribute of a content object " + + "when the data attributes was already set."); + } +} +module.exports = Content; + +}); + +require.define("/shred/mixins/headers.js", function (require, module, exports, __dirname, __filename) { + // The header mixins allow you to add HTTP header support to any object. This +// might seem pointless: why not simply use a hash? The main reason is that, per +// the [HTTP spec](http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2), +// headers are case-insensitive. So, for example, `content-type` is the same as +// `CONTENT-TYPE` which is the same as `Content-Type`. Since there is no way to +// overload the index operator in Javascript, using a hash to represent the +// headers means it's possible to have two conflicting values for a single +// header. +// +// The solution to this is to provide explicit methods to set or get headers. +// This also has the benefit of allowing us to introduce additional variations, +// including snake case, which we automatically convert to what Matthew King has +// dubbed "corset case" - the hyphen-separated names with initial caps: +// `Content-Type`. We use corset-case just in case we're dealing with servers +// that haven't properly implemented the spec. + +// Convert headers to corset-case. **Example:** `CONTENT-TYPE` will be converted +// to `Content-Type`. + +var corsetCase = function(string) { + return string.toLowerCase() + //.replace("_","-") + .replace(/(^|-)(\w)/g, + function(s) { return s.toUpperCase(); }); +}; + +// We suspect that `initializeHeaders` was once more complicated ... +var initializeHeaders = function(object) { + return {}; +}; + +// Access the `_headers` property using lazy initialization. **Warning:** If you +// mix this into an object that is using the `_headers` property already, you're +// going to have trouble. +var $H = function(object) { + return object._headers||(object._headers=initializeHeaders(object)); +}; + +// Hide the implementations as private functions, separate from how we expose them. + +// The "real" `getHeader` function: get the header after normalizing the name. +var getHeader = function(object,name) { + return $H(object)[corsetCase(name)]; +}; + +// The "real" `getHeader` function: get one or more headers, or all of them +// if you don't ask for any specifics. +var getHeaders = function(object,names) { + var keys = (names && names.length>0) ? names : Object.keys($H(object)); + var hash = keys.reduce(function(hash,key) { + hash[key] = getHeader(object,key); + return hash; + },{}); + // Freeze the resulting hash so you don't mistakenly think you're modifying + // the real headers. + Object.freeze(hash); + return hash; +}; + +// The "real" `setHeader` function: set a header, after normalizing the name. +var setHeader = function(object,name,value) { + $H(object)[corsetCase(name)] = value; + return object; +}; + +// The "real" `setHeaders` function: set multiple headers based on a hash. +var setHeaders = function(object,hash) { + for( var key in hash ) { setHeader(object,key,hash[key]); }; + return this; +}; + +// Here's where we actually bind the functionality to an object. These mixins work by +// exposing mixin functions. Each function mixes in a specific batch of features. +module.exports = { + + // Add getters. + getters: function(constructor) { + constructor.prototype.getHeader = function(name) { return getHeader(this,name); }; + constructor.prototype.getHeaders = function() { return getHeaders(this,arguments); }; + }, + // Add setters but as "private" methods. + privateSetters: function(constructor) { + constructor.prototype._setHeader = function(key,value) { return setHeader(this,key,value); }; + constructor.prototype._setHeaders = function(hash) { return setHeaders(this,hash); }; + }, + // Add setters. + setters: function(constructor) { + constructor.prototype.setHeader = function(key,value) { return setHeader(this,key,value); }; + constructor.prototype.setHeaders = function(hash) { return setHeaders(this,hash); }; + }, + // Add both getters and setters. + gettersAndSetters: function(constructor) { + constructor.prototype.getHeader = function(name) { return getHeader(this,name); }; + constructor.prototype.getHeaders = function() { return getHeaders(this,arguments); }; + constructor.prototype.setHeader = function(key,value) { return setHeader(this,key,value); }; + constructor.prototype.setHeaders = function(hash) { return setHeaders(this,hash); }; + }, +}; + +}); + +require.define("/node_modules/iconv-lite/package.json", function (require, module, exports, __dirname, __filename) { + module.exports = {} +}); + +require.define("/node_modules/iconv-lite/index.js", function (require, module, exports, __dirname, __filename) { + // Module exports +var iconv = module.exports = { + toEncoding: function(str, encoding) { + return iconv.getCodec(encoding).toEncoding(str); + }, + fromEncoding: function(buf, encoding) { + return iconv.getCodec(encoding).fromEncoding(buf); + }, + + defaultCharUnicode: '�', + defaultCharSingleByte: '?', + + // Get correct codec for given encoding. + getCodec: function(encoding) { + var enc = encoding || "utf8"; + var codecOptions = undefined; + while (1) { + if (getType(enc) === "String") + enc = enc.replace(/[- ]/g, "").toLowerCase(); + var codec = iconv.encodings[enc]; + var type = getType(codec); + if (type === "String") { + // Link to other encoding. + codecOptions = {originalEncoding: enc}; + enc = codec; + } + else if (type === "Object" && codec.type != undefined) { + // Options for other encoding. + codecOptions = codec; + enc = codec.type; + } + else if (type === "Function") + // Codec itself. + return codec(codecOptions); + else + throw new Error("Encoding not recognized: '" + encoding + "' (searched as: '"+enc+"')"); + } + }, + + // Define basic encodings + encodings: { + internal: function(options) { + return { + toEncoding: function(str) { + return new Buffer(ensureString(str), options.originalEncoding); + }, + fromEncoding: function(buf) { + return ensureBuffer(buf).toString(options.originalEncoding); + } + }; + }, + utf8: "internal", + ucs2: "internal", + binary: "internal", + ascii: "internal", + base64: "internal", + + // Codepage single-byte encodings. + singlebyte: function(options) { + // Prepare chars if needed + if (!options.chars || (options.chars.length !== 128 && options.chars.length !== 256)) + throw new Error("Encoding '"+options.type+"' has incorrect 'chars' (must be of len 128 or 256)"); + + if (options.chars.length === 128) + options.chars = asciiString + options.chars; + + if (!options.charsBuf) { + options.charsBuf = new Buffer(options.chars, 'ucs2'); + } + + if (!options.revCharsBuf) { + options.revCharsBuf = new Buffer(65536); + var defChar = iconv.defaultCharSingleByte.charCodeAt(0); + for (var i = 0; i < options.revCharsBuf.length; i++) + options.revCharsBuf[i] = defChar; + for (var i = 0; i < options.chars.length; i++) + options.revCharsBuf[options.chars.charCodeAt(i)] = i; + } + + return { + toEncoding: function(str) { + str = ensureString(str); + + var buf = new Buffer(str.length); + var revCharsBuf = options.revCharsBuf; + for (var i = 0; i < str.length; i++) + buf[i] = revCharsBuf[str.charCodeAt(i)]; + + return buf; + }, + fromEncoding: function(buf) { + buf = ensureBuffer(buf); + + // Strings are immutable in JS -> we use ucs2 buffer to speed up computations. + var charsBuf = options.charsBuf; + var newBuf = new Buffer(buf.length*2); + var idx1 = 0, idx2 = 0; + for (var i = 0, _len = buf.length; i < _len; i++) { + idx1 = buf[i]*2; idx2 = i*2; + newBuf[idx2] = charsBuf[idx1]; + newBuf[idx2+1] = charsBuf[idx1+1]; + } + return newBuf.toString('ucs2'); + } + }; + }, + + // Codepage double-byte encodings. + table: function(options) { + var table = options.table, key, revCharsTable = options.revCharsTable; + if (!table) { + throw new Error("Encoding '" + options.type +"' has incorect 'table' option"); + } + if(!revCharsTable) { + revCharsTable = options.revCharsTable = {}; + for (key in table) { + revCharsTable[table[key]] = parseInt(key); + } + } + + return { + toEncoding: function(str) { + str = ensureString(str); + var strLen = str.length; + var bufLen = strLen; + for (var i = 0; i < strLen; i++) + if (str.charCodeAt(i) >> 7) + bufLen++; + + var newBuf = new Buffer(bufLen), gbkcode, unicode, + defaultChar = revCharsTable[iconv.defaultCharUnicode.charCodeAt(0)]; + + for (var i = 0, j = 0; i < strLen; i++) { + unicode = str.charCodeAt(i); + if (unicode >> 7) { + gbkcode = revCharsTable[unicode] || defaultChar; + newBuf[j++] = gbkcode >> 8; //high byte; + newBuf[j++] = gbkcode & 0xFF; //low byte + } else {//ascii + newBuf[j++] = unicode; + } + } + return newBuf; + }, + fromEncoding: function(buf) { + buf = ensureBuffer(buf); + var bufLen = buf.length, strLen = 0; + for (var i = 0; i < bufLen; i++) { + strLen++; + if (buf[i] & 0x80) //the high bit is 1, so this byte is gbkcode's high byte.skip next byte + i++; + } + var newBuf = new Buffer(strLen*2), unicode, gbkcode, + defaultChar = iconv.defaultCharUnicode.charCodeAt(0); + + for (var i = 0, j = 0; i < bufLen; i++, j+=2) { + gbkcode = buf[i]; + if (gbkcode & 0x80) { + gbkcode = (gbkcode << 8) + buf[++i]; + unicode = table[gbkcode] || defaultChar; + } else { + unicode = gbkcode; + } + newBuf[j] = unicode & 0xFF; //low byte + newBuf[j+1] = unicode >> 8; //high byte + } + return newBuf.toString('ucs2'); + } + } + } + } +}; + +// Add aliases to convert functions +iconv.encode = iconv.toEncoding; +iconv.decode = iconv.fromEncoding; + +// Load other encodings from files in /encodings dir. +var encodingsDir = __dirname+"/encodings/", + fs = require('fs'); +fs.readdirSync(encodingsDir).forEach(function(file) { + if(fs.statSync(encodingsDir + file).isDirectory()) return; + var encodings = require(encodingsDir + file) + for (var key in encodings) + iconv.encodings[key] = encodings[key] +}); + +// Utilities +var asciiString = '\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f'+ + ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\x7f'; + +var ensureBuffer = function(buf) { + buf = buf || new Buffer(0); + return (buf instanceof Buffer) ? buf : new Buffer(buf.toString(), "utf8"); +} + +var ensureString = function(str) { + str = str || ""; + return (str instanceof String) ? str : str.toString((str instanceof Buffer) ? 'utf8' : undefined); +} + +var getType = function(obj) { + return Object.prototype.toString.call(obj).slice(8, -1); +} + + +}); + +require.define("/node_modules/http-browserify/package.json", function (require, module, exports, __dirname, __filename) { + module.exports = {"main":"index.js","browserify":"browser.js"} +}); + +require.define("/node_modules/http-browserify/browser.js", function (require, module, exports, __dirname, __filename) { + var http = module.exports; +var EventEmitter = require('events').EventEmitter; +var Request = require('./lib/request'); + +http.request = function (params, cb) { + if (!params) params = {}; + if (!params.host) params.host = window.location.host.split(':')[0]; + if (!params.port) params.port = window.location.port; + + var req = new Request(new xhrHttp, params); + if (cb) req.on('response', cb); + return req; +}; + +http.get = function (params, cb) { + params.method = 'GET'; + var req = http.request(params, cb); + req.end(); + return req; +}; + +var xhrHttp = (function () { + if (typeof window === 'undefined') { + throw new Error('no window object present'); + } + else if (window.XMLHttpRequest) { + return window.XMLHttpRequest; + } + else if (window.ActiveXObject) { + var axs = [ + 'Msxml2.XMLHTTP.6.0', + 'Msxml2.XMLHTTP.3.0', + 'Microsoft.XMLHTTP' + ]; + for (var i = 0; i < axs.length; i++) { + try { + var ax = new(window.ActiveXObject)(axs[i]); + return function () { + if (ax) { + var ax_ = ax; + ax = null; + return ax_; + } + else { + return new(window.ActiveXObject)(axs[i]); + } + }; + } + catch (e) {} + } + throw new Error('ajax not supported in this browser') + } + else { + throw new Error('ajax not supported in this browser'); + } +})(); + +http.STATUS_CODES = { + 100 : 'Continue', + 101 : 'Switching Protocols', + 102 : 'Processing', // RFC 2518, obsoleted by RFC 4918 + 200 : 'OK', + 201 : 'Created', + 202 : 'Accepted', + 203 : 'Non-Authoritative Information', + 204 : 'No Content', + 205 : 'Reset Content', + 206 : 'Partial Content', + 207 : 'Multi-Status', // RFC 4918 + 300 : 'Multiple Choices', + 301 : 'Moved Permanently', + 302 : 'Moved Temporarily', + 303 : 'See Other', + 304 : 'Not Modified', + 305 : 'Use Proxy', + 307 : 'Temporary Redirect', + 400 : 'Bad Request', + 401 : 'Unauthorized', + 402 : 'Payment Required', + 403 : 'Forbidden', + 404 : 'Not Found', + 405 : 'Method Not Allowed', + 406 : 'Not Acceptable', + 407 : 'Proxy Authentication Required', + 408 : 'Request Time-out', + 409 : 'Conflict', + 410 : 'Gone', + 411 : 'Length Required', + 412 : 'Precondition Failed', + 413 : 'Request Entity Too Large', + 414 : 'Request-URI Too Large', + 415 : 'Unsupported Media Type', + 416 : 'Requested Range Not Satisfiable', + 417 : 'Expectation Failed', + 418 : 'I\'m a teapot', // RFC 2324 + 422 : 'Unprocessable Entity', // RFC 4918 + 423 : 'Locked', // RFC 4918 + 424 : 'Failed Dependency', // RFC 4918 + 425 : 'Unordered Collection', // RFC 4918 + 426 : 'Upgrade Required', // RFC 2817 + 500 : 'Internal Server Error', + 501 : 'Not Implemented', + 502 : 'Bad Gateway', + 503 : 'Service Unavailable', + 504 : 'Gateway Time-out', + 505 : 'HTTP Version not supported', + 506 : 'Variant Also Negotiates', // RFC 2295 + 507 : 'Insufficient Storage', // RFC 4918 + 509 : 'Bandwidth Limit Exceeded', + 510 : 'Not Extended' // RFC 2774 +}; + +}); + +require.define("/node_modules/http-browserify/lib/request.js", function (require, module, exports, __dirname, __filename) { + var EventEmitter = require('events').EventEmitter; +var Response = require('./response'); +var isSafeHeader = require('./isSafeHeader'); + +var Request = module.exports = function (xhr, params) { + var self = this; + self.xhr = xhr; + self.body = ''; + + var uri = params.host + ':' + params.port + (params.path || '/'); + + xhr.open( + params.method || 'GET', + (params.scheme || 'http') + '://' + uri, + true + ); + + if (params.headers) { + Object.keys(params.headers).forEach(function (key) { + if (!isSafeHeader(key)) return; + var value = params.headers[key]; + if (Array.isArray(value)) { + value.forEach(function (v) { + xhr.setRequestHeader(key, v); + }); + } + else xhr.setRequestHeader(key, value) + }); + } + + var res = new Response(xhr); + res.on('ready', function () { + self.emit('response', res); + }); + + xhr.onreadystatechange = function () { + res.handle(xhr); + }; +}; + +Request.prototype = new EventEmitter; + +Request.prototype.setHeader = function (key, value) { + if ((Array.isArray && Array.isArray(value)) + || value instanceof Array) { + for (var i = 0; i < value.length; i++) { + this.xhr.setRequestHeader(key, value[i]); + } + } + else { + this.xhr.setRequestHeader(key, value); + } +}; + +Request.prototype.write = function (s) { + this.body += s; +}; + +Request.prototype.end = function (s) { + if (s !== undefined) this.write(s); + this.xhr.send(this.body); +}; + +}); + +require.define("/node_modules/http-browserify/lib/response.js", function (require, module, exports, __dirname, __filename) { + var EventEmitter = require('events').EventEmitter; +var isSafeHeader = require('./isSafeHeader'); + +var Response = module.exports = function (xhr) { + this.xhr = xhr; + this.offset = 0; +}; + +Response.prototype = new EventEmitter; + +var capable = { + streaming : true, + status2 : true +}; + +function parseHeaders (xhr) { + var lines = xhr.getAllResponseHeaders().split(/\r?\n/); + var headers = {}; + for (var i = 0; i < lines.length; i++) { + var line = lines[i]; + if (line === '') continue; + + var m = line.match(/^([^:]+):\s*(.*)/); + if (m) { + var key = m[1].toLowerCase(), value = m[2]; + + if (headers[key] !== undefined) { + if ((Array.isArray && Array.isArray(headers[key])) + || headers[key] instanceof Array) { + headers[key].push(value); + } + else { + headers[key] = [ headers[key], value ]; + } + } + else { + headers[key] = value; + } + } + else { + headers[line] = true; + } + } + return headers; +} + +Response.prototype.getHeader = function (key) { + var header = this.headers ? this.headers[key.toLowerCase()] : null; + if (header) return header; + + // Work around Mozilla bug #608735 [https://bugzil.la/608735], which causes + // getAllResponseHeaders() to return {} if the response is a CORS request. + // xhr.getHeader still works correctly. + if (isSafeHeader(key)) { + return this.xhr.getResponseHeader(key); + } + return null; +}; + +Response.prototype.handle = function () { + var xhr = this.xhr; + if (xhr.readyState === 2 && capable.status2) { + try { + this.statusCode = xhr.status; + this.headers = parseHeaders(xhr); + } + catch (err) { + capable.status2 = false; + } + + if (capable.status2) { + this.emit('ready'); + } + } + else if (capable.streaming && xhr.readyState === 3) { + try { + if (!this.statusCode) { + this.statusCode = xhr.status; + this.headers = parseHeaders(xhr); + this.emit('ready'); + } + } + catch (err) {} + + try { + this.write(); + } + catch (err) { + capable.streaming = false; + } + } + else if (xhr.readyState === 4) { + if (!this.statusCode) { + this.statusCode = xhr.status; + this.emit('ready'); + } + this.write(); + + if (xhr.error) { + this.emit('error', xhr.responseText); + } + else this.emit('end'); + } +}; + +Response.prototype.write = function () { + var xhr = this.xhr; + if (xhr.responseText.length > this.offset) { + this.emit('data', xhr.responseText.slice(this.offset)); + this.offset = xhr.responseText.length; + } +}; + +}); + +require.define("/node_modules/http-browserify/lib/isSafeHeader.js", function (require, module, exports, __dirname, __filename) { + // Taken from http://dxr.mozilla.org/mozilla/mozilla-central/content/base/src/nsXMLHttpRequest.cpp.html +var unsafeHeaders = [ + "accept-charset", + "accept-encoding", + "access-control-request-headers", + "access-control-request-method", + "connection", + "content-length", + "cookie", + "cookie2", + "content-transfer-encoding", + "date", + "expect", + "host", + "keep-alive", + "origin", + "referer", + "set-cookie", + "te", + "trailer", + "transfer-encoding", + "upgrade", + "user-agent", + "via" +]; + +module.exports = function (headerName) { + if (!headerName) return false; + return (unsafeHeaders.indexOf(headerName.toLowerCase()) === -1) +}; + +}); + +require.alias("http-browserify", "/node_modules/http"); + +require.alias("http-browserify", "/node_modules/https"); \ No newline at end of file diff --git a/tastypie_swagger/static/tastypie_swagger/js/lib/shred/content.js b/tastypie_swagger/static/tastypie_swagger/js/lib/shred/content.js new file mode 100755 index 0000000..b8051fe --- /dev/null +++ b/tastypie_swagger/static/tastypie_swagger/js/lib/shred/content.js @@ -0,0 +1,193 @@ + +// The purpose of the `Content` object is to abstract away the data conversions +// to and from raw content entities as strings. For example, you want to be able +// to pass in a Javascript object and have it be automatically converted into a +// JSON string if the `content-type` is set to a JSON-based media type. +// Conversely, you want to be able to transparently get back a Javascript object +// in the response if the `content-type` is a JSON-based media-type. + +// One limitation of the current implementation is that it [assumes the `charset` is UTF-8](https://github.com/spire-io/shred/issues/5). + +// The `Content` constructor takes an options object, which *must* have either a +// `body` or `data` property and *may* have a `type` property indicating the +// media type. If there is no `type` attribute, a default will be inferred. +var Content = function(options) { + this.body = options.body; + this.data = options.data; + this.type = options.type; +}; + +Content.prototype = { + // Treat `toString()` as asking for the `content.body`. That is, the raw content entity. + // + // toString: function() { return this.body; } + // + // Commented out, but I've forgotten why. :/ +}; + + +// `Content` objects have the following attributes: +Object.defineProperties(Content.prototype,{ + +// - **type**. Typically accessed as `content.type`, reflects the `content-type` +// header associated with the request or response. If not passed as an options +// to the constructor or set explicitly, it will infer the type the `data` +// attribute, if possible, and, failing that, will default to `text/plain`. + type: { + get: function() { + if (this._type) { + return this._type; + } else { + if (this._data) { + switch(typeof this._data) { + case "string": return "text/plain"; + case "object": return "application/json"; + } + } + } + return "text/plain"; + }, + set: function(value) { + this._type = value; + return this; + }, + enumerable: true + }, + +// - **data**. Typically accessed as `content.data`, reflects the content entity +// converted into Javascript data. This can be a string, if the `type` is, say, +// `text/plain`, but can also be a Javascript object. The conversion applied is +// based on the `processor` attribute. The `data` attribute can also be set +// directly, in which case the conversion will be done the other way, to infer +// the `body` attribute. + data: { + get: function() { + if (this._body) { + return this.processor.parser(this._body); + } else { + return this._data; + } + }, + set: function(data) { + if (this._body&&data) Errors.setDataWithBody(this); + this._data = data; + return this; + }, + enumerable: true + }, + +// - **body**. Typically accessed as `content.body`, reflects the content entity +// as a UTF-8 string. It is the mirror of the `data` attribute. If you set the +// `data` attribute, the `body` attribute will be inferred and vice-versa. If +// you attempt to set both, an exception is raised. + body: { + get: function() { + if (this._data) { + return this.processor.stringify(this._data); + } else { + return this._body.toString(); + } + }, + set: function(body) { + if (this._data&&body) Errors.setBodyWithData(this); + this._body = body; + return this; + }, + enumerable: true + }, + +// - **processor**. The functions that will be used to convert to/from `data` and +// `body` attributes. You can add processors. The two that are built-in are for +// `text/plain`, which is basically an identity transformation and +// `application/json` and other JSON-based media types (including custom media +// types with `+json`). You can add your own processors. See below. + processor: { + get: function() { + var processor = Content.processors[this.type]; + if (processor) { + return processor; + } else { + // Return the first processor that matches any part of the + // content type. ex: application/vnd.foobar.baz+json will match json. + var main = this.type.split(";")[0]; + var parts = main.split(/\+|\//); + for (var i=0, l=parts.length; i < l; i++) { + processor = Content.processors[parts[i]] + } + return processor || {parser:identity,stringify:toString}; + } + }, + enumerable: true + }, + +// - **length**. Typically accessed as `content.length`, returns the length in +// bytes of the raw content entity. + length: { + get: function() { + if (typeof Buffer !== 'undefined') { + return Buffer.byteLength(this.body); + } + return this.body.length; + } + } +}); + +Content.processors = {}; + +// The `registerProcessor` function allows you to add your own processors to +// convert content entities. Each processor consists of a Javascript object with +// two properties: +// - **parser**. The function used to parse a raw content entity and convert it +// into a Javascript data type. +// - **stringify**. The function used to convert a Javascript data type into a +// raw content entity. +Content.registerProcessor = function(types,processor) { + +// You can pass an array of types that will trigger this processor, or just one. +// We determine the array via duck-typing here. + if (types.forEach) { + types.forEach(function(type) { + Content.processors[type] = processor; + }); + } else { + // If you didn't pass an array, we just use what you pass in. + Content.processors[types] = processor; + } +}; + +// Register the identity processor, which is used for text-based media types. +var identity = function(x) { return x; } + , toString = function(x) { return x.toString(); } +Content.registerProcessor( + ["text/html","text/plain","text"], + { parser: identity, stringify: toString }); + +// Register the JSON processor, which is used for JSON-based media types. +Content.registerProcessor( + ["application/json; charset=utf-8","application/json","json"], + { + parser: function(string) { + return JSON.parse(string); + }, + stringify: function(data) { + return JSON.stringify(data); }}); + +var qs = require('querystring'); +// Register the post processor, which is used for JSON-based media types. +Content.registerProcessor( + ["application/x-www-form-urlencoded"], + { parser : qs.parse, stringify : qs.stringify }); + +// Error functions are defined separately here in an attempt to make the code +// easier to read. +var Errors = { + setDataWithBody: function(object) { + throw new Error("Attempt to set data attribute of a content object " + + "when the body attributes was already set."); + }, + setBodyWithData: function(object) { + throw new Error("Attempt to set body attribute of a content object " + + "when the data attributes was already set."); + } +} +module.exports = Content; \ No newline at end of file diff --git a/tastypie_swagger/static/tastypie_swagger/js/lib/swagger-oauth.js b/tastypie_swagger/static/tastypie_swagger/js/lib/swagger-oauth.js new file mode 100755 index 0000000..8bb17fb --- /dev/null +++ b/tastypie_swagger/static/tastypie_swagger/js/lib/swagger-oauth.js @@ -0,0 +1,211 @@ +var appName; +var popupMask; +var popupDialog; +var clientId; +var realm; + +function handleLogin() { + var scopes = []; + + if(window.swaggerUi.api.authSchemes + && window.swaggerUi.api.authSchemes.oauth2 + && window.swaggerUi.api.authSchemes.oauth2.scopes) { + scopes = window.swaggerUi.api.authSchemes.oauth2.scopes; + } + + if(window.swaggerUi.api + && window.swaggerUi.api.info) { + appName = window.swaggerUi.api.info.title; + } + + if(popupDialog.length > 0) + popupDialog = popupDialog.last(); + else { + popupDialog = $( + [ + '
', + '
Select OAuth2.0 Scopes
', + '
', + '

Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.', + 'Learn how to use', + '

', + '

' + appName + ' API requires the following scopes. Select which ones you want to grant to Swagger UI.

', + '
    ', + '
', + '

', + '
', + '
', + '
'].join('')); + $(document.body).append(popupDialog); + + popup = popupDialog.find('ul.api-popup-scopes').empty(); + for (i = 0; i < scopes.length; i ++) { + scope = scopes[i]; + str = '
  • ' + '
  • '; + popup.append(str); + } + } + + var $win = $(window), + dw = $win.width(), + dh = $win.height(), + st = $win.scrollTop(), + dlgWd = popupDialog.outerWidth(), + dlgHt = popupDialog.outerHeight(), + top = (dh -dlgHt)/2 + st, + left = (dw - dlgWd)/2; + + popupDialog.css({ + top: (top < 0? 0 : top) + 'px', + left: (left < 0? 0 : left) + 'px' + }); + + popupDialog.find('button.api-popup-cancel').click(function() { + popupMask.hide(); + popupDialog.hide(); + }); + popupDialog.find('button.api-popup-authbtn').click(function() { + popupMask.hide(); + popupDialog.hide(); + + var authSchemes = window.swaggerUi.api.authSchemes; + var host = window.location; + var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/")); + var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html"; + var url = null; + + for (var key in authSchemes) { + if (authSchemes.hasOwnProperty(key)) { + var o = authSchemes[key].grantTypes; + for(var t in o) { + if(o.hasOwnProperty(t) && t === 'implicit') { + var dets = o[t]; + url = dets.loginEndpoint.url + "?response_type=token"; + window.swaggerUi.tokenName = dets.tokenName; + } + } + } + } + var scopes = [] + var o = $('.api-popup-scopes').find('input:checked'); + + for(k =0; k < o.length; k++) { + scopes.push($(o[k]).attr("scope")); + } + + window.enabledScopes=scopes; + + url += '&redirect_uri=' + encodeURIComponent(redirectUrl); + url += '&realm=' + encodeURIComponent(realm); + url += '&client_id=' + encodeURIComponent(clientId); + url += '&scope=' + encodeURIComponent(scopes); + + window.open(url); + }); + + popupMask.show(); + popupDialog.show(); + return; +} + + +function handleLogout() { + for(key in window.authorizations.authz){ + window.authorizations.remove(key) + } + window.enabledScopes = null; + $('.api-ic.ic-on').addClass('ic-off'); + $('.api-ic.ic-on').removeClass('ic-on'); + + // set the info box + $('.api-ic.ic-warning').addClass('ic-error'); + $('.api-ic.ic-warning').removeClass('ic-warning'); +} + +function initOAuth(opts) { + var o = (opts||{}); + var errors = []; + + appName = (o.appName||errors.push("missing appName")); + popupMask = (o.popupMask||$('#api-common-mask')); + popupDialog = (o.popupDialog||$('.api-popup-dialog')); + clientId = (o.clientId||errors.push("missing client id")); + realm = (o.realm||errors.push("missing realm")); + + if(errors.length > 0){ + log("auth unable initialize oauth: " + errors); + return; + } + + $('pre code').each(function(i, e) {hljs.highlightBlock(e)}); + $('.api-ic').click(function(s) { + if($(s.target).hasClass('ic-off')) + handleLogin(); + else { + handleLogout(); + } + false; + }); +} + +function onOAuthComplete(token) { + if(token) { + if(token.error) { + var checkbox = $('input[type=checkbox],.secured') + checkbox.each(function(pos){ + checkbox[pos].checked = false; + }); + alert(token.error); + } + else { + var b = token[window.swaggerUi.tokenName]; + if(b){ + // if all roles are satisfied + var o = null; + $.each($('.auth #api_information_panel'), function(k, v) { + var children = v; + if(children && children.childNodes) { + var requiredScopes = []; + $.each((children.childNodes), function (k1, v1){ + var inner = v1.innerHTML; + if(inner) + requiredScopes.push(inner); + }); + var diff = []; + for(var i=0; i < requiredScopes.length; i++) { + var s = requiredScopes[i]; + if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) { + diff.push(s); + } + } + if(diff.length > 0){ + o = v.parentNode; + $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off'); + $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on'); + + // sorry, not all scopes are satisfied + $(o).find('.api-ic').addClass('ic-warning'); + $(o).find('.api-ic').removeClass('ic-error'); + } + else { + o = v.parentNode; + $(o.parentNode).find('.api-ic.ic-off').addClass('ic-on'); + $(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off'); + + // all scopes are satisfied + $(o).find('.api-ic').addClass('ic-info'); + $(o).find('.api-ic').removeClass('ic-warning'); + $(o).find('.api-ic').removeClass('ic-error'); + } + } + }); + + window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header")); + } + } + } +} \ No newline at end of file diff --git a/tastypie_swagger/static/tastypie_swagger/js/lib/swagger.js b/tastypie_swagger/static/tastypie_swagger/js/lib/swagger.js old mode 100644 new mode 100755 index 73cf3a8..8ea25d7 --- a/tastypie_swagger/static/tastypie_swagger/js/lib/swagger.js +++ b/tastypie_swagger/static/tastypie_swagger/js/lib/swagger.js @@ -1,748 +1,1603 @@ -// Generated by CoffeeScript 1.4.0 -(function() { - var SwaggerApi, SwaggerModel, SwaggerModelProperty, SwaggerOperation, SwaggerRequest, SwaggerResource, - __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; +// swagger.js +// version 2.0.37 - SwaggerApi = (function() { +var __bind = function(fn, me){ + return function(){ + return fn.apply(me, arguments); + }; +}; - SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json"; +log = function(){ + log.history = log.history || []; + log.history.push(arguments); + if(this.console){ + console.log( Array.prototype.slice.call(arguments)[0] ); + } +}; - SwaggerApi.prototype.debug = false; +if (!Array.prototype.indexOf) { + Array.prototype.indexOf = function(obj, start) { + for (var i = (start || 0), j = this.length; i < j; i++) { + if (this[i] === obj) { return i; } + } + return -1; + } +} - SwaggerApi.prototype.api_key = null; +if (!('filter' in Array.prototype)) { + Array.prototype.filter= function(filter, that /*opt*/) { + var other= [], v; + for (var i=0, n= this.length; i 0) { - _this.basePath = response.basePath; - if (_this.basePath.match(/^HTTP/i) == null) { - _this.fail("discoveryUrl basePath must be a URL."); - } - _this.basePath = _this.basePath.replace(/\/$/, ''); + return result; + }; +})(); + +var SwaggerApi = function(url, options) { + this.url = null; + this.debug = false; + this.basePath = null; + this.authorizations = null; + this.authorizationScheme = null; + this.info = null; + this.useJQuery = false; + + options = (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; + + if (typeof options.useJQuery === 'boolean') + this.useJQuery = options.useJQuery; + + 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 _this = this; + this.progress('fetching resource list: ' + this.url); + var obj = { + useJQuery: this.useJQuery, + url: this.url, + method: "get", + headers: { + accept: "application/json" + }, + on: { + error: function(response) { + if (_this.url.substring(0, 4) !== 'http') { + return _this.fail('Please specify the protocol for ' + _this.url); + } else if (response.status === 0) { + return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.'); + } else if (response.status === 404) { + return _this.fail('Can\'t read swagger JSON from ' + _this.url); } else { - _this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('/')); - log('derived basepath from discoveryUrl as ' + _this.basePath); + return _this.fail(response.status + ' : ' + response.statusText + ' ' + _this.url); } - _this.resources = {}; - _this.resourcesArray = []; - if (response.resourcePath != null) { - _this.resourcePath = response.resourcePath; - res = null; - _ref = response.apis; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - resource = _ref[_i]; - if (res === null) { - res = new SwaggerResource(resource, _this); - } else { - res.addOperations(resource.path, resource.operations); - } - } - if (res != null) { - _this.resources[res.name] = res; - _this.resourcesArray.push(res); - res.ready = true; - _this.selfReflect(); - } + }, + response: function(resp) { + var responseObj = resp.obj || JSON.parse(resp.data); + _this.swaggerVersion = responseObj.swaggerVersion; + if (_this.swaggerVersion === "1.2") { + return _this.buildFromSpec(responseObj); } else { - _ref1 = response.apis; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - resource = _ref1[_j]; - res = new SwaggerResource(resource, _this); - _this.resources[res.name] = res; - _this.resourcesArray.push(res); - } + return _this.buildFrom1_1Spec(responseObj); } - return _this; - }).error(function(error) { - return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl); - }); - }; + } + } + }; + var e = (typeof window !== 'undefined' ? window : exports); + e.authorizations.apply(obj); + new SwaggerHttp().execute(obj); + return this; +}; - SwaggerApi.prototype.selfReflect = function() { - var resource, resource_name, _ref; - if (this.resources == null) { - return false; +SwaggerApi.prototype.buildFromSpec = function(response) { + if (response.apiVersion != null) { + this.apiVersion = response.apiVersion; + } + this.apis = {}; + this.apisArray = []; + this.consumes = response.consumes; + this.produces = response.produces; + this.authSchemes = response.authorizations; + if (response.info != null) { + this.info = response.info; + } + var isApi = false; + var i; + for (i = 0; i < response.apis.length; i++) { + var api = response.apis[i]; + if (api.operations) { + var j; + for (j = 0; j < api.operations.length; j++) { + operation = api.operations[j]; + isApi = true; } - _ref = this.resources; - for (resource_name in _ref) { - resource = _ref[resource_name]; - if (resource.ready == null) { - return false; - } + } + } + 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) { + var newName = response.resourcePath.replace(/\//g, ''); + this.resourcePath = response.resourcePath; + res = new SwaggerResource(response, this); + this.apis[newName] = res; + this.apisArray.push(res); + } else { + var k; + for (k = 0; k < response.apis.length; k++) { + var resource = response.apis[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) { + 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; + } + var isApi = false; + for (var i = 0; i < response.apis.length; i++) { + var api = response.apis[i]; + if (api.operations) { + for (var j = 0; j < api.operations.length; j++) { + operation = api.operations[j]; + isApi = true; } - this.setConsolidatedModels(); - this.ready = true; - if (this.success != null) { - return this.success(); + } + } + 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) { + var newName = response.resourcePath.replace(/\//g, ''); + this.resourcePath = response.resourcePath; + var res = new SwaggerResource(response, this); + this.apis[newName] = res; + this.apisArray.push(res); + } else { + for (k = 0; k < response.apis.length; k++) { + resource = response.apis[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.fail = function(message) { - this.failure(message); - throw message; - }; +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]; + log(resource_name); + _ref1 = resource.operations; + for (operation_name in _ref1) { + operation = _ref1[operation_name]; + log(" " + operation.nickname); + _ref2 = operation.parameters; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + parameter = _ref2[_i]; + log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description); + } + } + } + return this; +}; - SwaggerApi.prototype.setConsolidatedModels = function() { - var model, modelName, resource, resource_name, _i, _len, _ref, _ref1, _results; - this.modelsArray = []; - this.models = {}; - _ref = this.resources; - 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]); - } +var SwaggerResource = function(resourceObj, api) { + var _this = this; + this.api = api; + this.api = this.api; + consumes = (this.consumes | []); + produces = (this.produces | []); + this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path; + this.description = resourceObj.description; + + var 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 = {}; + this.rawModels = {}; + this.useJQuery = (typeof api.useJQuery !== 'undefined' ? api.useJQuery : null); + + 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); + obj = { + url: this.url, + method: "get", + useJQuery: this.useJQuery, + headers: { + accept: "application/json" + }, + on: { + response: function(resp) { + var responseObj = resp.obj || JSON.parse(resp.data); + return _this.addApiDeclaration(responseObj); + }, + error: function(response) { + return _this.api.fail("Unable to read api '" + + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")"); } } - _ref1 = this.modelsArray; - _results = []; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - model = _ref1[_i]; - _results.push(model.setReferencedModels(this.models)); - } - return _results; }; + var e = typeof window !== 'undefined' ? window : exports; + e.authorizations.apply(obj); + new SwaggerHttp().execute(obj); + } +} - SwaggerApi.prototype.suffixApiKey = function(url) { - var sep; - if ((this.api_key != null) && jQuery.trim(this.api_key).length > 0 && (url != null)) { - sep = url.indexOf('?') > 0 ? '&' : '?'; - return url + sep + this.apiKeyName + '=' + this.api_key; - } else { - return url; +SwaggerResource.prototype.getAbsoluteBasePath = function (relativeBasePath) { + var pos, url; + url = this.api.basePath; + pos = url.lastIndexOf(relativeBasePath); + var parts = url.split("/"); + var rootUrl = parts[0] + "//" + parts[2]; + + if(relativeBasePath.indexOf("http") === 0) + return relativeBasePath; + if(relativeBasePath === "/") + return rootUrl; + if(relativeBasePath.substring(0, 1) == "/") { + // use root + relative + return rootUrl + relativeBasePath; + } + else { + var pos = this.basePath.lastIndexOf("/"); + var base = this.basePath.substring(0, pos); + if(base.substring(base.length - 1) == "/") + return base + relativeBasePath; + else + return base + "/" + relativeBasePath; + } +}; + +SwaggerResource.prototype.addApiDeclaration = function(response) { + 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.indexOf("http") === -1 ? this.getAbsoluteBasePath(response.basePath) : response.basePath; + + this.addModels(response.models); + if (response.apis) { + for (var i = 0 ; i < response.apis.length; i++) { + var endpoint = response.apis[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) { + if (models != null) { + var modelName; + for (modelName in models) { + if (this.models[modelName] == null) { + var swaggerModel = new SwaggerModel(modelName, models[modelName]); + this.modelsArray.push(swaggerModel); + this.models[modelName] = swaggerModel; + this.rawModels[modelName] = models[modelName]; } - }; + } + var output = []; + for (var i = 0; i < this.modelsArray.length; i++) { + model = this.modelsArray[i]; + output.push(model.setReferencedModels(this.models)); + } + return output; + } +}; - SwaggerApi.prototype.help = function() { - var operation, operation_name, parameter, resource, resource_name, _i, _len, _ref, _ref1, _ref2; - _ref = this.resources; - 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); - } +SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, produces) { + if (ops) { + output = []; + for (var i = 0; i < ops.length; 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 (var j = 0; j < responseMessages.length; j++) { + r = responseMessages[j]; + r.message = r.reason; + r.reason = null; } } - return this; - }; + 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, o.authorizations); + this.operations[op.nickname] = op; + output.push(this.operationsArray.push(op)); + } + return output; + } +}; - return SwaggerApi; - - })(); - - SwaggerResource = (function() { - - function SwaggerResource(resourceObj, api) { - var parts, - _this = this; - this.api = api; - 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.operations != null) && (this.api.resourcePath != null)) { - this.api.progress('reading resource ' + this.name + ' models and operations'); - this.addModels(resourceObj.models); - this.addOperations(resourceObj.path, resourceObj.operations); - this.api[this.name] = this; - } else { - if (this.path == null) { - this.api.fail("SwaggerResources must have a path."); +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 op = this.operations; + var output = []; + var operation_name; + for (operation_name in op) { + operation = op[operation_name]; + var msg = " " + operation.nickname; + for (var i = 0; i < operation.parameters; i++) { + parameter = operation.parameters[i]; + msg.concat(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description); + } + output.push(msg); + } + return output; +}; + +var SwaggerModel = function(modelName, obj) { + this.name = obj.id != null ? obj.id : modelName; + this.properties = []; + var propertyName; + for (propertyName in obj.properties) { + if (obj.required != null) { + var value; + for (value in obj.required) { + if (propertyName === obj.required[value]) { + obj.properties[propertyName].required = true; } - this.url = this.api.suffixApiKey(this.api.basePath + this.path.replace('{format}', 'json')); - this.api.progress('fetching resource ' + this.name + ': ' + this.url); - jQuery.getJSON(this.url, function(response) { - var endpoint, _i, _len, _ref; - if ((response.basePath != null) && jQuery.trim(response.basePath).length > 0) { - _this.basePath = response.basePath; - _this.basePath = _this.basePath.replace(/\/$/, ''); - } - _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); + } + } + prop = new SwaggerModelProperty(propertyName, obj.properties[propertyName]); + this.properties.push(prop); + } +} + +SwaggerModel.prototype.setReferencedModels = function(allModels) { + var results = []; + for (var i = 0; i < this.properties.length; i++) { + var property = this.properties[i]; + var type = property.type || property.dataType; + if (allModels[type] != null) + results.push(property.refModel = allModels[type]); + else if ((property.refDataType != null) && (allModels[property.refDataType] != null)) + results.push(property.refModel = allModels[property.refDataType]); + else + results.push(void 0); + } + return results; +}; + +SwaggerModel.prototype.getMockSignature = function(modelsToIgnore) { + var propertiesStr = []; + for (var i = 0; i < this.properties.length; i++) { + prop = this.properties[i]; + propertiesStr.push(prop.toString()); + } + + var strong = ''; + var stronger = ''; + var strongClose = ''; + var classOpen = strong + this.name + ' {' + strongClose; + var classClose = strong + '}' + strongClose; + var returnVal = classOpen + '
    ' + propertiesStr.join(',
    ') + '
    ' + classClose; + if (!modelsToIgnore) + modelsToIgnore = []; + modelsToIgnore.push(this.name); + + for (var i = 0; i < this.properties.length; i++) { + prop = this.properties[i]; + if ((prop.refModel != null) && modelsToIgnore.indexOf(prop.refModel.name) === -1) { + returnVal = returnVal + ('
    ' + prop.refModel.getMockSignature(modelsToIgnore)); + } + } + return returnVal; +}; + +SwaggerModel.prototype.createJSONSample = function(modelsToIgnore) { + if(sampleModels[this.name]) { + return sampleModels[this.name]; + } + else { + var result = {}; + var modelsToIgnore = (modelsToIgnore||[]) + modelsToIgnore.push(this.name); + for (var i = 0; i < this.properties.length; i++) { + prop = this.properties[i]; + result[prop.name] = prop.getSampleValue(modelsToIgnore); + } + modelsToIgnore.pop(this.name); + return result; + } +}; + +var SwaggerModelProperty = function(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(prop.refModel.name) === -1)) { + result = this.refModel.createJSONSample(modelsToIgnore); + } else { + if (this.isCollection) { + result = this.toSampleValue(this.refDataType); + } else { + result = this.toSampleValue(this.dataType); + } + } + if (this.isCollection) { + return [result]; + } else { + return result; + } +}; + +SwaggerModelProperty.prototype.toSampleValue = function(value) { + var result; + if (value === "integer") { + result = 0; + } else if (value === "boolean") { + result = false; + } else if (value === "double" || value === "number") { + result = 0.0; + } else if (value === "string") { + result = ""; + } else { + result = value; + } + return result; +}; + +SwaggerModelProperty.prototype.toString = function() { + var req = this.required ? 'propReq' : 'propOpt'; + var 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; +}; + +var SwaggerOperation = function(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces, authorizations) { + var _this = this; + + var errors = []; + this.nickname = (nickname||errors.push("SwaggerOperations must have a nickname.")); + this.path = (path||errors.push("SwaggerOperation " + nickname + " is missing path.")); + this.method = (method||errors.push("SwaggerOperation " + nickname + " is missing method.")); + this.parameters = parameters != null ? parameters : []; + this.summary = summary; + this.notes = notes; + this.type = type; + this.responseMessages = (responseMessages||[]); + this.resource = (resource||errors.push("Resource is required")); + this.consumes = consumes; + this.produces = produces; + this.authorizations = authorizations; + this["do"] = __bind(this["do"], this); + + if (errors.length > 0) + this.resource.api.fail(errors); + + this.path = this.path.replace('{format}', 'json'); + this.method = this.method.toLowerCase(); + this.isGetMethod = this.method === "get"; + + this.resourceName = this.resource.name; + if(typeof this.type !== 'undefined' && this.type === 'void') + this.type = null; + else { + this.responseClassSignature = this.getSignature(this.type, this.resource.models); + this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models); + } + + for(var i = 0; i < this.parameters.length; i ++) { + var param = this.parameters[i]; + // might take this away + param.name = param.name || param.type || param.dataType; + + // for 1.1 compatibility + var type = param.type || param.dataType; + if(type === 'array') { + type = 'array[' + (param.items.$ref ? param.items.$ref : param.items.type) + ']'; + } + param.type = type; + + if(type.toLowerCase() === 'boolean') { + param.allowableValues = {}; + param.allowableValues.values = ["true", "false"]; + } + param.signature = this.getSignature(type, this.resource.models); + param.sampleJSON = this.getSampleJSON(type, this.resource.models); + + var enumValue = param["enum"]; + if(enumValue != null) { + param.isList = true; + param.allowableValues = {}; + param.allowableValues.descriptiveValues = []; + + for(var j = 0; j < enumValue.length; j++) { + var v = enumValue[j]; + if(param.defaultValue != null) { + param.allowableValues.descriptiveValues.push ({ + value: String(v), + isDefault: (v === param.defaultValue) + }); + } + else { + param.allowableValues.descriptiveValues.push ({ + value: String(v), + isDefault: false + }); + } + } + } + else if(param.allowableValues != null) { + if(param.allowableValues.valueType === "RANGE") + param.isRange = true; + else + param.isList = true; + if(param.allowableValues != null) { + param.allowableValues.descriptiveValues = []; + if(param.allowableValues.values) { + for(var j = 0; j < param.allowableValues.values.length; j++){ + var v = param.allowableValues.values[j]; + if(param.defaultValue != null) { + param.allowableValues.descriptiveValues.push ({ + value: String(v), + isDefault: (v === param.defaultValue) + }); + } + else { + param.allowableValues.descriptiveValues.push ({ + value: String(v), + isDefault: false + }); } - } - _this.api[_this.name] = _this; - _this.ready = true; - return _this.api.selfReflect(); - }).error(function(error) { - return _this.api.fail(error.status + ' : ' + error.statusText + ' ' + _this.url); - }); - } - } - - 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; } - }; + } + } + this.resource[this.nickname] = function(args, callback, error) { + return _this["do"](args, callback, error); + }; + this.resource[this.nickname].help = function() { + return _this.help(); + }; +} - SwaggerResource.prototype.addOperations = function(resource_path, ops) { - var o, op, _i, _len, _results; - if (ops) { - _results = []; - for (_i = 0, _len = ops.length; _i < _len; _i++) { - o = ops[_i]; - op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, o.errorResponses, this, o.supportedContentTypes); - this.operations[op.nickname] = op; - _results.push(this.operationsArray.push(op)); - } - return _results; +SwaggerOperation.prototype.isListType = function(type) { + if (type && 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; + if(typeof val == "string") + return val; + else if(typeof val === "object") { + var t = val; + if(val instanceof Array && val.length > 0) { + t = val[0]; + } + if(t.nodeName) { + var xmlString = new XMLSerializer().serializeToString(t); + return this.formatXml(xmlString); + } + else + return JSON.stringify(val, null, 2); + } + else + return val; + } +}; + +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 log(xhr, textStatus, error); + }; + } + if (callback == null) { + callback = function(response) { + var content; + content = null; + if (response != null) { + content = response.data; + } else { + content = "no data"; } + return log("default callback: " + content); }; + } + params = {}; + params.headers = []; + if (args.headers != null) { + params.headers = args.headers; + delete args.headers; + } - SwaggerResource.prototype.help = function() { - var operation, operation_name, parameter, _i, _len, _ref, _ref1; - _ref = this.operations; - for (operation_name in _ref) { - operation = _ref[operation_name]; - console.log(" " + operation.nickname); - _ref1 = operation.parameters; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - parameter = _ref1[_i]; - console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description); - } + var possibleParams = []; + for(var i = 0; i < this.parameters.length; i++) { + var param = this.parameters[i]; + if(param.paramType === 'header') { + if(args[param.name]) + params.headers[param.name] = args[param.name]; + } + else if(param.paramType === 'form' || param.paramType.toLowerCase() === 'file') + possibleParams.push(param); + } + + if (args.body != null) { + params.body = args.body; + delete args.body; + } + + if (possibleParams) { + var key; + for (key in possibleParams) { + value = possibleParams[key]; + if (args[value.name]) { + params[value.name] = args[value.name]; } - return this; - }; + } + } + + req = new SwaggerRequest(this.method, this.urlify(args), params, opts, callback, error, this); + if (opts.mock != null) { + return req; + } else { + return true; + } +}; - return SwaggerResource; +SwaggerOperation.prototype.pathJson = function() { + return this.path.replace("{format}", "json"); +}; - })(); +SwaggerOperation.prototype.pathXml = function() { + return this.path.replace("{format}", "xml"); +}; - SwaggerModel = (function() { +SwaggerOperation.prototype.encodePathParam = function(pathParam) { + var encParts, part, parts, _i, _len; + pathParam = pathParam.toString(); + if (pathParam.indexOf("/") === -1) { + return encodeURIComponent(pathParam); + } else { + parts = pathParam.split("/"); + encParts = []; + for (_i = 0, _len = parts.length; _i < _len; _i++) { + part = parts[_i]; + encParts.push(encodeURIComponent(part)); + } + return encParts.join("/"); + } +}; - function SwaggerModel(modelName, obj) { - var propertyName; - this.name = obj.id != null ? obj.id : modelName; - this.properties = []; - for (propertyName in obj.properties) { - this.properties.push(new SwaggerModelProperty(propertyName, obj.properties[propertyName])); +SwaggerOperation.prototype.urlify = function(args) { + var url = this.resource.basePath + this.pathJson(); + var params = this.parameters; + for(var i = 0; i < params.length; i ++){ + var param = params[i]; + if (param.paramType === 'path') { + if(args[param.name]) { + // apply path params and remove from args + var reg = new RegExp('\{' + param.name + '[^\}]*\}', 'gi'); + url = url.replace(reg, this.encodePathParam(args[param.name])); + delete args[param.name]; + } + else + throw "" + param.name + " is a required path param."; + } + } + + var queryParams = ""; + for(var i = 0; i < params.length; i ++){ + var param = params[i]; + if(param.paramType === 'query') { + if (args[param.name] !== undefined) { + 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 = {}; + var params = this.parameters; + for (var i = 0; i < params.length; i++) { + param = params[i]; + if (args && args[param.name]) + matchingParams[param.name] = args[param.name]; + } + var headers = this.resource.api.headers; + var name; + for (name in headers) { + var value = headers[name]; + matchingParams[name] = value; + } + return matchingParams; +}; + +SwaggerOperation.prototype.help = function() { + var msg = ""; + var params = this.parameters; + for (var i = 0; i < params.length; i++) { + var param = params[i]; + if (msg !== "") + msg += "\n"; + msg += "* " + param.name + (param.required ? ' (required)' : '') + " - " + param.description; + } + return msg; +}; - SwaggerModel.prototype.setReferencedModels = function(allModels) { - var prop, _i, _len, _ref, _results; - _ref = this.properties; + +SwaggerOperation.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 (_i = 0, _len = _ref.length; _i < _len; _i++) { - prop = _ref[_i]; - if (allModels[prop.dataType] != null) { - _results.push(prop.refModel = allModels[prop.dataType]); - } else if ((prop.refDataType != null) && (allModels[prop.refDataType] != null)) { - _results.push(prop.refModel = allModels[prop.refDataType]); - } else { - _results.push(void 0); + for (key in types) { + value = types[key]; + if (value) { + _results.push(key); } } return _results; - }; - - SwaggerModel.prototype.getMockSignature = function(prefix, modelToIgnore) { - 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 + 'class ' + this.name + '(' + strongClose; - classClose = strong + ')' + strongClose; - returnVal = classOpen + '' + propertiesStr.join(', ') + '' + classClose; - if (prefix != null) { - returnVal = stronger + prefix + strongClose + '
    ' + returnVal; - } - _ref1 = this.properties; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - prop = _ref1[_j]; - if ((prop.refModel != null) && (!(prop.refModel === modelToIgnore))) { - returnVal = returnVal + ('
    ' + prop.refModel.getMockSignature(void 0, this)); - } + })())[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 returnVal; - }; + 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; +}; - SwaggerModel.prototype.createJSONSample = function(modelToIgnore) { - var prop, result, _i, _len, _ref; - result = {}; - _ref = this.properties; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - prop = _ref[_i]; - result[prop.name] = prop.getSampleValue(modelToIgnore); - } - return result; - }; +var SwaggerRequest = function(type, url, params, opts, successCallback, errorCallback, operation, execution) { + var _this = this; + var errors = []; + this.useJQuery = (typeof operation.resource.useJQuery !== 'undefined' ? operation.resource.useJQuery : null); + this.type = (type||errors.push("SwaggerRequest type is required (get/post/put/delete/patch/options).")); + this.url = (url||errors.push("SwaggerRequest url is required.")); + this.params = params; + this.opts = opts; + this.successCallback = (successCallback||errors.push("SwaggerRequest successCallback is required.")); + this.errorCallback = (errorCallback||errors.push("SwaggerRequest error callback is required.")); + this.operation = (operation||errors.push("SwaggerRequest operation is required.")); + this.execution = execution; + this.headers = (params.headers||{}); - return SwaggerModel; + if(errors.length > 0) { + throw errors; + } - })(); + this.type = this.type.toUpperCase(); - SwaggerModelProperty = (function() { + // set request, response content type headers + var headers = this.setHeaders(params, this.operation); + var body = params.body; - function SwaggerModelProperty(name, obj) { - this.name = name; - this.dataType = obj.type; - this.isArray = this.dataType.toLowerCase() === 'array'; - this.descr = obj.description; - if (obj.items != null) { - if (obj.items.type != null) { - this.refDataType = obj.items.type; - } - if (obj.items.$ref != null) { - this.refDataType = obj.items.$ref; + // encode the body for form submits + if (headers["Content-Type"]) { + var values = {}; + var i; + var operationParams = this.operation.parameters; + for(i = 0; i < operationParams.length; i++) { + var param = operationParams[i]; + if(param.paramType === "form") + values[param.name] = param; + } + + if(headers["Content-Type"].indexOf("application/x-www-form-urlencoded") === 0) { + var encoded = ""; + var key; + for(key in values) { + value = this.params[key]; + if(typeof value !== 'undefined'){ + if(encoded !== "") + encoded += "&"; + encoded += encodeURIComponent(key) + '=' + encodeURIComponent(value); } } - 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 '") + "'"; + body = encoded; + } + else if (headers["Content-Type"].indexOf("multipart/form-data") === 0) { + // encode the body for form submits + var data = ""; + var boundary = "----SwaggerFormBoundary" + Date.now(); + var key; + for(key in values) { + value = this.params[key]; + if(typeof value !== 'undefined') { + data += '--' + boundary + '\n'; + data += 'Content-Disposition: form-data; name="' + key + '"'; + data += '\n\n'; + data += value + "\n"; } } + data += "--" + boundary + "--\n"; + headers["Content-Type"] = "multipart/form-data; boundary=" + boundary; + body = data; } + } - SwaggerModelProperty.prototype.getSampleValue = function(modelToIgnore) { - var result; - if ((this.refModel != null) && (!(this.refModel === modelToIgnore))) { - result = this.refModel.createJSONSample(this.refModel); - } else { - if (this.isArray) { - result = this.refDataType; - } else { - result = this.dataType; + if (!((this.headers != null) && (this.headers.mock != null))) { + obj = { + url: this.url, + method: this.type, + headers: headers, + body: body, + useJQuery: this.useJQuery, + 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); } } - if (this.isArray) { - return [result]; + }; + var e; + if (typeof window !== 'undefined') { + e = window; + } else { + e = exports; + } + status = e.authorizations.apply(obj, this.operation.authorizations); + if (opts.mock == null) { + if (status !== false) { + new SwaggerHttp().execute(obj); } else { - return result; + obj.canceled = true; } - }; + } else { + return obj; + } + } +}; - SwaggerModelProperty.prototype.toString = function() { - var str; - str = this.name + ': ' + this.dataTypeWithRef; - if (this.values != null) { - str += " = ['" + this.values.join("' or '") + "']"; - } - if (this.descr != null) { - str += ' {' + this.descr + '}'; - } - return str; - }; +SwaggerRequest.prototype.setHeaders = function(params, operation) { + // default type + var accepts = "application/json"; + var consumes = "application/json"; - return SwaggerModelProperty; - - })(); - - SwaggerOperation = (function() { - - function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource, supportedContentTypes) { - var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2, - _this = this; - this.nickname = nickname; - this.path = path; - this.httpMethod = httpMethod; - this.parameters = parameters != null ? parameters : []; - this.summary = summary; - this.notes = notes; - this.responseClass = responseClass; - this.errorResponses = errorResponses; - this.resource = resource; - this.supportedContentTypes = supportedContentTypes; - 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.httpMethod == null) { - this.resource.api.fail("SwaggerOperation " + nickname + " is missing httpMethod."); - } - this.path = this.path.replace('{format}', 'json'); - this.httpMethod = this.httpMethod.toLowerCase(); - this.isGetMethod = this.httpMethod === "get"; - this.resourceName = this.resource.name; - if (((_ref = this.responseClass) != null ? _ref.toLowerCase() : void 0) === 'void') { - this.responseClass = void 0; - } - if (this.responseClass != null) { - this.responseClassSignature = this.getSignature(this.responseClass, this.resource.models); - this.responseSampleJSON = this.getSampleJSON(this.responseClass, this.resource.models); - } - this.errorResponses = this.errorResponses || []; - _ref1 = this.parameters; - for (_i = 0, _len = _ref1.length; _i < _len; _i++) { - parameter = _ref1[_i]; - parameter.name = parameter.name || parameter.dataType; - if (parameter.dataType.toLowerCase() === 'boolean') { - parameter.allowableValues = {}; - parameter.allowableValues.values = this.resource.api.booleanValues; - } - parameter.signature = this.getSignature(parameter.dataType, this.resource.models); - parameter.sampleJSON = this.getSampleJSON(parameter.dataType, this.resource.models); - if (parameter.allowableValues != null) { - if (parameter.allowableValues.valueType === "RANGE") { - parameter.isRange = true; - } else { - parameter.isList = true; - } - if (parameter.allowableValues.values != null) { - parameter.allowableValues.descriptiveValues = []; - _ref2 = parameter.allowableValues.values; - 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 - }); - } - } - } - } - } - this.resource[this.nickname] = function(args, callback, error) { - return _this["do"](args, callback, error); - }; + var allDefinedParams = this.operation.parameters; + var definedFormParams = []; + var definedFileParams = []; + var body = params.body; + var headers = {}; + + // get params from the operation and set them in definedFileParams, definedFormParams, headers + var i; + for(i = 0; i < allDefinedParams.length; i++) { + var param = allDefinedParams[i]; + if(param.paramType === "form") + definedFormParams.push(param); + else if(param.paramType === "file") + definedFileParams.push(param); + else if(param.paramType === "header" && this.params.headers) { + var key = param.name; + var headerValue = this.params.headers[param.name]; + if(typeof this.params.headers[param.name] !== 'undefined') + headers[key] = headerValue; } + } - SwaggerOperation.prototype.isListType = function(dataType) { - if (dataType.indexOf('[') >= 0) { - return dataType.substring(dataType.indexOf('[') + 1, dataType.indexOf(']')); - } else { - return void 0; + // if there's a body, need to set the accepts header via requestContentType + if (body && (this.type === "POST" || this.type === "PUT" || this.type === "PATCH" || this.type === "DELETE")) { + if (this.opts.requestContentType) + accepts = this.opts.requestContentType; + } else { + // if any form params, content type must be set + if(definedFormParams.length > 0) { + if(definedFileParams.length > 0) + consumes = "multipart/form-data"; + else + consumes = "application/x-www-form-urlencoded"; + } + else if (this.type == "DELETE") + body = "{}"; + else if (this.type != "DELETE") + accepts = null; + } + + if (consumes && this.operation.consumes) { + if (this.operation.consumes.indexOf(consumes) === -1) { + log("server doesn't consume " + consumes + ", try " + JSON.stringify(this.operation.consumes)); + consumes = this.operation.consumes[0]; + } + } + + if (this.opts.responseContentType) { + accepts = this.opts.responseContentType; + } else { + accepts = "application/json"; + } + if (accepts && this.operation.produces) { + if (this.operation.produces.indexOf(accepts) === -1) { + log("server can't produce " + accepts); + accepts = this.operation.produces[0]; + } + } + + if ((consumes && body !== "") || (consumes === "application/x-www-form-urlencoded")) + headers["Content-Type"] = consumes; + if (accepts) + headers["Accept"] = accepts; + return headers; +} + +SwaggerRequest.prototype.asCurl = function() { + var results = []; + if(this.headers) { + var key; + for(key in this.headers) { + results.push("--header \"" + key + ": " + this.headers[v] + "\""); + } + } + return "curl " + (results.join(" ")) + " " + this.url; +}; + +/** + * SwaggerHttp is a wrapper for executing requests + */ +var SwaggerHttp = function() {}; + +SwaggerHttp.prototype.execute = function(obj) { + if(obj && (typeof obj.useJQuery === 'boolean')) + this.useJQuery = obj.useJQuery; + else + this.useJQuery = this.isIE8(); + + if(this.useJQuery) + return new JQueryHttpClient().execute(obj); + else + return new ShredHttpClient().execute(obj); +} + +SwaggerHttp.prototype.isIE8 = function() { + var detectedIE = false; + if (typeof navigator !== 'undefined' && navigator.userAgent) { + nav = navigator.userAgent.toLowerCase(); + if (nav.indexOf('msie') !== -1) { + var version = parseInt(nav.split('msie')[1]); + if (version <= 8) { + detectedIE = true; } - }; + } + } + return detectedIE; +}; - SwaggerOperation.prototype.getSignature = function(dataType, models) { - var isPrimitive, listType; - listType = this.isListType(dataType); - isPrimitive = ((listType != null) && models[listType]) || (models[dataType] != null) ? false : true; - if (isPrimitive) { - return dataType; - } else { - if (listType != null) { - return models[listType].getMockSignature(dataType); +/* + * JQueryHttpClient lets a browser take advantage of JQuery's cross-browser magic. + * NOTE: when jQuery is available it will export both '$' and 'jQuery' to the global space. + * Since we are using closures here we need to alias it for internal use. + */ +var JQueryHttpClient = function(options) { + "use strict"; + if(!jQuery){ + var jQuery = window.jQuery; + } +} + +JQueryHttpClient.prototype.execute = function(obj) { + var cb = obj.on; + var request = obj; + + obj.type = obj.method; + obj.cache = false; + + obj.beforeSend = function(xhr) { + var key, results; + if (obj.headers) { + results = []; + var key; + for (key in obj.headers) { + if (key.toLowerCase() === "content-type") { + results.push(obj.contentType = obj.headers[key]); + } else if (key.toLowerCase() === "accept") { + results.push(obj.accepts = obj.headers[key]); } else { - return models[dataType].getMockSignature(dataType); + results.push(xhr.setRequestHeader(key, obj.headers[key])); } } - }; + return results; + } + }; - SwaggerOperation.prototype.getSampleJSON = function(dataType, models) { - var isPrimitive, listType, val; - listType = this.isListType(dataType); - isPrimitive = ((listType != null) && models[listType]) || (models[dataType] != null) ? false : true; - val = isPrimitive ? void 0 : (listType != null ? models[listType].createJSONSample() : models[dataType].createJSONSample()); - if (val) { - val = listType ? [val] : val; - return JSON.stringify(val, null, 2); - } - }; + obj.data = obj.body; + obj.complete = function(response, textStatus, opts) { + var headers = {}, + headerArray = response.getAllResponseHeaders().split("\n"); - SwaggerOperation.prototype["do"] = function(args, callback, error) { - var body, headers; - if (args == null) { - args = {}; - } - if ((typeof args) === "function") { - error = callback; - callback = args; - args = {}; - } - if (error == null) { - error = function(xhr, textStatus, error) { - return console.log(xhr, textStatus, error); - }; - } - if (callback == null) { - callback = function(data) { - return console.log(data); - }; - } - if (args.headers != null) { - headers = args.headers; - delete args.headers; - } - if (args.body != null) { - body = args.body; - delete args.body; - } - return new SwaggerRequest(this.httpMethod, this.urlify(args), headers, body, callback, error, this); - }; + for(var i = 0; i < headerArray.length; i++) { + var toSplit = headerArray[i].trim(); + if(toSplit.length === 0) + continue; + var separator = toSplit.indexOf(":"); + if(separator === -1) { + // Name but no value in the header + headers[toSplit] = null; + continue; + } + var name = toSplit.substring(0, separator).trim(), + value = toSplit.substring(separator + 1).trim(); + headers[name] = value; + } - SwaggerOperation.prototype.pathJson = function() { - return this.path.replace("{format}", "json"); + var out = { + url: request.url, + method: request.method, + status: response.status, + data: response.responseText, + headers: headers }; - SwaggerOperation.prototype.pathXml = function() { - return this.path.replace("{format}", "xml"); - }; + var contentType = (headers["content-type"]||headers["Content-Type"]||null) - SwaggerOperation.prototype.urlify = function(args, includeApiKey) { - var param, queryParams, reg, url, _i, _len, _ref; - if (includeApiKey == null) { - includeApiKey = true; - } - 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."; - } - } - } - if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) { - args[this.apiKeyName] = this.resource.api.api_key; + if(contentType != null) { + if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { + if(response.responseText && response.responseText !== "") + out.obj = JSON.parse(response.responseText); + else + out.obj = {} } - if (this.supportHeaderParams()) { - queryParams = jQuery.param(this.getQueryParams(args, includeApiKey)); - } else { - queryParams = jQuery.param(this.getQueryAndHeaderParams(args, includeApiKey)); - } - if ((queryParams != null) && queryParams.length > 0) { - url += "?" + queryParams; - } - return url; - }; + } - SwaggerOperation.prototype.supportHeaderParams = function() { - return this.resource.api.supportHeaderParams; - }; + if(response.status >= 200 && response.status < 300) + cb.response(out); + else if(response.status === 0 || (response.status >= 400 && response.status < 599)) + cb.error(out); + else + return cb.response(out); + }; - SwaggerOperation.prototype.supportedSubmitMethods = function() { - return this.resource.api.supportedSubmitMethods; - }; + jQuery.support.cors = true; + return jQuery.ajax(obj); +} - SwaggerOperation.prototype.getQueryAndHeaderParams = function(args, includeApiKey) { - if (includeApiKey == null) { - includeApiKey = true; - } - return this.getMatchingParams(['query', 'header'], args, includeApiKey); - }; +/* + * ShredHttpClient is a light-weight, node or browser HTTP client + */ +var ShredHttpClient = function(options) { + this.options = (options||{}); + this.isInitialized = false; - SwaggerOperation.prototype.getQueryParams = function(args, includeApiKey) { - if (includeApiKey == null) { - includeApiKey = true; - } - return this.getMatchingParams(['query'], args, includeApiKey); - }; + var identity, toString; - SwaggerOperation.prototype.getHeaderParams = function(args, includeApiKey) { - if (includeApiKey == null) { - includeApiKey = true; - } - return this.getMatchingParams(['header'], args, includeApiKey); - }; + if (typeof window !== 'undefined') { + this.Shred = require("./shred"); + this.content = require("./shred/content"); + } + else + this.Shred = require("shred"); + this.shred = new this.Shred(); +} - SwaggerOperation.prototype.getMatchingParams = function(paramTypes, args, includeApiKey) { - 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 ((jQuery.inArray(param.paramType, paramTypes) >= 0) && args[param.name]) { - matchingParams[param.name] = args[param.name]; - } - } - if (includeApiKey && (this.resource.api.api_key != null) && this.resource.api.api_key.length > 0) { - matchingParams[this.resource.api.apiKeyName] = this.resource.api.api_key; - } - if (jQuery.inArray('header', paramTypes) >= 0) { - _ref1 = this.resource.api.headers; - for (name in _ref1) { - value = _ref1[name]; - matchingParams[name] = value; - } - } - return matchingParams; +ShredHttpClient.prototype.initShred = function () { + this.isInitialized = true; + this.registerProcessors(this.shred); +} + +ShredHttpClient.prototype.registerProcessors = function(shred) { + var identity = function(x) { + return x; + }; + var toString = function(x) { + return x.toString(); + }; + + if (typeof window !== 'undefined') { + 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 + }); + } +} + +ShredHttpClient.prototype.execute = function(obj) { + if(!this.isInitialized) + this.initShred(); + + var cb = obj.on, res; + + var transform = function(response) { + var out = { + headers: response._headers, + url: response.request.url, + method: response.request.method, + status: response.status, + data: response.content.data }; - SwaggerOperation.prototype.help = function() { - var parameter, _i, _len, _ref; - _ref = this.parameters; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - parameter = _ref[_i]; - console.log(" " + parameter.name + (parameter.required ? ' (required)' : '') + " - " + parameter.description); + var contentType = (response._headers["content-type"]||response._headers["Content-Type"]||null) + + if(contentType != null) { + if(contentType.indexOf("application/json") == 0 || contentType.indexOf("+json") > 0) { + if(response.content.data && response.content.data !== "") + out.obj = JSON.parse(response.content.data); + else + out.obj = {} } - return this; - }; + } + return out; + }; - return SwaggerOperation; + res = { + error: function(response) { + if (obj) + return cb.error(transform(response)); + }, + redirect: function(response) { + if (obj) + return cb.redirect(transform(response)); + }, + 307: function(response) { + if (obj) + return cb.redirect(transform(response)); + }, + response: function(response) { + if (obj) + return cb.response(transform(response)); + } + }; + if (obj) { + obj.on = res; + } + return this.shred.request(obj); +}; - })(); +/** + * SwaggerAuthorizations applys the correct authorization to an operation being executed + */ +var SwaggerAuthorizations = function() { + this.authz = {}; +}; - SwaggerRequest = (function() { +SwaggerAuthorizations.prototype.add = function(name, auth) { + this.authz[name] = auth; + return auth; +}; - function SwaggerRequest(type, url, headers, body, successCallback, errorCallback, operation) { - var obj, - _this = this; - this.type = type; - this.url = url; - this.headers = headers; - this.body = body; - this.successCallback = successCallback; - this.errorCallback = errorCallback; - this.operation = operation; - 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."; - } - if (this.operation.resource.api.verbose) { - console.log(this.asCurl()); - } - this.headers || (this.headers = {}); - if (this.operation.resource.api.api_key != null) { - this.headers[this.apiKeyName] = this.operation.resource.api.api_key; - } - if (this.headers.mock == null) { - obj = { - type: this.type, - url: this.url, - data: JSON.stringify(this.body), - dataType: 'json', - error: function(xhr, textStatus, error) { - return _this.errorCallback(xhr, textStatus, error); - }, - success: function(data) { - return _this.successCallback(data); - } - }; - if (obj.type.toLowerCase() === "post" || obj.type.toLowerCase() === "put") { - obj.contentType = "application/json"; +SwaggerAuthorizations.prototype.remove = function(name) { + return delete this.authz[name]; +}; + +SwaggerAuthorizations.prototype.apply = function(obj, authorizations) { + var status = null; + var key; + + // if the "authorizations" key is undefined, or has an empty array, add all keys + if(typeof authorizations === 'undefined' || Object.keys(authorizations).length == 0) { + for (key in this.authz) { + value = this.authz[key]; + result = value.apply(obj, authorizations); + if (result === true) + status = true; + } + } + else { + for(name in authorizations) { + for (key in this.authz) { + if(key == name) { + value = this.authz[key]; + result = value.apply(obj, authorizations); + if (result === true) + status = true; } - jQuery.ajax(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 status; +}; + +/** + * ApiKeyAuthorization allows a query param or header to be injected + */ +var ApiKeyAuthorization = function(name, value, type) { + this.name = name; + this.value = value; + this.type = type; +}; + +ApiKeyAuthorization.prototype.apply = function(obj, authorizations) { + 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") { + obj.headers[this.name] = this.value; + return true; + } +}; - return SwaggerRequest; +var CookieAuthorization = function(cookie) { + this.cookie = cookie; +} - })(); +CookieAuthorization.prototype.apply = function(obj, authorizations) { + obj.cookieJar = obj.cookieJar || CookieJar(); + obj.cookieJar.setCookie(this.cookie); + return true; +} - window.SwaggerApi = SwaggerApi; +/** + * Password Authorization is a basic auth implementation + */ +var PasswordAuthorization = function(name, username, password) { + this.name = name; + this.username = username; + this.password = password; + this._btoa = null; + if (typeof window !== 'undefined') + this._btoa = btoa; + else + this._btoa = require("btoa"); +}; - window.SwaggerResource = SwaggerResource; +PasswordAuthorization.prototype.apply = function(obj, authorizations) { + var base64encoder = this._btoa; + obj.headers["Authorization"] = "Basic " + base64encoder(this.username + ":" + this.password); + return true; +}; - window.SwaggerOperation = SwaggerOperation; +var e = (typeof window !== 'undefined' ? window : exports); - window.SwaggerRequest = SwaggerRequest; +var sampleModels = {}; +var cookies = {}; -}).call(this); +e.SampleModels = sampleModels; +e.SwaggerHttp = SwaggerHttp; +e.SwaggerRequest = SwaggerRequest; +e.authorizations = new SwaggerAuthorizations(); +e.ApiKeyAuthorization = ApiKeyAuthorization; +e.PasswordAuthorization = PasswordAuthorization; +e.CookieAuthorization = CookieAuthorization; +e.JQueryHttpClient = JQueryHttpClient; +e.ShredHttpClient = ShredHttpClient; +e.SwaggerOperation = SwaggerOperation; +e.SwaggerModel = SwaggerModel; +e.SwaggerModelProperty = SwaggerModelProperty; +e.SwaggerResource = SwaggerResource; +e.SwaggerApi = SwaggerApi; diff --git a/tastypie_swagger/static/tastypie_swagger/js/lib/underscore-min.js b/tastypie_swagger/static/tastypie_swagger/js/lib/underscore-min.js old mode 100644 new mode 100755 diff --git a/tastypie_swagger/static/tastypie_swagger/js/swagger-ui.js b/tastypie_swagger/static/tastypie_swagger/js/swagger-ui.js old mode 100644 new mode 100755 index 8b5c3ed..3405a89 --- a/tastypie_swagger/static/tastypie_swagger/js/swagger-ui.js +++ b/tastypie_swagger/static/tastypie_swagger/js/swagger-ui.js @@ -1,3 +1,5 @@ +// swagger-ui.js +// version 2.0.22 $(function() { // Helper function for vertically aligning DOM elements @@ -62,9 +64,14 @@ function clippyCopiedCallback(a) { } // Logging function that accounts for browsers that don't have window.console -function log() { - if (window.console) console.log.apply(console,arguments); -} +log = function(){ + log.history = log.history || []; + log.history.push(arguments); + if(this.console){ + console.log( Array.prototype.slice.call(arguments)[0] ); + } +}; + // 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") { [ @@ -86,7 +93,7 @@ var Docs = { switch (fragments.length) { case 1: // Expand all operations for the resource and scroll to it -// log('shebang resource:' + fragments[0]); + log('shebang resource:' + fragments[0]); var dom_id = 'resource_' + fragments[0]; Docs.expandEndpointListForResource(fragments[0]); @@ -94,18 +101,18 @@ var Docs = { break; case 2: // Refer to the endpoint DOM element, e.g. #words_get_search -// log('shebang endpoint: ' + fragments.join('_')); + log('shebang endpoint: ' + fragments.join('_')); - // Expand Resource - Docs.expandEndpointListForResource(fragments[0]); - $("#"+dom_id).slideto({highlight: false}); + // Expand Resource + Docs.expandEndpointListForResource(fragments[0]); + $("#"+dom_id).slideto({highlight: false}); - // Expand operation + // 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); + 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}); @@ -180,970 +187,1049 @@ var Docs = { collapseOperation: function(elem) { elem.slideUp(); } - -}; -(function() { +};(function() { var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0; + 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, stack2; - buffer += "\n "; - foundHelper = helpers.supportedContentTypes; - stack1 = foundHelper || depth0.supportedContentTypes; - stack2 = helpers.each; - tmp1 = self.program(2, program2, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.noop; - stack1 = stack2.call(depth0, stack1, tmp1); + 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;} + return buffer; + } function program2(depth0,data) { var buffer = "", stack1; buffer += "\n \n "; - return buffer;} + return buffer; + } function program4(depth0,data) { - return "\n \n";} + return "\n \n"; + } buffer += "\n\n"; - return buffer;}); + return buffer; + }); })(); (function() { var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; templates['main'] = template(function (Handlebars,depth0,helpers,partials,data) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression; + 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: "; - foundHelper = helpers.apiVersion; - stack1 = foundHelper || depth0.apiVersion; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "apiVersion", { hash: {} }); } - buffer += escapeExpression(stack1) + "\n "; - return buffer;} - - buffer += "\n
    \n
      \n
    \n\n
    \n
    \n
    \n

    [ base url: "; - foundHelper = helpers.basePath; - stack1 = foundHelper || depth0.basePath; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "basePath", { hash: {} }); } - buffer += escapeExpression(stack1) + "\n "; - foundHelper = helpers.apiVersion; - stack1 = foundHelper || depth0.apiVersion; - stack2 = helpers['if']; - tmp1 = self.program(1, program1, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.noop; - stack1 = stack2.call(depth0, stack1, tmp1); + 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;}); + return buffer; + }); })(); (function() { var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; templates['operation'] = template(function (Handlebars,depth0,helpers,partials,data) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression; + 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) { var buffer = "", stack1; - buffer += "\n

    Implementation Notes

    \n

    "; - foundHelper = helpers.notes; - stack1 = foundHelper || depth0.notes; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "notes", { hash: {} }); } + 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;} + buffer += "

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

    Response Class

    \n

    \n
    \n
    \n ";} + return "\n
    \n "; + } function program5(depth0,data) { + var buffer = "", stack1; + buffer += "\n
    \n "; + stack1 = helpers.each.call(depth0, depth0, {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n
    \n "; + return buffer; + } +function program6(depth0,data) { - return "\n
    \n

    Status Codes

    \n \n \n \n \n \n \n \n \n \n \n
    HTTP Status CodeReason
    \n ";} + var buffer = "", stack1, stack2; + buffer += "\n
    " + + escapeExpression(((stack1 = depth0.scope),typeof stack1 === functionType ? stack1.apply(depth0) : stack1)) + + "
    \n "; + return buffer; + } -function program7(depth0,data) { +function program8(depth0,data) { - return "\n ";} + return "
    "; + } -function program9(depth0,data) { +function program10(depth0,data) { + + + return "\n
    \n \n
    \n "; + } + +function program12(depth0,data) { + + + return "\n

    Response Class

    \n

    \n
    \n
    \n "; + } + +function program14(depth0,data) { - return "\n
    \n \n \n \n
    \n ";} - - buffer += "\n \n"; - return buffer;}); + buffer += "\n
    \n
    \n "; + stack1 = helpers['if'].call(depth0, depth0.parameters, {hash:{},inverse:self.noop,fn:self.program(14, program14, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.responseMessages, {hash:{},inverse:self.noop,fn:self.program(16, program16, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.isReadOnly, {hash:{},inverse:self.program(20, program20, data),fn:self.program(18, program18, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n
    \n \n
    \n \n \n"; + return buffer; + }); })(); (function() { var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; templates['param'] = template(function (Handlebars,depth0,helpers,partials,data) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression; + 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; + var buffer = "", stack1; buffer += "\n "; - foundHelper = helpers.isFile; - stack1 = foundHelper || depth0.isFile; - stack2 = helpers['if']; - tmp1 = self.program(2, program2, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(4, program4, data); - stack1 = stack2.call(depth0, stack1, tmp1); + 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;} + return buffer; + } function program2(depth0,data) { var buffer = "", stack1; buffer += "\n \n "; - return 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 "; + return buffer; + } function program4(depth0,data) { - var buffer = "", stack1, stack2; + var buffer = "", stack1; buffer += "\n "; - foundHelper = helpers.defaultValue; - stack1 = foundHelper || depth0.defaultValue; - stack2 = helpers['if']; - tmp1 = self.program(5, program5, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(7, program7, data); - stack1 = stack2.call(depth0, stack1, tmp1); + 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;} + return buffer; + } function program5(depth0,data) { var buffer = "", stack1; buffer += "\n \n "; - return 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) + + "'>"; + 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 program7(depth0,data) { var buffer = "", stack1; buffer += "\n \n
    \n
    \n "; - return 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 "; + return buffer; + } function program9(depth0,data) { - var buffer = "", stack1, stack2; + var buffer = "", stack1; buffer += "\n "; - foundHelper = helpers.defaultValue; - stack1 = foundHelper || depth0.defaultValue; - stack2 = helpers['if']; - tmp1 = self.program(10, program10, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(12, program12, data); - stack1 = stack2.call(depth0, stack1, tmp1); + stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(10, program10, data),fn:self.program(2, program2, data),data:data}); if(stack1 || stack1 === 0) { buffer += stack1; } buffer += "\n "; - return buffer;} + return buffer; + } function program10(depth0,data) { var buffer = "", stack1; - buffer += "\n \n "; - return buffer;} + buffer += "\n "; + stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(13, program13, data),fn:self.program(11, program11, data),data:data}); + if(stack1 || stack1 === 0) { buffer += stack1; } + buffer += "\n "; + return buffer; + } +function program11(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } -function program12(depth0,data) { +function program13(depth0,data) { var buffer = "", stack1; - buffer += "\n \n "; - return buffer;} + buffer += "\n \n "; + return buffer; + } buffer += ""; - foundHelper = helpers.name; - stack1 = foundHelper || depth0.name; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); } - buffer += escapeExpression(stack1) + "\n\n\n "; - foundHelper = helpers.isBody; - stack1 = foundHelper || depth0.isBody; - stack2 = helpers['if']; - tmp1 = self.program(1, program1, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(9, program9, data); - stack1 = stack2.call(depth0, stack1, tmp1); + 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"; - foundHelper = helpers.description; - stack1 = foundHelper || depth0.description; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "description", { hash: {} }); } + 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\n"; - return buffer;}); + 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) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression; + this.compilerInfo = [4,'>= 1.0.0']; +helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, stack2, options, self=this, helperMissing=helpers.helperMissing, functionType="function", escapeExpression=this.escapeExpression; function program1(depth0,data) { - return "\n ";} + return " multiple='multiple'"; + } function program3(depth0,data) { - var buffer = "", stack1, stack2; - buffer += "\n "; - foundHelper = helpers.defaultValue; - stack1 = foundHelper || depth0.defaultValue; - stack2 = helpers['if']; - tmp1 = self.program(4, program4, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(6, program6, data); - stack1 = stack2.call(depth0, stack1, tmp1); - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n "; - return buffer;} -function program4(depth0,data) { - - return "\n ";} + 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 \n ";} + return "\n "; + } function program8(depth0,data) { - var buffer = "", stack1, stack2; - buffer += "\n "; - foundHelper = helpers.isDefault; - stack1 = foundHelper || depth0.isDefault; - stack2 = helpers['if']; - tmp1 = self.program(9, program9, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(11, program11, data); - stack1 = stack2.call(depth0, stack1, tmp1); - if(stack1 || stack1 === 0) { buffer += stack1; } + var buffer = "", stack1, stack2, options; buffer += "\n "; - return buffer;} + options = {hash:{},inverse:self.program(11, program11, data),fn:self.program(9, program9, data),data:data}; + stack2 = ((stack1 = helpers.isArray || depth0.isArray),stack1 ? stack1.call(depth0, depth0, options) : helperMissing.call(depth0, "isArray", depth0, options)); + if(stack2 || stack2 === 0) { buffer += stack2; } + buffer += "\n "; + return buffer; + } function program9(depth0,data) { - var buffer = "", stack1; - buffer += "\n \n "; - return buffer;} + + 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;} + buffer += "\n \n "; + return buffer; + } + +function program16(depth0,data) { + + var buffer = "", stack1; + buffer += "\n \n "; + return buffer; + } buffer += ""; - foundHelper = helpers.name; - stack1 = foundHelper || depth0.name; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); } - buffer += escapeExpression(stack1) + "\n\n \n\n"; - foundHelper = helpers.description; - stack1 = foundHelper || depth0.description; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "description", { hash: {} }); } - if(stack1 || stack1 === 0) { buffer += stack1; } - buffer += "\n\n"; - return 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) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression; + 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;} + 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) + + "'>"; + 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 program3(depth0,data) { var buffer = "", stack1; buffer += "\n "; - foundHelper = helpers.defaultValue; - stack1 = foundHelper || depth0.defaultValue; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "defaultValue", { hash: {} }); } - buffer += escapeExpression(stack1) + "\n "; - return buffer;} + 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 += ""; - foundHelper = helpers.name; - stack1 = foundHelper || depth0.name; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); } - buffer += escapeExpression(stack1) + "\n\n "; - foundHelper = helpers.isBody; - stack1 = foundHelper || depth0.isBody; - stack2 = helpers['if']; - tmp1 = self.program(1, program1, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(3, program3, data); - stack1 = stack2.call(depth0, stack1, tmp1); + 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"; - foundHelper = helpers.description; - stack1 = foundHelper || depth0.description; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "description", { hash: {} }); } + 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;}); + return buffer; + }); })(); (function() { var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; templates['param_readonly_required'] = template(function (Handlebars,depth0,helpers,partials,data) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression; + 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;} + 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) + + "'>"; + 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 program3(depth0,data) { var buffer = "", stack1; buffer += "\n "; - foundHelper = helpers.defaultValue; - stack1 = foundHelper || depth0.defaultValue; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "defaultValue", { hash: {} }); } - buffer += escapeExpression(stack1) + "\n "; - return buffer;} + 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 += ""; - foundHelper = helpers.name; - stack1 = foundHelper || depth0.name; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); } - buffer += escapeExpression(stack1) + "\n\n "; - foundHelper = helpers.isBody; - stack1 = foundHelper || depth0.isBody; - stack2 = helpers['if']; - tmp1 = self.program(1, program1, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(3, program3, data); - stack1 = stack2.call(depth0, stack1, tmp1); + 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"; - foundHelper = helpers.description; - stack1 = foundHelper || depth0.description; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "description", { hash: {} }); } + 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;}); + return buffer; + }); })(); (function() { var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; templates['param_required'] = template(function (Handlebars,depth0,helpers,partials,data) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, stack2, foundHelper, tmp1, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression; + 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; + var buffer = "", stack1; buffer += "\n "; - foundHelper = helpers.isFile; - stack1 = foundHelper || depth0.isFile; - stack2 = helpers['if']; - tmp1 = self.program(2, program2, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(4, program4, data); - stack1 = stack2.call(depth0, stack1, tmp1); + 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;} + return buffer; + } function program2(depth0,data) { var buffer = "", stack1; buffer += "\n \n "; - return 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 "; + return buffer; + } function program4(depth0,data) { - var buffer = "", stack1, stack2; + var buffer = "", stack1; buffer += "\n "; - foundHelper = helpers.defaultValue; - stack1 = foundHelper || depth0.defaultValue; - stack2 = helpers['if']; - tmp1 = self.program(5, program5, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(7, program7, data); - stack1 = stack2.call(depth0, stack1, tmp1); + 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;} + return buffer; + } function program5(depth0,data) { var buffer = "", stack1; buffer += "\n \n "; - return 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) + + "'>"; + 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 program7(depth0,data) { var buffer = "", stack1; buffer += "\n \n
    \n
    \n "; - return 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 "; + return buffer; + } function program9(depth0,data) { - var buffer = "", stack1, stack2; + var buffer = "", stack1; buffer += "\n "; - foundHelper = helpers.isFile; - stack1 = foundHelper || depth0.isFile; - stack2 = helpers['if']; - tmp1 = self.program(10, program10, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(12, program12, data); - stack1 = stack2.call(depth0, stack1, tmp1); + 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;} + return buffer; + } function program10(depth0,data) { var buffer = "", stack1; - buffer += "\n \n "; - return buffer;} + buffer += "\n \n "; + return buffer; + } function program12(depth0,data) { - var buffer = "", stack1, stack2; + var buffer = "", stack1; buffer += "\n "; - foundHelper = helpers.defaultValue; - stack1 = foundHelper || depth0.defaultValue; - stack2 = helpers['if']; - tmp1 = self.program(13, program13, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(15, program15, data); - stack1 = stack2.call(depth0, stack1, tmp1); + 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;} + return buffer; + } function program13(depth0,data) { var buffer = "", stack1; - buffer += "\n \n "; - return buffer;} + buffer += "\n \n "; + return buffer; + } function program15(depth0,data) { var buffer = "", stack1; - buffer += "\n \n "; - return buffer;} + buffer += "\n \n "; + return buffer; + } buffer += ""; - foundHelper = helpers.name; - stack1 = foundHelper || depth0.name; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "name", { hash: {} }); } - buffer += escapeExpression(stack1) + "\n\n "; - foundHelper = helpers.isBody; - stack1 = foundHelper || depth0.isBody; - stack2 = helpers['if']; - tmp1 = self.program(1, program1, data); - tmp1.hash = {}; - tmp1.fn = tmp1; - tmp1.inverse = self.program(9, program9, data); - stack1 = stack2.call(depth0, stack1, tmp1); + 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 "; - foundHelper = helpers.description; - stack1 = foundHelper || depth0.description; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "description", { hash: {} }); } + 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\n\n"; - return buffer;}); + 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['resource'] = template(function (Handlebars,depth0,helpers,partials,data) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, foundHelper, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression; - - - buffer += "\n\n"; - return buffer;}); + 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"; + } + + buffer += "\n\n"; + return buffer; + }); })(); (function() { var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {}; templates['signature'] = template(function (Handlebars,depth0,helpers,partials,data) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, foundHelper, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression; + 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 "; - foundHelper = helpers.signature; - stack1 = foundHelper || depth0.signature; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "signature", { hash: {} }); } + 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
    ";
    -  foundHelper = helpers.sampleJSON;
    -  stack1 = foundHelper || depth0.sampleJSON;
    -  if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
    -  else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "sampleJSON", { hash: {} }); }
    -  buffer += escapeExpression(stack1) + "
    \n \n
    \n
    \n\n"; - return buffer;}); + 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) { - helpers = helpers || Handlebars.helpers; - var buffer = "", stack1, foundHelper, self=this, functionType="function", helperMissing=helpers.helperMissing, undef=void 0, escapeExpression=this.escapeExpression; + this.compilerInfo = [4,'>= 1.0.0']; +helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; + var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression; buffer += ""; - foundHelper = helpers.code; - stack1 = foundHelper || depth0.code; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "code", { hash: {} }); } - buffer += escapeExpression(stack1) + "\n"; - foundHelper = helpers.reason; - stack1 = foundHelper || depth0.reason; - if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); } - else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "reason", { hash: {} }); } + 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\n"; - return buffer;}); + buffer += "\n"; + return buffer; + }); })(); -// Generated by CoffeeScript 1.3.3 +// Generated by CoffeeScript 1.6.3 (function() { - var ContentTypeView, HeaderView, MainView, OperationView, ParameterView, ResourceView, SignatureView, StatusCodeView, SwaggerUi, + 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() { - return SwaggerUi.__super__.constructor.apply(this, arguments); + _ref = SwaggerUi.__super__.constructor.apply(this, arguments); + return _ref; } SwaggerUi.prototype.dom_id = "swagger_ui"; @@ -1165,7 +1251,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials this.dom_id = options.dom_id; delete options.dom_id; } - if (!($('#' + this.dom_id) != null)) { + if ($('#' + this.dom_id) == null) { $('body').append('
    '); } this.options = options; @@ -1187,18 +1273,24 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials }; SwaggerUi.prototype.updateSwaggerUi = function(data) { - this.options.discoveryUrl = data.discoveryUrl; - this.options.apiKey = data.apiKey; + this.options.url = data.url; return this.load(); }; SwaggerUi.prototype.load = function() { - var _ref; - if ((_ref = this.mainView) != null) { - _ref.clear(); + 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.headerView.update(this.options.discoveryUrl, this.options.apiKey); - return this.api = new SwaggerApi(this.options); + this.options.url = url; + this.headerView.update(url); + this.api = new SwaggerApi(this.options); + this.api.build(); + return this.api; }; SwaggerUi.prototype.render = function() { @@ -1206,7 +1298,8 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...'); this.mainView = new MainView({ model: this.api, - el: $('#' + this.dom_id) + el: $('#' + this.dom_id), + swaggerOptions: this.options }).render(); this.showMessage(); switch (this.options.docExpansion) { @@ -1224,6 +1317,29 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials }, 400); }; + SwaggerUi.prototype.buildUrl = function(base, url) { + var endOfPath, parts; + log("base is " + base); + if (url.indexOf("/") === 0) { + parts = base.split("/"); + base = parts[0] + "//" + parts[2]; + return base + url; + } else { + endOfPath = base.length; + if (base.indexOf("?") > -1) { + endOfPath = Math.min(endOfPath, base.indexOf("?")); + } + if (base.indexOf("#") > -1) { + endOfPath = Math.min(endOfPath, base.indexOf("#")); + } + base = base.substring(0, endOfPath); + if (base.indexOf("/", base.length - 1) !== -1) { + return base + url; + } + return base + "/" + url; + } + }; + SwaggerUi.prototype.showMessage = function(data) { if (data == null) { data = ''; @@ -1254,11 +1370,11 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials window.SwaggerUi = SwaggerUi; HeaderView = (function(_super) { - __extends(HeaderView, _super); function HeaderView() { - return HeaderView.__super__.constructor.apply(this, arguments); + _ref1 = HeaderView.__super__.constructor.apply(this, arguments); + return _ref1; } HeaderView.prototype.events = { @@ -1273,15 +1389,13 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials HeaderView.prototype.showPetStore = function(e) { return this.trigger('update-swagger-ui', { - discoveryUrl: "http://petstore.swagger.wordnik.com/api/api-docs.json", - apiKey: "special-key" + url: "http://petstore.swagger.wordnik.com/api/api-docs" }); }; HeaderView.prototype.showWordnikDev = function(e) { return this.trigger('update-swagger-ui', { - discoveryUrl: "http://api.wordnik.com/v4/resources.json", - apiKey: "" + url: "http://api.wordnik.com/v4/resources.json" }); }; @@ -1296,7 +1410,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials e.preventDefault(); } return this.trigger('update-swagger-ui', { - discoveryUrl: $('#input_baseUrl').val(), + url: $('#input_baseUrl').val(), apiKey: $('#input_apiKey').val() }); }; @@ -1306,11 +1420,9 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials trigger = false; } $('#input_baseUrl').val(url); - $('#input_apiKey').val(apiKey); if (trigger) { return this.trigger('update-swagger-ui', { - discoveryUrl: url, - apiKey: apiKey + url: url }); } }; @@ -1320,21 +1432,58 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials })(Backbone.View); MainView = (function(_super) { + var sorters; __extends(MainView, _super); function MainView() { - return MainView.__super__.constructor.apply(this, arguments); + _ref2 = MainView.__super__.constructor.apply(this, arguments); + return _ref2; } - MainView.prototype.initialize = function() {}; + sorters = { + 'alpha': function(a, b) { + return a.path.localeCompare(b.path); + }, + 'method': function(a, b) { + return a.method.localeCompare(b.method); + } + }; + + MainView.prototype.initialize = function(opts) { + var route, sorter, sorterName, _i, _len, _ref3; + if (opts == null) { + opts = {}; + } + if (opts.swaggerOptions.sorter) { + sorterName = opts.swaggerOptions.sorter; + sorter = sorters[sorterName]; + _ref3 = this.model.apisArray; + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { + route = _ref3[_i]; + route.operationsArray.sort(sorter); + } + if (sorterName === "alpha") { + return this.model.apisArray.sort(sorter); + } + } + }; MainView.prototype.render = function() { - var resource, _i, _len, _ref; + var counter, id, resource, resources, _i, _len, _ref3; $(this.el).html(Handlebars.templates.main(this.model)); - _ref = this.model.resourcesArray; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - resource = _ref[_i]; + resources = {}; + counter = 0; + _ref3 = this.model.apisArray; + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { + resource = _ref3[_i]; + id = resource.name; + while (typeof resources[id] !== 'undefined') { + id = id + "_" + counter; + counter += 1; + } + resource.id = id; + resources[id] = resource; this.addResource(resource); } return this; @@ -1345,8 +1494,9 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials resourceView = new ResourceView({ model: resource, tagName: 'li', - id: 'resource_' + resource.name, - className: 'resource' + id: 'resource_' + resource.id, + className: 'resource', + swaggerOptions: this.options.swaggerOptions }); return $('#resources').append(resourceView.render().el); }; @@ -1360,22 +1510,31 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials })(Backbone.View); ResourceView = (function(_super) { - __extends(ResourceView, _super); function ResourceView() { - return ResourceView.__super__.constructor.apply(this, arguments); + _ref3 = ResourceView.__super__.constructor.apply(this, arguments); + return _ref3; } ResourceView.prototype.initialize = function() {}; ResourceView.prototype.render = function() { - var operation, _i, _len, _ref; + var counter, id, methods, operation, _i, _len, _ref4; $(this.el).html(Handlebars.templates.resource(this.model)); - this.number = 0; - _ref = this.model.operationsArray; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - operation = _ref[_i]; + methods = {}; + _ref4 = this.model.operationsArray; + for (_i = 0, _len = _ref4.length; _i < _len; _i++) { + operation = _ref4[_i]; + counter = 0; + id = operation.nickname; + while (typeof methods[id] !== 'undefined') { + id = id + "_" + counter; + counter += 1; + } + methods[id] = operation; + operation.nickname = id; + operation.parentId = this.model.id; this.addOperation(operation); } return this; @@ -1387,7 +1546,8 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials operationView = new OperationView({ model: operation, tagName: 'li', - className: 'endpoint' + className: 'endpoint', + swaggerOptions: this.options.swaggerOptions }); $('.endpoints', $(this.el)).append(operationView.render().el); return this.number++; @@ -1398,28 +1558,85 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials })(Backbone.View); OperationView = (function(_super) { - __extends(OperationView, _super); function OperationView() { - return OperationView.__super__.constructor.apply(this, arguments); + _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' + 'click .toggleOperation': 'toggleOperationContent', + 'mouseenter .api-ic': 'mouseEnter', + 'mouseout .api-ic': 'mouseExit' }; OperationView.prototype.initialize = function() {}; + OperationView.prototype.mouseEnter = function(e) { + var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y; + elem = $(e.currentTarget.parentNode).find('#api_information_panel'); + x = e.pageX; + y = e.pageY; + scX = $(window).scrollLeft(); + scY = $(window).scrollTop(); + scMaxX = scX + $(window).width(); + scMaxY = scY + $(window).height(); + wd = elem.width(); + hgh = elem.height(); + if (x + wd > scMaxX) { + x = scMaxX - wd; + } + if (x < scX) { + x = scX; + } + if (y + hgh > scMaxY) { + y = scMaxY - hgh; + } + if (y < scY) { + y = scY; + } + pos = {}; + pos.top = y; + pos.left = x; + elem.css(pos); + return $(e.currentTarget.parentNode).find('#api_information_panel').show(); + }; + + OperationView.prototype.mouseExit = function(e) { + return $(e.currentTarget.parentNode).find('#api_information_panel').hide(); + }; + OperationView.prototype.render = function() { - var contentTypeModel, contentTypeView, isMethodSubmissionSupported, param, responseSignatureView, signatureModel, statusCode, _i, _j, _len, _len1, _ref, _ref1; - isMethodSubmissionSupported = jQuery.inArray(this.model.httpMethod, this.model.supportedSubmitMethods()) >= 0; + var contentTypeModel, isMethodSubmissionSupported, k, o, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, v, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8; + isMethodSubmissionSupported = true; if (!isMethodSubmissionSupported) { this.model.isReadOnly = true; } + this.model.oauth = null; + if (this.model.authorizations) { + _ref5 = this.model.authorizations; + for (k in _ref5) { + v = _ref5[k]; + if (k === "oauth2") { + if (this.model.oauth === null) { + this.model.oauth = {}; + } + if (this.model.oauth.scopes === void 0) { + this.model.oauth.scopes = []; + } + for (_i = 0, _len = v.length; _i < _len; _i++) { + o = v[_i]; + this.model.oauth.scopes.push(o); + } + } + } + } $(this.el).html(Handlebars.templates.operation(this.model)); if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') { signatureModel = { @@ -1433,31 +1650,44 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials }); $('.model-signature', $(this.el)).append(responseSignatureView.render().el); } else { - $('.model-signature', $(this.el)).html(this.model.responseClass); + $('.model-signature', $(this.el)).html(this.model.type); } contentTypeModel = { - isParam: false, - supportedContentTypes: this.model.supportedContentTypes + isParam: false }; - contentTypeView = new ContentTypeView({ + contentTypeModel.consumes = this.model.consumes; + contentTypeModel.produces = this.model.produces; + _ref6 = this.model.parameters; + for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { + param = _ref6[_j]; + type = param.type || param.dataType; + if (type.toLowerCase() === 'file') { + if (!contentTypeModel.consumes) { + log("set content type "); + contentTypeModel.consumes = 'multipart/form-data'; + } + } + } + responseContentTypeView = new ResponseContentTypeView({ model: contentTypeModel }); - $('.content-type', $(this.el)).append(contentTypeView.render().el); - _ref = this.model.parameters; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - param = _ref[_i]; - this.addParameter(param); + $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el); + _ref7 = this.model.parameters; + for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) { + param = _ref7[_k]; + this.addParameter(param, contentTypeModel.consumes); } - _ref1 = this.model.errorResponses; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - statusCode = _ref1[_j]; + _ref8 = this.model.responseMessages; + for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) { + statusCode = _ref8[_l]; this.addStatusCode(statusCode); } return this; }; - OperationView.prototype.addParameter = function(param) { + OperationView.prototype.addParameter = function(param, consumes) { var paramView; + param.consumes = consumes; paramView = new ParameterView({ model: param, tagName: 'tr', @@ -1476,8 +1706,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials }; OperationView.prototype.submitOperation = function(e) { - var bodyParam, error_free, form, headerParams, invocationUrl, isFileUpload, map, o, obj, param, paramContentTypeField, responseContentTypeField, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, - _this = this; + var error_free, form, isFileUpload, map, o, opts, val, _i, _j, _k, _len, _len1, _len2, _ref5, _ref6, _ref7; if (e != null) { e.preventDefault(); } @@ -1498,78 +1727,158 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials }); if (error_free) { map = {}; - _ref = form.serializeArray(); - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - o = _ref[_i]; + 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; + } } - isFileUpload = $('input[type~="file"]').size !== 0; - if (isFileUpload) { - bodyParam = new FormData(); - _ref1 = this.model.parameters; - for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) { - param = _ref1[_j]; - if (param.paramType === 'body') { - bodyParam.append(param.name, map[param.name]); - } + _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; } - $.each($('input[type~="file"]'), function(i, el) { - return bodyParam.append($(el).attr('name'), el.files[0]); - }); - console.log(bodyParam); - } else { - } - bodyParam = null; - _ref2 = this.model.parameters; - for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) { - param = _ref2[_k]; - if (param.paramType === 'body') { - bodyParam = map[param.name]; + _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; } } - log("bodyParam = " + bodyParam); - headerParams = null; - invocationUrl = this.model.supportHeaderParams() ? (headerParams = this.model.getHeaderParams(map), this.model.urlify(map, false)) : this.model.urlify(map, true); - log('submitting ' + invocationUrl); - $(".request_url", $(this.el)).html("
    " + invocationUrl + "
    "); + opts.responseContentType = $("div select[name=responseContentType]", $(this.el)).val(); + opts.requestContentType = $("div select[name=parameterContentType]", $(this.el)).val(); $(".response_throbber", $(this.el)).show(); - obj = { - type: this.model.httpMethod, - url: invocationUrl, - headers: headerParams, - data: bodyParam, - dataType: 'json', - processData: false, - error: function(xhr, textStatus, error) { - return _this.showErrorStatus(xhr, textStatus, error); - }, - success: function(data) { - return _this.showResponse(data); - }, - complete: function(data) { - return _this.showCompleteStatus(data); + 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, el, headerParams, o, obj, param, params, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8, + _this = this; + _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(); + params = 0; + _ref6 = this.model.parameters; + for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { + param = _ref6[_j]; + if (param.paramType === 'form') { + if (param.type.toLowerCase() !== 'file' && map[param.name] !== void 0) { + bodyParam.append(param.name, map[param.name]); } - }; - if (obj.type.toLowerCase() === "post" || obj.type.toLowerCase() === "put" || obj.type.toLowerCase() === "patch") { - obj.contentType = "application/json"; } - if (isFileUpload) { - obj.contentType = false; + } + 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]; } - paramContentTypeField = $("td select[name=contentType]", $(this.el)).val(); - if (paramContentTypeField) { - obj.contentType = paramContentTypeField; + } + log(headerParams); + _ref8 = form.find('input[type~="file"]'); + for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) { + el = _ref8[_l]; + if (typeof el.files[0] !== 'undefined') { + bodyParam.append($(el).attr('name'), el.files[0]); + params += 1; + } + } + 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("
    ");
    +      $(".request_url pre", $(this.el)).text(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);
             }
    -        responseContentTypeField = $('.content > .content-type > div > select[name=contentType]', $(this.el)).val();
    -        if (responseContentTypeField) {
    -          obj.headers = obj.headers != null ? obj.headers : {};
    -          obj.headers.accept = responseContentTypeField;
    +      };
    +      if (window.authorizations) {
    +        window.authorizations.apply(obj);
    +      }
    +      if (params === 0) {
    +        obj.data.append("fake", "true");
    +      }
    +      jQuery.ajax(obj);
    +      return false;
    +    };
    +
    +    OperationView.prototype.wrap = function(data) {
    +      var h, headerArray, headers, i, o, _i, _len;
    +      headers = {};
    +      headerArray = data.getAllResponseHeaders().split("\r");
    +      for (_i = 0, _len = headerArray.length; _i < _len; _i++) {
    +        i = headerArray[_i];
    +        h = i.split(':');
    +        if (h[0] !== void 0 && h[1] !== void 0) {
    +          headers[h[0].trim()] = h[1].trim();
    +        }
    +      }
    +      o = {};
    +      o.content = {};
    +      o.content.data = data.responseText;
    +      o.headers = headers;
    +      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;
             }
    -        jQuery.ajax(obj);
    -        return false;
           }
         };
     
    @@ -1587,12 +1896,12 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
           return $(".response_body", $(this.el)).html(escape(prettyJson));
         };
     
    -    OperationView.prototype.showErrorStatus = function(data) {
    -      return this.showStatus(data);
    +    OperationView.prototype.showErrorStatus = function(data, parent) {
    +      return parent.showStatus(data);
         };
     
    -    OperationView.prototype.showCompleteStatus = function(data) {
    -      return this.showStatus(data);
    +    OperationView.prototype.showCompleteStatus = function(data, parent) {
    +      return parent.showStatus(data);
         };
     
         OperationView.prototype.formatXml = function(xml) {
    @@ -1648,9 +1957,9 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
             padding = '';
             indent += transitions[fromTo];
             padding = ((function() {
    -          var _j, _ref, _results;
    +          var _j, _ref5, _results;
               _results = [];
    -          for (j = _j = 0, _ref = indent; 0 <= _ref ? _j < _ref : _j > _ref; j = 0 <= _ref ? ++_j : --_j) {
    +          for (j = _j = 0, _ref5 = indent; 0 <= _ref5 ? _j < _ref5 : _j > _ref5; j = 0 <= _ref5 ? ++_j : --_j) {
                 _results.push('  ');
               }
               return _results;
    @@ -1668,28 +1977,56 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
           return formatted;
         };
     
    -    OperationView.prototype.showStatus = function(data) {
    -      var code, pre, response_body;
    -      try {
    -        code = $('').text(JSON.stringify(JSON.parse(data.responseText), null, 2));
    +    OperationView.prototype.showStatus = function(response) {
    +      var code, content, contentType, headers, opts, pre, response_body, response_body_el, url;
    +      if (response.content === void 0) {
    +        content = response.data;
    +        url = response.url;
    +      } else {
    +        content = response.content.data;
    +        url = response.request.url;
    +      }
    +      headers = response.headers;
    +      contentType = headers && headers["Content-Type"] ? headers["Content-Type"].split(";")[0].trim() : null;
    +      if (!content) {
    +        code = $('').text("no content");
             pre = $('
    ').append(code);
    -      } catch (error) {
    -        code = $('').text(this.formatXml(data.responseText));
    +      } else if (contentType === "application/json" || /\+json$/.test(contentType)) {
    +        code = $('').text(JSON.stringify(JSON.parse(content), null, "  "));
    +        pre = $('
    ').append(code);
    +      } else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
    +        code = $('').text(this.formatXml(content));
    +        pre = $('
    ').append(code);
    +      } else if (contentType === "text/html") {
    +        code = $('').html(content);
             pre = $('
    ').append(code);
    +      } else if (/^image\//.test(contentType)) {
    +        pre = $('').attr('src', url);
    +      } else {
    +        code = $('').text(content);
    +        pre = $('
    ').append(code);
           }
           response_body = pre;
    -      $(".response_code", $(this.el)).html("
    " + data.status + "
    "); + $(".request_url", $(this.el)).html("
    ");
    +      $(".request_url pre", $(this.el)).text(url);
    +      $(".response_code", $(this.el)).html("
    " + response.status + "
    "); $(".response_body", $(this.el)).html(response_body); - $(".response_headers", $(this.el)).html("
    " + data.getAllResponseHeaders() + "
    "); + $(".response_headers", $(this.el)).html("
    " + _.escape(JSON.stringify(response.headers, 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]); + response_body_el = $('.response_body', $(this.el))[0]; + opts = this.options.swaggerOptions; + if (opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold) { + return response_body_el; + } else { + return hljs.highlightBlock(response_body_el); + } }; OperationView.prototype.toggleOperationContent = function() { var elem; - elem = $('#' + this.model.resourceName + "_" + this.model.nickname + "_" + this.model.httpMethod + "_" + this.model.number + "_content"); + elem = $('#' + Docs.escapeResourceName(this.model.parentId) + "_" + this.model.nickname + "_content"); if (elem.is(':visible')) { return Docs.collapseOperation(elem); } else { @@ -1702,19 +2039,33 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials })(Backbone.View); StatusCodeView = (function(_super) { - __extends(StatusCodeView, _super); function StatusCodeView() { - return StatusCodeView.__super__.constructor.apply(this, arguments); + _ref5 = StatusCodeView.__super__.constructor.apply(this, arguments); + return _ref5; } StatusCodeView.prototype.initialize = function() {}; StatusCodeView.prototype.render = function() { - var template; + var responseModel, responseModelView, template; template = this.template(); $(this.el).html(template(this.model)); + if (swaggerUi.api.models.hasOwnProperty(this.model.responseModel)) { + responseModel = { + sampleJSON: JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(), null, 2), + isParam: false, + signature: swaggerUi.api.models[this.model.responseModel].getMockSignature() + }; + responseModelView = new SignatureView({ + model: responseModel, + tagName: 'div' + }); + $('.model-signature', this.$el).append(responseModelView.render().el); + } else { + $('.model-signature', this.$el).html(''); + } return this; }; @@ -1727,21 +2078,30 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials })(Backbone.View); ParameterView = (function(_super) { - __extends(ParameterView, _super); function ParameterView() { - return ParameterView.__super__.constructor.apply(this, arguments); + _ref6 = ParameterView.__super__.constructor.apply(this, arguments); + return _ref6; } - ParameterView.prototype.initialize = function() {}; + ParameterView.prototype.initialize = function() { + return Handlebars.registerHelper('isArray', function(param, opts) { + if (param.type.toLowerCase() === 'array' || param.allowMultiple) { + return opts.fn(this); + } else { + return opts.inverse(this); + } + }); + }; ParameterView.prototype.render = function() { - var contentTypeModel, contentTypeView, signatureModel, signatureView, template; + 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 (this.model.dataType === 'file') { + if (type.toLowerCase() === 'file') { this.model.isFile = true; } template = this.template(); @@ -1760,14 +2120,25 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials } else { $('.model-signature', $(this.el)).html(this.model.signature); } + isParam = false; + if (this.model.isBody) { + isParam = true; + } contentTypeModel = { - isParam: true, - supportedContentTypes: this.model.supportedContentTypes + isParam: isParam }; - contentTypeView = new ContentTypeView({ - model: contentTypeModel - }); - $('.content-type', $(this.el)).append(contentTypeView.render().el); + 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; }; @@ -1796,11 +2167,11 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials })(Backbone.View); SignatureView = (function(_super) { - __extends(SignatureView, _super); function SignatureView() { - return SignatureView.__super__.constructor.apply(this, arguments); + _ref7 = SignatureView.__super__.constructor.apply(this, arguments); + return _ref7; } SignatureView.prototype.events = { @@ -1815,7 +2186,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials var template; template = this.template(); $(this.el).html(template(this.model)); - this.switchToDescription(); + this.switchToSnippet(); this.isParam = this.model.isParam; if (this.isParam) { $('.notice', $(this.el)).text('Click to set as parameter value'); @@ -1865,11 +2236,11 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials })(Backbone.View); ContentTypeView = (function(_super) { - __extends(ContentTypeView, _super); function ContentTypeView() { - return ContentTypeView.__super__.constructor.apply(this, arguments); + _ref8 = ContentTypeView.__super__.constructor.apply(this, arguments); + return _ref8; } ContentTypeView.prototype.initialize = function() {}; @@ -1878,12 +2249,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials var template; template = this.template(); $(this.el).html(template(this.model)); - this.isParam = this.model.isParam; - if (this.isParam) { - $('label[for=contentType]', $(this.el)).text('Parameter content type:'); - } else { - $('label[for=contentType]', $(this.el)).text('Response Content Type'); - } + $('label[for=contentType]', $(this.el)).text('Response Content Type'); return this; }; @@ -1895,4 +2261,56 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials })(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/tastypie_swagger/static/tastypie_swagger/js/swagger-ui.min.js b/tastypie_swagger/static/tastypie_swagger/js/swagger-ui.min.js old mode 100644 new mode 100755 index ecff26d..0373460 --- a/tastypie_swagger/static/tastypie_swagger/js/swagger-ui.min.js +++ b/tastypie_swagger/static/tastypie_swagger/js/swagger-ui.min.js @@ -1 +1 @@ -$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}function log(){if(window.console){console.log.apply(console,arguments)}}if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,p,f,n,m){f=f||g.helpers;var l="",c,s,k,j,q=this,h="function",o=f.helperMissing,i=void 0;function e(x,w){var t="",v,u;t+="\n ";k=f.supportedContentTypes;v=k||x.supportedContentTypes;u=f.each;j=q.program(2,d,w);j.hash={};j.fn=j;j.inverse=q.noop;v=u.call(x,v,j);if(v||v===0){t+=v}t+="\n";return t}function d(w,v){var t="",u;t+='\n \n ";return t}function r(u,t){return'\n \n'}l+='\n\n";return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(f,p,e,n,m){e=e||f.helpers;var k="",c,r,j,i,q=this,g="function",o=e.helperMissing,h=void 0,l=this.escapeExpression;function d(v,u){var s="",t;s+='\n , api version: ';j=e.apiVersion;t=j||v.apiVersion;if(typeof t===g){t=t.call(v,{hash:{}})}else{if(t===h){t=o.call(v,"apiVersion",{hash:{}})}}s+=l(t)+"\n ";return s}k+="\n
    \n
      \n
    \n\n
    \n
    \n
    \n

    [ base url: ";j=e.basePath;c=j||p.basePath;if(typeof c===g){c=c.call(p,{hash:{}})}else{if(c===h){c=o.call(p,"basePath",{hash:{}})}}k+=l(c)+"\n ";j=e.apiVersion;c=j||p.apiVersion;r=e["if"];i=q.program(1,d,m);i.hash={};i.fn=i;i.inverse=q.noop;c=r.call(p,c,i);if(c||c===0){k+=c}k+="]

    \n
    \n
    \n";return k})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(h,u,s,m,v){s=s||h.helpers;var t="",j,g,i,q,p=this,e="function",r=s.helperMissing,c=void 0,d=this.escapeExpression;function o(z,y){var w="",x;w+="\n

    Implementation Notes

    \n

    ";i=s.notes;x=i||z.notes;if(typeof x===e){x=x.call(z,{hash:{}})}else{if(x===c){x=r.call(z,"notes",{hash:{}})}}if(x||x===0){w+=x}w+="

    \n ";return w}function n(x,w){return'\n

    Response Class

    \n

    \n
    \n
    \n '}function l(x,w){return"\n
    \n

    Status Codes

    \n \n \n \n \n \n \n \n \n \n \n
    HTTP Status CodeReason
    \n "}function k(x,w){return"\n "}function f(x,w){return"\n
    \n \n \n \n
    \n "}t+="\n \n";return t})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(h,v,t,m,y){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(D,C){var z="",B,A;z+="\n ";i=t.isFile;B=i||D.isFile;A=t["if"];r=q.program(2,o,C);r.hash={};r.fn=r;r.inverse=q.program(4,n,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function o(C,B){var z="",A;z+='\n \n ";return z}function n(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(5,l,C);r.hash={};r.fn=r;r.inverse=q.program(7,k,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function l(C,B){var z="",A;z+="\n \n ";return z}function k(C,B){var z="",A;z+="\n \n
    \n
    \n ';return z}function f(D,C){var z="",B,A;z+="\n ";i=t.defaultValue;B=i||D.defaultValue;A=t["if"];r=q.program(10,x,C);r.hash={};r.fn=r;r.inverse=q.program(12,w,C);B=A.call(D,B,r);if(B||B===0){z+=B}z+="\n ";return z}function x(C,B){var z="",A;z+="\n \n ";return z}function w(C,B){var z="",A;z+="\n \n ";return z}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+"\n\n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,y);r.hash={};r.fn=r;r.inverse=q.program(9,f,y);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n\n\n";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+='\n\n \n\n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,v,t,m,x){t=t||h.helpers;var u="",k,g,j,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(z,y){return"\n "}function o(C,B){var y="",A,z;y+="\n ";j=t.defaultValue;A=j||C.defaultValue;z=t["if"];r=q.program(4,n,B);r.hash={};r.fn=r;r.inverse=q.program(6,l,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function n(z,y){return"\n "}function l(z,y){return"\n \n "}function i(C,B){var y="",A,z;y+="\n ";j=t.isDefault;A=j||C.isDefault;z=t["if"];r=q.program(9,f,B);r.hash={};r.fn=r;r.inverse=q.program(11,w,B);A=z.call(C,A,r);if(A||A===0){y+=A}y+="\n ";return y}function f(B,A){var y="",z;y+="\n \n ";return y}function w(B,A){var y="",z;y+="\n \n ";return y}u+="";j=t.name;k=j||v.name;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"name",{hash:{}})}}u+=d(k)+"\n\n \n\n";j=t.description;k=j||v.description;if(typeof k===e){k=k.call(v,{hash:{}})}else{if(k===c){k=s.call(v,"description",{hash:{}})}}if(k||k===0){u+=k}u+='\n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,q,f,o,n){f=f||g.helpers;var l="",d,s,k,j,r=this,h="function",p=f.helperMissing,i=void 0,m=this.escapeExpression;function e(w,v){var t="",u;t+="\n \n ";return t}function c(w,v){var t="",u;t+="\n ";k=f.defaultValue;u=k||w.defaultValue;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=p.call(w,"defaultValue",{hash:{}})}}t+=m(u)+"\n ";return t}l+="";k=f.name;d=k||q.name;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"name",{hash:{}})}}l+=m(d)+"\n\n ";k=f.isBody;d=k||q.isBody;s=f["if"];j=r.program(1,e,n);j.hash={};j.fn=j;j.inverse=r.program(3,c,n);d=s.call(q,d,j);if(d||d===0){l+=d}l+="\n\n";k=f.description;d=k||q.description;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"description",{hash:{}})}}if(d||d===0){l+=d}l+='\n\n';return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,q,f,o,n){f=f||g.helpers;var l="",d,s,k,j,r=this,h="function",p=f.helperMissing,i=void 0,m=this.escapeExpression;function e(w,v){var t="",u;t+="\n \n ";return t}function c(w,v){var t="",u;t+="\n ";k=f.defaultValue;u=k||w.defaultValue;if(typeof u===h){u=u.call(w,{hash:{}})}else{if(u===i){u=p.call(w,"defaultValue",{hash:{}})}}t+=m(u)+"\n ";return t}l+="";k=f.name;d=k||q.name;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"name",{hash:{}})}}l+=m(d)+"\n\n ";k=f.isBody;d=k||q.isBody;s=f["if"];j=r.program(1,e,n);j.hash={};j.fn=j;j.inverse=r.program(3,c,n);d=s.call(q,d,j);if(d||d===0){l+=d}l+="\n\n";k=f.description;d=k||q.description;if(typeof d===h){d=d.call(q,{hash:{}})}else{if(d===i){d=p.call(q,"description",{hash:{}})}}if(d||d===0){l+=d}l+='\n\n';return l})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(h,v,t,m,A){t=t||h.helpers;var u="",j,g,i,r,q=this,e="function",s=t.helperMissing,c=void 0,d=this.escapeExpression;function p(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(2,o,E);r.hash={};r.fn=r;r.inverse=q.program(4,n,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function o(E,D){var B="",C;B+='\n \n ";return B}function n(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(5,l,E);r.hash={};r.fn=r;r.inverse=q.program(7,k,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function l(E,D){var B="",C;B+="\n \n ";return B}function k(E,D){var B="",C;B+="\n \n
    \n
    \n ';return B}function f(F,E){var B="",D,C;B+="\n ";i=t.isFile;D=i||F.isFile;C=t["if"];r=q.program(10,z,E);r.hash={};r.fn=r;r.inverse=q.program(12,y,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function z(E,D){var B="",C;B+="\n \n ";return B}function y(F,E){var B="",D,C;B+="\n ";i=t.defaultValue;D=i||F.defaultValue;C=t["if"];r=q.program(13,x,E);r.hash={};r.fn=r;r.inverse=q.program(15,w,E);D=C.call(F,D,r);if(D||D===0){B+=D}B+="\n ";return B}function x(E,D){var B="",C;B+="\n \n ";return B}function w(E,D){var B="",C;B+="\n \n ";return B}u+="";i=t.name;j=i||v.name;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"name",{hash:{}})}}u+=d(j)+"\n\n ";i=t.isBody;j=i||v.isBody;g=t["if"];r=q.program(1,p,A);r.hash={};r.fn=r;r.inverse=q.program(9,f,A);j=g.call(v,j,r);if(j||j===0){u+=j}u+="\n\n\n ";i=t.description;j=i||v.description;if(typeof j===e){j=j.call(v,{hash:{}})}else{if(j===c){j=s.call(v,"description",{hash:{}})}}if(j||j===0){u+=j}u+='\n\n\n';return u})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+='
    \n\n
    \n\n
    \n
    \n ';h=d.signature;c=h||n.signature;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"signature",{hash:{}})}}if(c||c===0){i+=c}i+='\n
    \n\n
    \n
    ';h=d.sampleJSON;c=h||n.sampleJSON;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"sampleJSON",{hash:{}})}}i+=j(c)+'
    \n \n
    \n
    \n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,n,d,l,k){d=d||e.helpers;var i="",c,h,o=this,f="function",m=d.helperMissing,g=void 0,j=this.escapeExpression;i+="";h=d.code;c=h||n.code;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"code",{hash:{}})}}i+=j(c)+"\n";h=d.reason;c=h||n.reason;if(typeof c===f){c=c.call(n,{hash:{}})}else{if(c===g){c=m.call(n,"reason",{hash:{}})}}if(c||c===0){i+=c}i+="\n\n";return i})})();(function(){var f,b,h,c,e,j,k,i,a,g={}.hasOwnProperty,d=function(o,m){for(var l in m){if(g.call(m,l)){o[l]=m[l]}}function n(){this.constructor=o}n.prototype=m.prototype;o.prototype=new n();o.__super__=m.prototype;return o};a=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.dom_id="swagger_ui";l.prototype.options=null;l.prototype.api=null;l.prototype.headerView=null;l.prototype.mainView=null;l.prototype.initialize=function(n){var o=this;if(n==null){n={}}if(n.dom_id!=null){this.dom_id=n.dom_id;delete n.dom_id}if(!($("#"+this.dom_id)!=null)){$("body").append('
    ')}this.options=n;this.options.success=function(){return o.render()};this.options.progress=function(p){return o.showMessage(p)};this.options.failure=function(p){return o.onLoadFailure(p)};this.headerView=new b({el:$("#header")});return this.headerView.on("update-swagger-ui",function(p){return o.updateSwaggerUi(p)})};l.prototype.updateSwaggerUi=function(n){this.options.discoveryUrl=n.discoveryUrl;this.options.apiKey=n.apiKey;return this.load()};l.prototype.load=function(){var n;if((n=this.mainView)!=null){n.clear()}this.headerView.update(this.options.discoveryUrl,this.options.apiKey);return this.api=new SwaggerApi(this.options)};l.prototype.render=function(){var n=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new h({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)};l.prototype.showMessage=function(n){if(n==null){n=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(n)};l.prototype.onLoadFailure=function(n){var o;if(n==null){n=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");o=$("#message-bar").html(n);if(this.options.onFailure!=null){this.options.onFailure(n)}return o};return l})(Backbone.Router);window.SwaggerUi=a;b=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.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"};l.prototype.initialize=function(){};l.prototype.showPetStore=function(n){return this.trigger("update-swagger-ui",{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",apiKey:"special-key"})};l.prototype.showWordnikDev=function(n){return this.trigger("update-swagger-ui",{discoveryUrl:"http://api.wordnik.com/v4/resources.json",apiKey:""})};l.prototype.showCustomOnKeyup=function(n){if(n.keyCode===13){return this.showCustom()}};l.prototype.showCustom=function(n){if(n!=null){n.preventDefault()}return this.trigger("update-swagger-ui",{discoveryUrl:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};l.prototype.update=function(o,p,n){if(n==null){n=false}$("#input_baseUrl").val(o);$("#input_apiKey").val(p);if(n){return this.trigger("update-swagger-ui",{discoveryUrl:o,apiKey:p})}};return l})(Backbone.View);h=(function(l){d(m,l);function m(){return m.__super__.constructor.apply(this,arguments)}m.prototype.initialize=function(){};m.prototype.render=function(){var q,p,n,o;$(this.el).html(Handlebars.templates.main(this.model));o=this.model.resourcesArray;for(p=0,n=o.length;p=0;if(!y){this.model.isReadOnly=true}$(this.el).html(Handlebars.templates.operation(this.model));if(this.model.responseClassSignature&&this.model.responseClassSignature!=="string"){z={sampleJSON:this.model.responseSampleJSON,isParam:false,signature:this.model.responseClassSignature};u=new k({model:z,tagName:"div"});$(".model-signature",$(this.el)).append(u.render().el)}else{$(".model-signature",$(this.el)).html(this.model.responseClass)}n={isParam:false,supportedContentTypes:this.model.supportedContentTypes};x=new f({model:n});$(".content-type",$(this.el)).append(x.render().el);t=this.model.parameters;for(s=0,w=t.length;s0){I[D.name]=D.value}}H=$('input[type~="file"]').size!==0;if(H){B=new FormData();v=this.model.parameters;for(r=0,K=v.length;r"+w+"
    ");$(".response_throbber",$(this.el)).show();z={type:this.model.httpMethod,url:w,headers:n,data:B,dataType:"json",processData:false,error:function(L,M,o){return E.showErrorStatus(L,M,o)},success:function(o){return E.showResponse(o)},complete:function(o){return E.showCompleteStatus(o)}};if(z.type.toLowerCase()==="post"||z.type.toLowerCase()==="put"||z.type.toLowerCase()==="patch"){z.contentType="application/json"}if(H){z.contentType=false}C=$("td select[name=contentType]",$(this.el)).val();if(C){z.contentType=C}p=$(".content > .content-type > div > select[name=contentType]",$(this.el)).val();if(p){z.headers=z.headers!=null?z.headers:{};z.headers.accept=p}jQuery.ajax(z);return false}};l.prototype.hideResponse=function(n){if(n!=null){n.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};l.prototype.showResponse=function(n){var o;o=JSON.stringify(n,null,"\t").replace(/\n/g,"
    ");return $(".response_body",$(this.el)).html(escape(o))};l.prototype.showErrorStatus=function(n){return this.showStatus(n)};l.prototype.showCompleteStatus=function(n){return this.showStatus(n)};l.prototype.formatXml=function(u){var q,t,o,v,A,w,p,n,y,z,s,r,x;n=/(>)(<)(\/*)/g;z=/[ ]*(.*)[ ]+\n/g;q=/(<.+>)(.+\n)/g;u=u.replace(n,"$1\n$2$3").replace(z,"$1\n").replace(q,"$1\n$2");p=0;t="";A=u.split("\n");o=0;v="other";y={"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};s=function(G){var C,B,E,I,F,D,H;D={single:Boolean(G.match(/<.+\/>/)),closing:Boolean(G.match(/<\/.+>/)),opening:Boolean(G.match(/<[^!?].*>/))};F=((function(){var J;J=[];for(E in D){H=D[E];if(H){J.push(E)}}return J})())[0];F=F===void 0?"other":F;C=v+"->"+F;v=F;I="";o+=y[C];I=((function(){var K,L,J;J=[];for(B=K=0,L=o;0<=L?KL;B=0<=L?++K:--K){J.push(" ")}return J})()).join("");if(C==="opening->closing"){return t=t.substr(0,t.length-1)+G+"\n"}else{return t+=I+G+"\n"}};for(r=0,x=A.length;r").text(JSON.stringify(JSON.parse(q.responseText),null,2));r=$('
    ').append(p)}catch(n){p=$("").text(this.formatXml(q.responseText));r=$('
    ').append(p)}o=r;$(".response_code",$(this.el)).html("
    "+q.status+"
    ");$(".response_body",$(this.el)).html(o);$(".response_headers",$(this.el)).html("
    "+q.getAllResponseHeaders()+"
    ");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();return hljs.highlightBlock($(".response_body",$(this.el))[0])};l.prototype.toggleOperationContent=function(){var n;n=$("#"+this.model.resourceName+"_"+this.model.nickname+"_"+this.model.httpMethod+"_"+this.model.number+"_content");if(n.is(":visible")){return Docs.collapseOperation(n)}else{return Docs.expandOperation(n)}};return l})(Backbone.View);i=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.initialize=function(){};l.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));return this};l.prototype.template=function(){return Handlebars.templates.status_code};return l})(Backbone.View);e=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.initialize=function(){};l.prototype.render=function(){var q,o,n,r,p;if(this.model.paramType==="body"){this.model.isBody=true}if(this.model.dataType==="file"){this.model.isFile=true}p=this.template();$(this.el).html(p(this.model));n={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){r=new k({model:n,tagName:"div"});$(".model-signature",$(this.el)).append(r.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}q={isParam:true,supportedContentTypes:this.model.supportedContentTypes};o=new f({model:q});$(".content-type",$(this.el)).append(o.render().el);return this};l.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 l})(Backbone.View);k=(function(m){d(l,m);function l(){return l.__super__.constructor.apply(this,arguments)}l.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};l.prototype.initialize=function(){};l.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));this.switchToDescription();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};l.prototype.template=function(){return Handlebars.templates.signature};l.prototype.switchToDescription=function(n){if(n!=null){n.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};l.prototype.switchToSnippet=function(n){if(n!=null){n.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};l.prototype.snippetToTextArea=function(n){var o;if(this.isParam){if(n!=null){n.preventDefault()}o=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(o.val())===""){return o.val(this.model.sampleJSON)}}};return l})(Backbone.View);f=(function(l){d(m,l);function m(){return m.__super__.constructor.apply(this,arguments)}m.prototype.initialize=function(){};m.prototype.render=function(){var n;n=this.template();$(this.el).html(n(this.model));this.isParam=this.model.isParam;if(this.isParam){$("label[for=contentType]",$(this.el)).text("Parameter content type:")}else{$("label[for=contentType]",$(this.el)).text("Response Content Type")}return this};m.prototype.template=function(){return Handlebars.templates.content_type};return m})(Backbone.View)}).call(this); \ No newline at end of file +$(function(){$.fn.vAlign=function(){return this.each(function(c){var a=$(this).height();var d=$(this).parent().height();var b=(d-a)/2;$(this).css("margin-top",b)})};$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(b){var d=$(this).closest("form").innerWidth();var c=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10);var a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",d-c-a)})};$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent();$("ul.downplayed li div.content p").vAlign();$("form.sandbox").submit(function(){var a=true;$(this).find("input.required").each(function(){$(this).removeClass("error");if($(this).val()==""){$(this).addClass("error");$(this).wiggle();a=false}});return a})});function clippyCopiedCallback(b){$("#api_key_copied").fadeIn().delay(1000).fadeOut()}log=function(){log.history=log.history||[];log.history.push(arguments);if(this.console){console.log(Array.prototype.slice.call(arguments)[0])}};if(Function.prototype.bind&&console&&typeof console.log=="object"){["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(a){console[a]=this.bind(console[a],console)},Function.prototype.call)}var Docs={shebang:function(){var b=$.param.fragment().split("/");b.shift();switch(b.length){case 1:log("shebang resource:"+b[0]);var d="resource_"+b[0];Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});break;case 2:log("shebang endpoint: "+b.join("_"));Docs.expandEndpointListForResource(b[0]);$("#"+d).slideto({highlight:false});var c=b.join("_");var a=c+"_content";log("li_dom_id "+c);log("li_content_dom_id "+a);Docs.expandOperation($("#"+a));$("#"+c).slideto({highlight:false});break}},toggleEndpointListForResource:function(b){var a=$("li#resource_"+Docs.escapeResourceName(b)+" ul.endpoints");if(a.is(":visible")){Docs.collapseEndpointListForResource(b)}else{Docs.expandEndpointListForResource(b)}},expandEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);if(b==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+b).addClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideDown()},collapseEndpointListForResource:function(b){var b=Docs.escapeResourceName(b);$("li#resource_"+b).removeClass("active");var a=$("li#resource_"+b+" ul.endpoints");a.slideUp()},expandOperationsForResource:function(a){Docs.expandEndpointListForResource(a);if(a==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(a){Docs.expandEndpointListForResource(a);$("li#resource_"+Docs.escapeResourceName(a)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(a){return a.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(a){a.slideDown()},collapseOperation:function(a){a.slideUp()}};(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.main=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",c,h="function",j=this.escapeExpression,p=this;function e(v,u){var r="",t,s;r+='\n
    '+j(((t=((t=v.info),t==null||t===false?t:t.title)),typeof t===h?t.apply(v):t))+'
    \n
    ';s=((t=((t=v.info),t==null||t===false?t:t.description)),typeof t===h?t.apply(v):t);if(s||s===0){r+=s}r+="
    \n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.termsOfServiceUrl),{hash:{},inverse:p.noop,fn:p.program(2,d,u),data:u});if(s||s===0){r+=s}r+="\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.contact),{hash:{},inverse:p.noop,fn:p.program(4,q,u),data:u});if(s||s===0){r+=s}r+="\n ";s=f["if"].call(v,((t=v.info),t==null||t===false?t:t.license),{hash:{},inverse:p.noop,fn:p.program(6,o,u),data:u});if(s||s===0){r+=s}r+="\n ";return r}function d(u,t){var r="",s;r+='';return r}function q(u,t){var r="",s;r+="';return r}function o(u,t){var r="",s;r+="";return r}function n(u,t){var r="",s;r+='\n , api version: ';if(s=f.apiVersion){s=s.call(u,{hash:{},data:t})}else{s=u.apiVersion;s=typeof s===h?s.apply(u):s}r+=j(s)+"\n ";return r}i+="
    \n ";c=f["if"].call(m,m.info,{hash:{},inverse:p.noop,fn:p.program(1,e,k),data:k});if(c||c===0){i+=c}i+="\n
    \n
    \n
      \n
    \n\n
    \n
    \n
    \n

    [ base url: ";if(c=f.basePath){c=c.call(m,{hash:{},data:k})}else{c=m.basePath;c=typeof c===h?c.apply(m):c}i+=j(c)+"\n ";c=f["if"].call(m,m.apiVersion,{hash:{},inverse:p.noop,fn:p.program(8,n,k),data:k});if(c||c===0){i+=c}i+="]

    \n
    \n
    \n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.operation=b(function(g,s,q,m,y){this.compilerInfo=[4,">= 1.0.0"];q=this.merge(q,g.helpers);y=y||{};var r="",i,f,e="function",d=this.escapeExpression,p=this,c=q.blockHelperMissing;function o(C,B){var z="",A;z+="\n

    Implementation Notes

    \n

    ";if(A=q.notes){A=A.call(C,{hash:{},data:B})}else{A=C.notes;A=typeof A===e?A.apply(C):A}if(A||A===0){z+=A}z+="

    \n ";return z}function n(A,z){return'\n
    \n '}function l(C,B){var z="",A;z+='\n \n ";return z}function k(D,C){var z="",B,A;z+="\n
    "+d(((B=D.scope),typeof B===e?B.apply(D):B))+"
    \n ";return z}function h(A,z){return"
    "}function x(A,z){return'\n
    \n \n
    \n '}function w(A,z){return'\n

    Response Class

    \n

    \n
    \n
    \n '}function v(A,z){return'\n

    Parameters

    \n \n \n \n \n \n \n \n \n \n \n \n\n \n
    ParameterValueDescriptionParameter TypeData Type
    \n '}function u(A,z){return"\n
    \n

    Response Messages

    \n \n \n \n \n \n \n \n \n \n \n \n
    HTTP Status CodeReasonResponse Model
    \n "}function t(A,z){return"\n "}function j(A,z){return"\n
    \n \n \n \n
    \n "}r+="\n
      \n
    • \n \n \n
    • \n
    \n";return r})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param=b(function(f,q,o,j,t){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);t=t||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(4,k,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function l(y,x){var v="",w;v+='\n \n
    \n ';return v}function k(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.defaultValue,{hash:{},inverse:n.program(7,h,x),fn:n.program(5,i,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function i(y,x){var v="",w;v+="\n \n ";return v}function h(y,x){var v="",w;v+="\n \n
    \n
    \n ';return v}function e(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.isFile,{hash:{},inverse:n.program(10,u,x),fn:n.program(2,l,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function u(y,x){var v="",w;v+="\n ";w=o["if"].call(y,y.defaultValue,{hash:{},inverse:n.program(13,r,x),fn:n.program(11,s,x),data:x});if(w||w===0){v+=w}v+="\n ";return v}function s(y,x){var v="",w;v+="\n \n ";return v}function r(y,x){var v="",w;v+="\n \n ";return v}p+="";if(g=o.name){g=g.call(q,{hash:{},data:t})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,t),fn:n.program(1,m,t),data:t});if(g||g===0){p+=g}p+="\n\n\n";if(g=o.description){g=g.call(q,{hash:{},data:t})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n";if(g=o.paramType){g=g.call(q,{hash:{},data:t})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n \n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_list=b(function(h,t,r,m,y){this.compilerInfo=[4,">= 1.0.0"];r=this.merge(r,h.helpers);y=y||{};var s="",j,g,e,p=this,q=r.helperMissing,d="function",c=this.escapeExpression;function o(A,z){return" multiple='multiple'"}function n(A,z){return"\n "}function l(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.defaultValue,{hash:{},inverse:p.program(8,i,B),fn:p.program(6,k,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function k(A,z){return"\n "}function i(E,D){var z="",C,B,A;z+="\n ";A={hash:{},inverse:p.program(11,x,D),fn:p.program(9,f,D),data:D};B=((C=r.isArray||E.isArray),C?C.call(E,E,A):q.call(E,"isArray",E,A));if(B||B===0){z+=B}z+="\n ";return z}function f(A,z){return"\n "}function x(A,z){return"\n \n "}function w(C,B){var z="",A;z+="\n ";A=r["if"].call(C,C.isDefault,{hash:{},inverse:p.program(16,u,B),fn:p.program(14,v,B),data:B});if(A||A===0){z+=A}z+="\n ";return z}function v(C,B){var z="",A;z+='\n \n ";return z}function u(C,B){var z="",A;z+="\n \n ";return z}s+="";if(j=r.name){j=j.call(t,{hash:{},data:y})}else{j=t.name;j=typeof j===d?j.apply(t):j}s+=c(j)+"\n\n \n\n";if(g=r.description){g=g.call(t,{hash:{},data:y})}else{g=t.description;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+="\n";if(g=r.paramType){g=g.call(t,{hash:{},data:y})}else{g=t.paramType;g=typeof g===d?g.apply(t):g}if(g||g===0){s+=g}s+='\n';return s})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_readonly_required=b(function(g,m,f,l,k){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);k=k||{};var i="",d,h="function",j=this.escapeExpression,o=this;function e(t,s){var q="",r;q+="\n \n ";return q}function c(t,s){var q="",r;q+="\n ";r=f["if"].call(t,t.defaultValue,{hash:{},inverse:o.program(6,n,s),fn:o.program(4,p,s),data:s});if(r||r===0){q+=r}q+="\n ";return q}function p(t,s){var q="",r;q+="\n ";if(r=f.defaultValue){r=r.call(t,{hash:{},data:s})}else{r=t.defaultValue;r=typeof r===h?r.apply(t):r}q+=j(r)+"\n ";return q}function n(r,q){return"\n (empty)\n "}i+="";if(d=f.name){d=d.call(m,{hash:{},data:k})}else{d=m.name;d=typeof d===h?d.apply(m):d}i+=j(d)+"\n\n ";d=f["if"].call(m,m.isBody,{hash:{},inverse:o.program(3,c,k),fn:o.program(1,e,k),data:k});if(d||d===0){i+=d}i+="\n\n";if(d=f.description){d=d.call(m,{hash:{},data:k})}else{d=m.description;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+="\n";if(d=f.paramType){d=d.call(m,{hash:{},data:k})}else{d=m.paramType;d=typeof d===h?d.apply(m):d}if(d||d===0){i+=d}i+='\n\n';return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.param_required=b(function(f,q,o,j,u){this.compilerInfo=[4,">= 1.0.0"];o=this.merge(o,f.helpers);u=u||{};var p="",g,d="function",c=this.escapeExpression,n=this;function m(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(4,k,y),fn:n.program(2,l,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function l(z,y){var w="",x;w+='\n \n ";return w}function k(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(7,h,y),fn:n.program(5,i,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function i(z,y){var w="",x;w+="\n \n ";return w}function h(z,y){var w="",x;w+="\n \n
    \n
    \n ';return w}function e(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.isFile,{hash:{},inverse:n.program(12,t,y),fn:n.program(10,v,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function v(z,y){var w="",x;w+="\n \n ";return w}function t(z,y){var w="",x;w+="\n ";x=o["if"].call(z,z.defaultValue,{hash:{},inverse:n.program(15,r,y),fn:n.program(13,s,y),data:y});if(x||x===0){w+=x}w+="\n ";return w}function s(z,y){var w="",x;w+="\n \n ";return w}function r(z,y){var w="",x;w+="\n \n ";return w}p+="";if(g=o.name){g=g.call(q,{hash:{},data:u})}else{g=q.name;g=typeof g===d?g.apply(q):g}p+=c(g)+"\n\n ";g=o["if"].call(q,q.isBody,{hash:{},inverse:n.program(9,e,u),fn:n.program(1,m,u),data:u});if(g||g===0){p+=g}p+="\n\n\n ";if(g=o.description){g=g.call(q,{hash:{},data:u})}else{g=q.description;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+="\n\n";if(g=o.paramType){g=g.call(q,{hash:{},data:u})}else{g=q.paramType;g=typeof g===d?g.apply(q):g}if(g||g===0){p+=g}p+='\n\n';return p})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.parameter_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.consumes,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.resource=b(function(f,l,e,k,j){this.compilerInfo=[4,">= 1.0.0"];e=this.merge(e,f.helpers);j=j||{};var h="",c,o,g="function",i=this.escapeExpression,n=this,m=e.blockHelperMissing;function d(q,p){return" : "}h+="
    \n

    \n ";if(c=e.name){c=c.call(l,{hash:{},data:j})}else{c=l.name;c=typeof c===g?c.apply(l):c}h+=i(c)+" ";o={hash:{},inverse:n.noop,fn:n.program(1,d,j),data:j};if(c=e.description){c=c.call(l,o)}else{c=l.description;c=typeof c===g?c.apply(l):c}if(!e.description){c=m.call(l,c,o)}if(c||c===0){h+=c}if(c=e.description){c=c.call(l,{hash:{},data:j})}else{c=l.description;c=typeof c===g?c.apply(l):c}if(c||c===0){h+=c}h+="\n

    \n \n
    \n\n";return h})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.response_content_type=b(function(g,l,f,k,j){this.compilerInfo=[4,">= 1.0.0"];f=this.merge(f,g.helpers);j=j||{};var i="",c,h="function",m=this;function e(r,q){var o="",p;o+="\n ";p=f.each.call(r,r.produces,{hash:{},inverse:m.noop,fn:m.program(2,d,q),data:q});if(p||p===0){o+=p}o+="\n";return o}function d(r,q){var o="",p;o+='\n \n ";return o}function n(p,o){return'\n \n'}i+='\n\n";return i})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.signature=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+='
    \n\n
    \n\n
    \n
    \n ';if(c=d.signature){c=c.call(k,{hash:{},data:i})}else{c=k.signature;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+='\n
    \n\n
    \n
    ';if(c=d.sampleJSON){c=c.call(k,{hash:{},data:i})}else{c=k.sampleJSON;c=typeof c===f?c.apply(k):c}g+=h(c)+'
    \n \n
    \n
    \n\n';return g})})();(function(){var b=Handlebars.template,a=Handlebars.templates=Handlebars.templates||{};a.status_code=b(function(e,k,d,j,i){this.compilerInfo=[4,">= 1.0.0"];d=this.merge(d,e.helpers);i=i||{};var g="",c,f="function",h=this.escapeExpression;g+="";if(c=d.code){c=c.call(k,{hash:{},data:i})}else{c=k.code;c=typeof c===f?c.apply(k):c}g+=h(c)+"\n";if(c=d.message){c=c.call(k,{hash:{},data:i})}else{c=k.message;c=typeof c===f?c.apply(k):c}if(c||c===0){g+=c}g+="\n";return g})})();(function(){var j,r,u,o,l,k,n,m,i,p,s,q,h,c,g,f,e,d,b,a,x,w,t={}.hasOwnProperty,v=function(B,z){for(var y in z){if(t.call(z,y)){B[y]=z[y]}}function A(){this.constructor=B}A.prototype=z.prototype;B.prototype=new A();B.__super__=z.prototype;return B};s=(function(z){v(y,z);function y(){q=y.__super__.constructor.apply(this,arguments);return q}y.prototype.dom_id="swagger_ui";y.prototype.options=null;y.prototype.api=null;y.prototype.headerView=null;y.prototype.mainView=null;y.prototype.initialize=function(A){var B=this;if(A==null){A={}}if(A.dom_id!=null){this.dom_id=A.dom_id;delete A.dom_id}if($("#"+this.dom_id)==null){$("body").append('
    ')}this.options=A;this.options.success=function(){return B.render()};this.options.progress=function(C){return B.showMessage(C)};this.options.failure=function(C){return B.onLoadFailure(C)};this.headerView=new r({el:$("#header")});return this.headerView.on("update-swagger-ui",function(C){return B.updateSwaggerUi(C)})};y.prototype.updateSwaggerUi=function(A){this.options.url=A.url;return this.load()};y.prototype.load=function(){var B,A;if((A=this.mainView)!=null){A.clear()}B=this.options.url;if(B.indexOf("http")!==0){B=this.buildUrl(window.location.href.toString(),B)}this.options.url=B;this.headerView.update(B);this.api=new SwaggerApi(this.options);this.api.build();return this.api};y.prototype.render=function(){var A=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI...");this.mainView=new u({model:this.api,el:$("#"+this.dom_id),swaggerOptions:this.options}).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)};y.prototype.buildUrl=function(C,A){var B,D;log("base is "+C);if(A.indexOf("/")===0){D=C.split("/");C=D[0]+"//"+D[2];return C+A}else{B=C.length;if(C.indexOf("?")>-1){B=Math.min(B,C.indexOf("?"))}if(C.indexOf("#")>-1){B=Math.min(B,C.indexOf("#"))}C=C.substring(0,B);if(C.indexOf("/",C.length-1)!==-1){return C+A}return C+"/"+A}};y.prototype.showMessage=function(A){if(A==null){A=""}$("#message-bar").removeClass("message-fail");$("#message-bar").addClass("message-success");return $("#message-bar").html(A)};y.prototype.onLoadFailure=function(A){var B;if(A==null){A=""}$("#message-bar").removeClass("message-success");$("#message-bar").addClass("message-fail");B=$("#message-bar").html(A);if(this.options.onFailure!=null){this.options.onFailure(A)}return B};return y})(Backbone.Router);window.SwaggerUi=s;r=(function(z){v(y,z);function y(){h=y.__super__.constructor.apply(this,arguments);return h}y.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"};y.prototype.initialize=function(){};y.prototype.showPetStore=function(A){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})};y.prototype.showWordnikDev=function(A){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})};y.prototype.showCustomOnKeyup=function(A){if(A.keyCode===13){return this.showCustom()}};y.prototype.showCustom=function(A){if(A!=null){A.preventDefault()}return this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})};y.prototype.update=function(B,C,A){if(A==null){A=false}$("#input_baseUrl").val(B);if(A){return this.trigger("update-swagger-ui",{url:B})}};return y})(Backbone.View);u=(function(y){var z;v(A,y);function A(){g=A.__super__.constructor.apply(this,arguments);return g}z={alpha:function(C,B){return C.path.localeCompare(B.path)},method:function(C,B){return C.method.localeCompare(B.method)}};A.prototype.initialize=function(D){var C,H,F,E,B,G;if(D==null){D={}}if(D.swaggerOptions.sorter){F=D.swaggerOptions.sorter;H=z[F];G=this.model.apisArray;for(E=0,B=G.length;EB){K=B-C}if(KA){H=A-E}if(H0){D[I.name]=I.value}if(I.type==="file"){N=true}}E=G.find("textarea");for(L=0,F=E.length;L0){D.body=I.value}}B=G.find("select");for(K=0,C=B.length;K0){D[I.name]=J}}A.responseContentType=$("div select[name=responseContentType]",$(this.el)).val();A.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val();$(".response_throbber",$(this.el)).show();if(N){return this.handleFileUpload(D,G)}else{return this.model["do"](D,A,this.showCompleteStatus,this.showErrorStatus,this)}}};y.prototype.success=function(A,B){return B.showCompleteStatus(A)};y.prototype.handleFileUpload=function(R,I){var M,H,C,N,L,K,P,J,G,F,D,Q,U,T,S,E,B,A,V,O=this;E=I.serializeArray();for(J=0,Q=E.length;J0){R[N.name]=N.value}}M=new FormData();P=0;B=this.model.parameters;for(G=0,U=B.length;G
    ");$(".request_url pre",$(this.el)).text(this.invocationUrl);L={type:this.model.method,url:this.invocationUrl,headers:C,data:M,dataType:"json",contentType:false,processData:false,error:function(X,Y,W){return O.showErrorStatus(O.wrap(X),O)},success:function(W){return O.showResponse(W,O)},complete:function(W){return O.showCompleteStatus(O.wrap(W),O)}};if(window.authorizations){window.authorizations.apply(L)}if(P===0){L.data.append("fake","true")}jQuery.ajax(L);return false};y.prototype.wrap=function(E){var C,F,H,B,G,D,A;H={};F=E.getAllResponseHeaders().split("\r");for(D=0,A=F.length;D0){return C.join(",")}else{return null}}};y.prototype.hideResponse=function(A){if(A!=null){A.preventDefault()}$(".response",$(this.el)).slideUp();return $(".response_hider",$(this.el)).fadeOut()};y.prototype.showResponse=function(A){var B;B=JSON.stringify(A,null,"\t").replace(/\n/g,"
    ");return $(".response_body",$(this.el)).html(escape(B))};y.prototype.showErrorStatus=function(B,A){return A.showStatus(B)};y.prototype.showCompleteStatus=function(B,A){return A.showStatus(B)};y.prototype.formatXml=function(H){var D,G,B,I,N,J,C,A,L,M,F,E,K;A=/(>)(<)(\/*)/g;M=/[ ]*(.*)[ ]+\n/g;D=/(<.+>)(.+\n)/g;H=H.replace(A,"$1\n$2$3").replace(M,"$1\n").replace(D,"$1\n$2");C=0;G="";N=H.split("\n");B=0;I="other";L={"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};F=function(T){var P,O,R,V,S,Q,U;Q={single:Boolean(T.match(/<.+\/>/)),closing:Boolean(T.match(/<\/.+>/)),opening:Boolean(T.match(/<[^!?].*>/))};S=((function(){var W;W=[];for(R in Q){U=Q[R];if(U){W.push(R)}}return W})())[0];S=S===void 0?"other":S;P=I+"->"+S;I=S;V="";B+=L[P];V=((function(){var X,Y,W;W=[];for(O=X=0,Y=B;0<=Y?XY;O=0<=Y?++X:--X){W.push(" ")}return W})()).join("");if(P==="opening->closing"){return G=G.substr(0,G.length-1)+T+"\n"}else{return G+=V+T+"\n"}};for(E=0,K=N.length;E").text("no content");E=$('
    ').append(C)}else{if(J==="application/json"||/\+json$/.test(J)){C=$("").text(JSON.stringify(JSON.parse(H),null,"  "));E=$('
    ').append(C)}else{if(J==="application/xml"||/\+xml$/.test(J)){C=$("").text(this.formatXml(H));E=$('
    ').append(C)}else{if(J==="text/html"){C=$("").html(H);E=$('
    ').append(C)}else{if(/^image\//.test(J)){E=$("").attr("src",B)}else{C=$("").text(H);E=$('
    ').append(C)}}}}}I=E;$(".request_url",$(this.el)).html("
    ");$(".request_url pre",$(this.el)).text(B);$(".response_code",$(this.el)).html("
    "+F.status+"
    ");$(".response_body",$(this.el)).html(I);$(".response_headers",$(this.el)).html("
    "+_.escape(JSON.stringify(F.headers,null,"  ")).replace(/\n/g,"
    ")+"
    ");$(".response",$(this.el)).slideDown();$(".response_hider",$(this.el)).show();$(".response_throbber",$(this.el)).hide();G=$(".response_body",$(this.el))[0];A=this.options.swaggerOptions;if(A.highlightSizeThreshold&&F.data.length>A.highlightSizeThreshold){return G}else{return hljs.highlightBlock(G)}};y.prototype.toggleOperationContent=function(){var A;A=$("#"+Docs.escapeResourceName(this.model.parentId)+"_"+this.model.nickname+"_content");if(A.is(":visible")){return Docs.collapseOperation(A)}else{return Docs.expandOperation(A)}};return y})(Backbone.View);p=(function(z){v(y,z);function y(){d=y.__super__.constructor.apply(this,arguments);return d}y.prototype.initialize=function(){};y.prototype.render=function(){var B,A,C;C=this.template();$(this.el).html(C(this.model));if(swaggerUi.api.models.hasOwnProperty(this.model.responseModel)){B={sampleJSON:JSON.stringify(swaggerUi.api.models[this.model.responseModel].createJSONSample(),null,2),isParam:false,signature:swaggerUi.api.models[this.model.responseModel].getMockSignature()};A=new i({model:B,tagName:"div"});$(".model-signature",this.$el).append(A.render().el)}else{$(".model-signature",this.$el).html("")}return this};y.prototype.template=function(){return Handlebars.templates.status_code};return y})(Backbone.View);k=(function(z){v(y,z);function y(){b=y.__super__.constructor.apply(this,arguments);return b}y.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(B,A){if(B.type.toLowerCase()==="array"||B.allowMultiple){return A.fn(this)}else{return A.inverse(this)}})};y.prototype.render=function(){var G,A,C,F,B,H,E,D;D=this.model.type||this.model.dataType;if(this.model.paramType==="body"){this.model.isBody=true}if(D.toLowerCase()==="file"){this.model.isFile=true}E=this.template();$(this.el).html(E(this.model));B={sampleJSON:this.model.sampleJSON,isParam:true,signature:this.model.signature};if(this.model.sampleJSON){H=new i({model:B,tagName:"div"});$(".model-signature",$(this.el)).append(H.render().el)}else{$(".model-signature",$(this.el)).html(this.model.signature)}A=false;if(this.model.isBody){A=true}G={isParam:A};G.consumes=this.model.consumes;if(A){C=new l({model:G});$(".parameter-content-type",$(this.el)).append(C.render().el)}else{F=new m({model:G});$(".response-content-type",$(this.el)).append(F.render().el)}return this};y.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 y})(Backbone.View);i=(function(z){v(y,z);function y(){a=y.__super__.constructor.apply(this,arguments);return a}y.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"};y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));this.switchToSnippet();this.isParam=this.model.isParam;if(this.isParam){$(".notice",$(this.el)).text("Click to set as parameter value")}return this};y.prototype.template=function(){return Handlebars.templates.signature};y.prototype.switchToDescription=function(A){if(A!=null){A.preventDefault()}$(".snippet",$(this.el)).hide();$(".description",$(this.el)).show();$(".description-link",$(this.el)).addClass("selected");return $(".snippet-link",$(this.el)).removeClass("selected")};y.prototype.switchToSnippet=function(A){if(A!=null){A.preventDefault()}$(".description",$(this.el)).hide();$(".snippet",$(this.el)).show();$(".snippet-link",$(this.el)).addClass("selected");return $(".description-link",$(this.el)).removeClass("selected")};y.prototype.snippetToTextArea=function(A){var B;if(this.isParam){if(A!=null){A.preventDefault()}B=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(B.val())===""){return B.val(this.model.sampleJSON)}}};return y})(Backbone.View);j=(function(y){v(z,y);function z(){x=z.__super__.constructor.apply(this,arguments);return x}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=contentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.content_type};return z})(Backbone.View);m=(function(y){v(z,y);function z(){w=z.__super__.constructor.apply(this,arguments);return w}z.prototype.initialize=function(){};z.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=responseContentType]",$(this.el)).text("Response Content Type");return this};z.prototype.template=function(){return Handlebars.templates.response_content_type};return z})(Backbone.View);l=(function(z){v(y,z);function y(){c=y.__super__.constructor.apply(this,arguments);return c}y.prototype.initialize=function(){};y.prototype.render=function(){var A;A=this.template();$(this.el).html(A(this.model));$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:");return this};y.prototype.template=function(){return Handlebars.templates.parameter_content_type};return y})(Backbone.View)}).call(this); \ No newline at end of file diff --git a/tastypie_swagger/templates/tastypie_swagger/index.html b/tastypie_swagger/templates/tastypie_swagger/index.html index 22f64bc..8022d5c 100644 --- a/tastypie_swagger/templates/tastypie_swagger/index.html +++ b/tastypie_swagger/templates/tastypie_swagger/index.html @@ -4,14 +4,15 @@ Swagger UI - - + + + - + @@ -47,7 +48,7 @@