From 149925fd0cd6daa9f646a34b6d2d54cc0b695636 Mon Sep 17 00:00:00 2001 From: Dennis Jung Date: Thu, 14 Jul 2016 10:06:06 +0900 Subject: [PATCH 01/11] Support django 1.9.x - Update requirements file - Change module --- requirements.txt | 8 ++++---- rest_framework_swagger/tests.py | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 44b2e020..ce099542 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,14 +1,14 @@ -Django==1.7.1 +Django>=1.7.1 Markdown==2.1.1 PyYAML==3.11 argh==0.23.2 argparse==1.2.1 coverage==3.6 -django-nose==1.2 +django-nose>=1.2 djangorestframework>=2.3.8 django-filter==0.11.0 jsonschema==2.5 -nose==1.3.0 +nose>=1.3.0 mock==1.0.1 ordereddict==1.1 -docutils>=0.11 \ No newline at end of file +docutils>=0.11 diff --git a/rest_framework_swagger/tests.py b/rest_framework_swagger/tests.py index 875dfc55..7f7c5f2f 100644 --- a/rest_framework_swagger/tests.py +++ b/rest_framework_swagger/tests.py @@ -19,7 +19,11 @@ from django.test import TestCase from django.test.utils import override_settings from django.utils.decorators import classonlymethod -from django.utils.importlib import import_module +try: + from django.utils.module_loading import import_module +except ImportError: + from django.utils.importlib import import_module + from django.views.generic import View import django_filters From 82a5dd18379ea112a5df314bdc0488167de0d808 Mon Sep 17 00:00:00 2001 From: Marc Gibbons Date: Thu, 14 Jul 2016 12:21:56 -0400 Subject: [PATCH 02/11] Trim tox --- tox.ini | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tox.ini b/tox.ini index 941bb24a..6eeacb52 100644 --- a/tox.ini +++ b/tox.ini @@ -1,22 +1,15 @@ [tox] envlist = py27-flake8, - {py27,py33,py34}-django1.8-drf{2.3,2.4,3.0,3.1,3.2,3.3}, - # Django 1.9+ requires Python 2.7/3.4+ and django-rest-framework 3.3+. - {py27,py34}-django1.9-drf3.3, - {py35}-django{1.8,1.9}-drf3.3 + {py27,py34}-django{1.8,1.9}-drf{3.3,3.4}, [testenv] commands = ./runtests.py --stop deps = django1.8: Django>=1.8,<1.9 django1.9: Django>=1.9,<1.10 - drf2.3: djangorestframework>=2.3,<2.4 - drf2.4: djangorestframework>=2.4,<2.5 - drf3.0: djangorestframework>=3.0,<3.1 - drf3.1: djangorestframework>=3.1,<3.2 - drf3.2: djangorestframework>=3.2,<3.3 drf3.3: djangorestframework>=3.3,<3.4 + drf3.4: djangorestframework>=3.4 {py27,py33,py34}-django{1.8}-drf{2.3,2.4}: PyYAML==3.10 py27: functools32==3.2.3-2 docutils==0.11 @@ -25,7 +18,7 @@ deps = nose==1.3.0 Markdown==2.5.1 mock==1.0.1 - django-nose==1.4 + django-nose==1.4.4 coverage==3.6 django-filter==0.10.0 jsonschema==2.5 From a80b75f5fbb115ef9bbd20e956bf0da86f836a77 Mon Sep 17 00:00:00 2001 From: Marc Gibbons Date: Thu, 14 Jul 2016 12:58:30 -0400 Subject: [PATCH 03/11] Update test runners, compat for 1.8, 1.9 Fixes (#471) --- .travis.yml | 23 +--- requirements.txt | 6 +- rest_framework_swagger/tests.py | 187 -------------------------------- setup.cfg | 3 + tox.ini | 2 +- 5 files changed, 11 insertions(+), 210 deletions(-) diff --git a/.travis.yml b/.travis.yml index 25071bc1..77446196 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,31 +11,16 @@ sudo: false env: - TOX_ENV=py27-flake8 - - TOX_ENV=py27-django1.8-drf2.3 - - TOX_ENV=py27-django1.8-drf2.4 - - TOX_ENV=py27-django1.8-drf3.0 - - TOX_ENV=py27-django1.8-drf3.1 - - TOX_ENV=py27-django1.8-drf3.2 - TOX_ENV=py27-django1.8-drf3.3 + - TOX_ENV=py27-django1.8-drf3.4 - TOX_ENV=py27-django1.9-drf3.3 - - TOX_ENV=py33-django1.8-drf3.1 - - TOX_ENV=py33-django1.8-drf3.2 - - TOX_ENV=py33-django1.8-drf3.3 - - TOX_ENV=py34-django1.8-drf2.3 - - TOX_ENV=py34-django1.8-drf2.4 - - TOX_ENV=py34-django1.8-drf3.0 - - TOX_ENV=py34-django1.8-drf3.1 - - TOX_ENV=py34-django1.8-drf3.2 - - TOX_ENV=py34-django1.8-drf3.3 - - TOX_ENV=py34-django1.9-drf3.3 + - TOX_ENV=py27-django1.9-drf3.4 - TOX_ENV=py35-django1.8-drf3.3 + - TOX_ENV=py35-django1.8-drf3.4 - TOX_ENV=py35-django1.9-drf3.3 + - TOX_ENV=py35-django1.9-drf3.4 matrix: - allow_failures: - - env: TOX_ENV=py27-django1.9-drf3.3 - - env: TOX_ENV=py34-django1.9-drf3.3 - - env: TOX_ENV=py35-django1.9-drf3.3 fast_finish: true install: diff --git a/requirements.txt b/requirements.txt index ce099542..3a293610 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,11 +1,11 @@ -Django>=1.7.1 +Django>=1.8.13 Markdown==2.1.1 PyYAML==3.11 argh==0.23.2 argparse==1.2.1 coverage==3.6 -django-nose>=1.2 -djangorestframework>=2.3.8 +django-nose>=1.4.4 +djangorestframework>=3.3 django-filter==0.11.0 jsonschema==2.5 nose>=1.3.0 diff --git a/rest_framework_swagger/tests.py b/rest_framework_swagger/tests.py index 7f7c5f2f..d58bbe76 100644 --- a/rest_framework_swagger/tests.py +++ b/rest_framework_swagger/tests.py @@ -1,9 +1,6 @@ import datetime -import platform import functools -import os import copy -import os.path from mock import Mock, patch from distutils.version import StrictVersion try: @@ -2779,187 +2776,3 @@ def wrapped(*view_args, **view_kwargs): cls.as_view = classonlymethod(new_as_view) return cls return wrapper - - -if platform.python_version_tuple()[:2] != ('3', '2'): - class Swagger1_2Tests(TestCase): - """ - build some swagger endpoints, and run swagger's JSON schema on the results. - """ - def setUp(self): - from json import loads - self.schemas = {} - schema_dir = 'schemas/v1.2' - for schema_file in [x for x in os.listdir(schema_dir) - if x.endswith('.json')]: - with open(os.path.join(schema_dir, schema_file)) as f: - schema = loads(f.read()) - self.schemas[schema_file] = schema - - def get_validator(self, schema_name): - from jsonschema import Draft4Validator - validator = Draft4Validator(self.schemas[schema_name + '.json']) - - def http_handler(uri): - from django.utils.six.moves.urllib import parse - urp = parse.urlparse(uri) - paff = os.path.basename(urp.path) - return self.schemas[paff] - validator.resolver.handlers['http'] = http_handler - return validator - - def test1(self): - class MockApiView(APIView): - def get_serializer_class(self): - return KitchenSinkSerializer - - def get(self, request): - pass - self.url_patterns = patterns( - '', - url(r'^a-view/?$', MockApiView.as_view(), name='a test view'), - url(r'^swagger/', include('rest_framework_swagger.urls')), - ) - urls = import_module(settings.ROOT_URLCONF) - urls.urlpatterns = self.url_patterns - - validator = self.get_validator("resourceListing") - response = self.client.get("/swagger/api-docs/") - json = parse_json(response) - validator.validate(json) - validator = self.get_validator("apiDeclaration") - response = self.client.get("/swagger/api-docs/a-view") - json = parse_json(response) - self.assertIn("KitchenSinkSerializer", json['models']) - validator.validate(json) - - def test_yaml_parameters(self): - class MockApiView(APIView): - """ - --- - GET: - parameters: - - name: bob - type: string - enum: - - taco - - enchilada - - name: rob - type: string - defaultValue: 'lewis' - - name: i1 - type: integer - format: int32 - - name: i2 - type: integer - format: int64 - - name: idurp - type: integer - format: smokey - minimum: 1 - maximum: 100 - - name: mandy - type: string - allowMultiple: true - uniqueItems: true - - name: sandy - type: array - items: - type: integer - - name: candy - type: array - items: - type: integer - uniqueItems: true - """ - def get(self, request): - pass - self.url_patterns = patterns( - '', - url(r'^a-view/?$', MockApiView.as_view(), name='a test view'), - url(r'^swagger/', include('rest_framework_swagger.urls')), - ) - urls = import_module(settings.ROOT_URLCONF) - urls.urlpatterns = self.url_patterns - - validator = self.get_validator("resourceListing") - response = self.client.get("/swagger/api-docs/") - json = parse_json(response) - validator.validate(json) - validator = self.get_validator("apiDeclaration") - response = self.client.get("/swagger/api-docs/a-view") - json = parse_json(response) - validator.validate(json) - self.assertEqual('object', json['apis'][0]['operations'][0]['type']) - parameters = json['apis'][0]['operations'][0]['parameters'] - self.assertNotIn('format', parameters[0]) - self.assertNotIn('defaultValue', parameters[0]) - self.assertNotIn('format', parameters[1]) - self.assertEqual('lewis', parameters[1]['defaultValue']) - self.assertEqual('', parameters[1]['description']) - self.assertEqual('i1', parameters[2]['name']) - self.assertEqual('int32', parameters[2]['format']) - self.assertEqual('i2', parameters[3]['name']) - self.assertEqual('int64', parameters[3]['format']) - self.assertEqual('idurp', parameters[4]['name']) - self.assertEqual('int32', parameters[4]['format']) - self.assertEqual('sandy', parameters[6]['name']) - self.assertEqual('integer', parameters[6]['items']['type']) - self.assertEqual('int32', parameters[6]['items']['format']) - self.assertEqual('candy', parameters[7]['name']) - self.assertIn('uniqueItems', parameters[7]) - - def test_raw_array(self): - class MockApiView(APIView): - """ - --- - GET: - parameters: - - name: bob - type: array - items: - type: string - """ - def get(self, request): - pass - self.url_patterns = patterns( - '', - url(r'^a-view/?$', MockApiView.as_view(), name='a test view'), - url(r'^swagger/', include('rest_framework_swagger.urls')), - ) - urls = import_module(settings.ROOT_URLCONF) - urls.urlpatterns = self.url_patterns - - validator = self.get_validator("resourceListing") - response = self.client.get("/swagger/api-docs/") - json = parse_json(response) - validator.validate(json) - validator = self.get_validator("apiDeclaration") - response = self.client.get("/swagger/api-docs/a-view") - json = parse_json(response) - validator.validate(json) - - def test_old_parameters(self): - - class MockApiView(APIView): - def get(self, request): - """ - taco -- a place to my food - """ - pass - self.url_patterns = patterns( - '', - url(r'^a-view/?$', MockApiView.as_view(), name='a test view'), - url(r'^swagger/', include('rest_framework_swagger.urls')), - ) - urls = import_module(settings.ROOT_URLCONF) - urls.urlpatterns = self.url_patterns - - validator = self.get_validator("resourceListing") - response = self.client.get("/swagger/api-docs/") - json = parse_json(response) - validator.validate(json) - validator = self.get_validator("apiDeclaration") - response = self.client.get("/swagger/api-docs/a-view") - json = parse_json(response) - validator.validate(json) diff --git a/setup.cfg b/setup.cfg index 5e409001..82690218 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,2 +1,5 @@ [wheel] universal = 1 + +[flake8] +exclude = *.ropeproject diff --git a/tox.ini b/tox.ini index 6eeacb52..14635f24 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] envlist = py27-flake8, - {py27,py34}-django{1.8,1.9}-drf{3.3,3.4}, + {py27,py35}-django{1.8,1.9}-drf{3.3,3.4}, [testenv] commands = ./runtests.py --stop From 11dbe1208dd7a47a7f4367d2c376d9b8fe40d701 Mon Sep 17 00:00:00 2001 From: Marc Gibbons Date: Thu, 14 Jul 2016 13:13:39 -0400 Subject: [PATCH 04/11] Remove XSS vulnerability. --- .../rest_framework_swagger/swagger-ui.js | 170 +++++++++--------- 1 file changed, 85 insertions(+), 85 deletions(-) diff --git a/rest_framework_swagger/static/rest_framework_swagger/swagger-ui.js b/rest_framework_swagger/static/rest_framework_swagger/swagger-ui.js index 7da10354..464772a1 100755 --- a/rest_framework_swagger/static/rest_framework_swagger/swagger-ui.js +++ b/rest_framework_swagger/static/rest_framework_swagger/swagger-ui.js @@ -135,7 +135,7 @@ var Docs = { $('.resource ul.endpoints').slideDown(); return; } - + $('li#resource_' + resource).addClass('active'); var elem = $('li#resource_' + resource + ' ul.endpoints'); @@ -154,7 +154,7 @@ var Docs = { expandOperationsForResource: function(resource) { // Make sure the resource container is open.. Docs.expandEndpointListForResource(resource); - + if (resource == '') { $('.resource ul.endpoints li.operation div.content').slideDown(); return; @@ -193,7 +193,7 @@ 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}); @@ -202,7 +202,7 @@ function program1(depth0,data) { return buffer; } function program2(depth0,data) { - + var buffer = "", stack1; buffer += "\n \n"; } @@ -236,7 +236,7 @@ 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)) @@ -256,7 +256,7 @@ function program1(depth0,data) { return buffer; } function program2(depth0,data) { - + var buffer = "", stack1; buffer += "
api version: "; if (stack1 = helpers.apiVersion) { stack1 = stack1.call(depth0, {hash:{},data:data}); } @@ -318,7 +318,7 @@ 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

"; if (stack1 = helpers.notes) { stack1 = stack1.call(depth0, {hash:{},data:data}); } @@ -329,13 +329,13 @@ function program1(depth0,data) { } function program3(depth0,data) { - - + + 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}); @@ -344,7 +344,7 @@ function program5(depth0,data) { return buffer; } function program6(depth0,data) { - + var buffer = "", stack1, stack2; buffer += "\n
\n \n
\n "; } function program12(depth0,data) { - - + + return "\n

Response Class

\n

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

Parameters

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

Error Status Codes

\n \n \n \n \n \n \n \n \n \n \n
HTTP Status CodeReason
\n "; } function program18(depth0,data) { - - + + return "\n "; } function program20(depth0,data) { - - + + return "\n
\n "; } @@ -502,7 +502,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this; function program1(depth0,data) { - + var buffer = "", stack1; buffer += "\n "; stack1 = helpers['if'].call(depth0, depth0.isFile, {hash:{},inverse:self.program(4, program4, data),fn:self.program(2, program2, data),data:data}); @@ -511,7 +511,7 @@ function program1(depth0,data) { return buffer; } function program2(depth0,data) { - + var buffer = "", stack1; buffer += "\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}); @@ -677,7 +677,7 @@ function program13(depth0,data) { return buffer; } function program14(depth0,data) { - + var buffer = "", stack1; buffer += "\n \n"; } @@ -1061,8 +1061,8 @@ 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 " : "; } @@ -1128,7 +1128,7 @@ 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}); @@ -1137,7 +1137,7 @@ function program1(depth0,data) { return buffer; } function program2(depth0,data) { - + var buffer = "", stack1; buffer += "\n \n"; } @@ -1398,8 +1398,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {}; e.preventDefault(); } return this.trigger('update-swagger-ui', { - url: $('#input_baseUrl').val(), - apiKey: $('#input_apiKey').val() + url: $('#input_baseUrl').text(), + apiKey: $('#input_apiKey').text() }); }; From 40d5f79b7fc967e76b55c9d547b8dff1a845e622 Mon Sep 17 00:00:00 2001 From: Marc Gibbons Date: Fri, 15 Jul 2016 13:35:04 -0400 Subject: [PATCH 05/11] Bump version to 0.3.9. --- .gitignore | 1 + rest_framework_swagger/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b49d9f82..4a16ece7 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ tests/cigar_example/static supervisord.log tests/cigar_example/static_root/ dist +site/ diff --git a/rest_framework_swagger/__init__.py b/rest_framework_swagger/__init__.py index 42692b62..725f0434 100644 --- a/rest_framework_swagger/__init__.py +++ b/rest_framework_swagger/__init__.py @@ -1,4 +1,4 @@ -VERSION = '0.3.8' +VERSION = '0.3.9' DEFAULT_SWAGGER_SETTINGS = { 'exclude_url_names': [], From c8277704697f16b6e03d7e711fe48354822eb34e Mon Sep 17 00:00:00 2001 From: Marc Gibbons Date: Fri, 15 Jul 2016 13:38:10 -0400 Subject: [PATCH 06/11] Update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f0923a41..d4397b43 100644 --- a/README.md +++ b/README.md @@ -42,8 +42,8 @@ for more information, see the [documentation][docs]. ## Requirements * Python (2.7, 3.3, 3.4, 3.5) -* Django (1.8) -* Django REST framework (2.3.8+) +* Django (1.8+) +* Django REST framework (3.8+) * PyYAML (3.10+) ## Bugs & Contributions From 2a13b8c5182dfe87baf5c22c1417b4c243a289e9 Mon Sep 17 00:00:00 2001 From: Marc Gibbons Date: Sun, 17 Jul 2016 08:48:21 -0400 Subject: [PATCH 07/11] Update CHANGELOG --- CHANGELOG.md | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index afb39823..1b8cbda6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,45 @@ # Change Log -## [Unreleased](https://github.com/marcgibbons/django-rest-swagger/tree/HEAD) +## [0.3.9](https://github.com/marcgibbons/django-rest-swagger/tree/0.3.9) (2016-07-17) +[Full Changelog](https://github.com/marcgibbons/django-rest-swagger/compare/2.0.0...0.3.9) -[Full Changelog](https://github.com/marcgibbons/django-rest-swagger/compare/0.3.7...HEAD) +**Implemented enhancements:** + +- Add possibility of generating 'header' parameters [\#3](https://github.com/marcgibbons/django-rest-swagger/issues/3) +- Add generic filtering parameters [\#2](https://github.com/marcgibbons/django-rest-swagger/issues/2) +- Add permission classes as part of the implementation notes [\#1](https://github.com/marcgibbons/django-rest-swagger/issues/1) + +**Closed issues:** + +- ImportError: cannot import name 'OpenAPIRenderer' [\#478](https://github.com/marcgibbons/django-rest-swagger/issues/478) +- Swagger UI doesn't work in 2.0.0 [\#477](https://github.com/marcgibbons/django-rest-swagger/issues/477) +- Swagger 2.0 roadmap [\#443](https://github.com/marcgibbons/django-rest-swagger/issues/443) +- CSRF cookie fails on HttpOnly [\#432](https://github.com/marcgibbons/django-rest-swagger/issues/432) + +**Merged pull requests:** + +- Release 0.3.9 [\#481](https://github.com/marcgibbons/django-rest-swagger/pull/481) ([marcgibbons](https://github.com/marcgibbons)) + +## [2.0.0](https://github.com/marcgibbons/django-rest-swagger/tree/2.0.0) (2016-07-14) +[Full Changelog](https://github.com/marcgibbons/django-rest-swagger/compare/2.0.0a0...2.0.0) + +**Closed issues:** + +- DRS docs break with CSP that blocks inline scripts [\#434](https://github.com/marcgibbons/django-rest-swagger/issues/434) + +## [2.0.0a0](https://github.com/marcgibbons/django-rest-swagger/tree/2.0.0a0) (2016-07-14) +[Full Changelog](https://github.com/marcgibbons/django-rest-swagger/compare/0.3.8...2.0.0a0) + +**Closed issues:** + +- \#Not working on production deployed on aws. if debug is true works on localhost else fails on localhost as well. [\#464](https://github.com/marcgibbons/django-rest-swagger/issues/464) + +**Merged pull requests:** + +- Release: 2.0.0a0 [\#470](https://github.com/marcgibbons/django-rest-swagger/pull/470) ([marcgibbons](https://github.com/marcgibbons)) + +## [0.3.8](https://github.com/marcgibbons/django-rest-swagger/tree/0.3.8) (2016-06-27) +[Full Changelog](https://github.com/marcgibbons/django-rest-swagger/compare/0.3.7...0.3.8) **Closed issues:** From 87cc3a409bf7c9d4744715d28569430b26cfe626 Mon Sep 17 00:00:00 2001 From: Marc Gibbons Date: Tue, 19 Jul 2016 17:03:52 -0400 Subject: [PATCH 08/11] Update minified JS. --- .gitignore | 1 + .../static/rest_framework_swagger/swagger-ui.min.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 4a16ece7..7993b963 100644 --- a/.gitignore +++ b/.gitignore @@ -46,3 +46,4 @@ supervisord.log tests/cigar_example/static_root/ dist site/ +example_app/ diff --git a/rest_framework_swagger/static/rest_framework_swagger/swagger-ui.min.js b/rest_framework_swagger/static/rest_framework_swagger/swagger-ui.min.js index 853a9b90..f3b1dc49 100755 --- a/rest_framework_swagger/static/rest_framework_swagger/swagger-ui.min.js +++ b/rest_framework_swagger/static/rest_framework_swagger/swagger-ui.min.js @@ -1,2 +1,2 @@ -function clippyCopiedCallback(e){$("#api_key_copied").fadeIn().delay(1e3).fadeOut()}$(function(){$.fn.vAlign=function(){return this.each(function(e){var t=$(this).height(),n=$(this).parent().height(),r=(n-t)/2;$(this).css("margin-top",r)})},$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(e){var t=$(this).closest("form").innerWidth(),n=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10),r=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",t-n-r)})},$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent(),$("ul.downplayed li div.content p").vAlign(),$("form.sandbox").submit(function(){var e=!0;return $(this).find("input.required").each(function(){$(this).removeClass("error"),$(this).val()==""&&($(this).addClass("error"),$(this).wiggle(),e=!1)}),e})}),log=function(){log.history=log.history||[],log.history.push(arguments),this.console&&console.log(Array.prototype.slice.call(arguments))},Function.prototype.bind&&console&&typeof console.log=="object"&&["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var Docs={shebang:function(){var e=$.param.fragment().split("/");e.shift();switch(e.length){case 1:log("shebang resource:"+e[0]);var t="resource_"+e[0];Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1});break;case 2:log("shebang endpoint: "+e.join("_")),Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1});var n=e.join("_"),r=n+"_content";log("li_dom_id "+n),log("li_content_dom_id "+r),Docs.expandOperation($("#"+r)),$("#"+n).slideto({highlight:!1})}},toggleEndpointListForResource:function(e){var t=$("li#resource_"+Docs.escapeResourceName(e)+" ul.endpoints");t.is(":visible")?Docs.collapseEndpointListForResource(e):Docs.expandEndpointListForResource(e)},expandEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);if(e==""){$(".resource ul.endpoints").slideDown();return}$("li#resource_"+e).addClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideDown()},collapseEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);$("li#resource_"+e).removeClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideUp()},expandOperationsForResource:function(e){Docs.expandEndpointListForResource(e);if(e==""){$(".resource ul.endpoints li.operation div.content").slideDown();return}$("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(e){Docs.expandEndpointListForResource(e),$("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(e){return e.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(e){e.slideDown()},collapseOperation:function(e){e.slideUp()}};(function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.content_type=e(function(e,t,n,r,i){function f(e,t){var r="",i;r+="\n ",i=n.each.call(e,e.produces,{hash:{},inverse:a.noop,fn:a.program(2,l,t),data:t});if(i||i===0)r+=i;return r+="\n",r}function l(e,t){var n="",r;n+='\n \n ",n}function c(e,t){return'\n \n'}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),i=i||{};var s="",o,u="function",a=this;s+='\n\n",s})})(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.main=e(function(e,t,n,r,i){function l(e,t){var r="",i,s;r+='\n
'+a((i=(i=e.info,i==null||i===!1?i:i.title),typeof i===u?i.apply(e):i))+'
\n
',s=(i=(i=e.info,i==null||i===!1?i:i.description),typeof i===u?i.apply(e):i);if(s||s===0)r+=s;r+="
\n ",s=n["if"].call(e,(i=e.info,i==null||i===!1?i:i.termsOfServiceUrl),{hash:{},inverse:f.noop,fn:f.program(2,c,t),data:t});if(s||s===0)r+=s;r+="\n ",s=n["if"].call(e,(i=e.info,i==null||i===!1?i:i.contact),{hash:{},inverse:f.noop,fn:f.program(4,h,t),data:t});if(s||s===0)r+=s;r+="\n ",s=n["if"].call(e,(i=e.info,i==null||i===!1?i:i.license),{hash:{},inverse:f.noop,fn:f.program(6,p,t),data:t});if(s||s===0)r+=s;return r+="\n ",r}function c(e,t){var n="",r;return n+='',n}function h(e,t){var n="",r;return n+="',n}function p(e,t){var n="",r;return n+="",n}function d(e,t){var r="",i;return r+='\n , api version: ',(i=n.apiVersion)?i=i.call(e,{hash:{},data:t}):(i=e.apiVersion,i=typeof i===u?i.apply(e):i),r+=a(i)+"\n ",r}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),i=i||{};var s="",o,u="function",a=this.escapeExpression,f=this;s+="
\n ",o=n["if"].call(t,t.info,{hash:{},inverse:f.noop,fn:f.program(1,l,i),data:i});if(o||o===0)s+=o;s+="\n
\n
\n
    \n
\n\n
\n
\n
\n

[ base url: ",(o=n.basePath)?o=o.call(t,{hash:{},data:i}):(o=t.basePath,o=typeof o===u?o.apply(t):o),s+=a(o)+"\n ",o=n["if"].call(t,t.apiVersion,{hash:{},inverse:f.noop,fn:f.program(8,d,i),data:i});if(o||o===0)s+=o;return s+="]

\n
\n
\n",s})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.operation=e(function(e,t,n,r,i){function h(e,t){var r="",i;r+="\n

Implementation Notes

\n

",(i=n.notes)?i=i.call(e,{hash:{},data:t}):(i=e.notes,i=typeof i===a?i.apply(e):i);if(i||i===0)r+=i;return r+="

\n ",r}function p(e,t){return'\n
\n '}function d(e,t){var r="",i;r+='\n \n ",r}function v(e,t){var n="",r,i;n+="\n
"+f((r=e.scope,typeof r===a?r.apply(e):r))+"
\n ",n}function m(e,t){return"
"}function g(e,t){return'\n
\n \n
\n '}function y(e,t){return'\n

Response Class

\n

\n
\n
\n '}function b(e,t){return'\n

Parameters

\n \n \n \n \n \n \n \n \n \n \n \n\n \n
ParameterValueDescriptionParameter TypeData Type
\n '}function w(e,t){return"\n
\n

Error Status Codes

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

\n ",(o=n.name)?o=o.call(t,{hash:{},data:i}):(o=t.name,o=typeof o===a?o.apply(t):o),s+=f(o)+" ",u={hash:{},inverse:l.noop,fn:l.program(1,h,i),data:i},(o=n.description)?o=o.call(t,u):(o=t.description,o=typeof o===a?o.apply(t):o),n.description||(o=c.call(t,o,u));if(o||o===0)s+=o;(o=n.description)?o=o.call(t,{hash:{},data:i}):(o=t.description,o=typeof o===a?o.apply(t):o);if(o||o===0)s+=o;return s+="\n

\n \n
\n\n",s})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.response_content_type=e(function(e,t,n,r,i){function f(e,t){var r="",i;r+="\n ",i=n.each.call(e,e.produces,{hash:{},inverse:a.noop,fn:a.program(2,l,t),data:t});if(i||i===0)r+=i;return r+="\n",r}function l(e,t){var n="",r;n+='\n \n ",n}function c(e,t){return'\n \n'}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),i=i||{};var s="",o,u="function",a=this;s+='\n\n",s})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.signature=e(function(e,t,n,r,i){this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),i=i||{};var s="",o,u="function",a=this.escapeExpression;s+='
\n\n
\n\n
\n
\n ',(o=n.signature)?o=o.call(t,{hash:{},data:i}):(o=t.signature,o=typeof o===u?o.apply(t):o);if(o||o===0)s+=o;return s+='\n
\n\n
\n
',(o=n.sampleJSON)?o=o.call(t,{hash:{},data:i}):(o=t.sampleJSON,o=typeof o===u?o.apply(t):o),s+=a(o)+'
\n \n
\n
\n\n',s})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.status_code=e(function(e,t,n,r,i){this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),i=i||{};var s="",o,u="function",a=this.escapeExpression;s+="",(o=n.code)?o=o.call(t,{hash:{},data:i}):(o=t.code,o=typeof o===u?o.apply(t):o),s+=a(o)+"\n",(o=n.message)?o=o.call(t,{hash:{},data:i}):(o=t.message,o=typeof o===u?o.apply(t):o);if(o||o===0)s+=o;return s+="\n",s})}(),function(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S={}.hasOwnProperty,x=function(e,t){function r(){this.constructor=e}for(var n in t)S.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};l=function(e){function r(){return c=r.__super__.constructor.apply(this,arguments),c}return x(r,e),r.prototype.dom_id="swagger_ui",r.prototype.options=null,r.prototype.api=null,r.prototype.headerView=null,r.prototype.mainView=null,r.prototype.initialize=function(e){var n=this;return e==null&&(e={}),e.dom_id!=null&&(this.dom_id=e.dom_id,delete e.dom_id),$("#"+this.dom_id)==null&&$("body").append('
'),this.options=e,this.options.success=function(){return n.render()},this.options.progress=function(e){return n.showMessage(e)},this.options.failure=function(e){return n.onLoadFailure(e)},this.headerView=new t({el:$("#header")}),this.headerView.on("update-swagger-ui",function(e){return n.updateSwaggerUi(e)})},r.prototype.updateSwaggerUi=function(e){return this.options.url=e.url,this.load()},r.prototype.load=function(){var e,t;return(t=this.mainView)!=null&&t.clear(),e=this.options.url,e.indexOf("http")!==0&&(e=this.buildUrl(window.location.href.toString(),e)),this.options.url=e,this.headerView.update(e),this.api=new SwaggerApi(this.options),this.api.build(),this.api},r.prototype.render=function(){var e=this;this.showMessage("Finished Loading Resource Information. Rendering Swagger UI..."),this.mainView=(new n({model:this.api,el:$("#"+this.dom_id)})).render(),this.showMessage();switch(this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}return this.options.onComplete&&this.options.onComplete(this.api,this),setTimeout(function(){return Docs.shebang()},400)},r.prototype.buildUrl=function(e,t){var n,r;return log("base is "+e),t.indexOf("/")===0?(r=e.split("/"),e=r[0]+"//"+r[2],e+t):(n=e.length,e.indexOf("?")>-1&&(n=Math.min(n,e.indexOf("?"))),e.indexOf("#")>-1&&(n=Math.min(n,e.indexOf("#"))),e=e.substring(0,n),e.indexOf("/",e.length-1)!==-1?e+t:e+"/"+t)},r.prototype.showMessage=function(e){return e==null&&(e=""),$("#message-bar").removeClass("message-fail"),$("#message-bar").addClass("message-success"),$("#message-bar").html(e)},r.prototype.onLoadFailure=function(e){var t;return e==null&&(e=""),$("#message-bar").removeClass("message-success"),$("#message-bar").addClass("message-fail"),t=$("#message-bar").html(e),this.options.onFailure!=null&&this.options.onFailure(e),t},r}(Backbone.Router),window.SwaggerUi=l,t=function(e){function t(){return h=t.__super__.constructor.apply(this,arguments),h}return x(t,e),t.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" -},t.prototype.initialize=function(){},t.prototype.showPetStore=function(e){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})},t.prototype.showWordnikDev=function(e){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})},t.prototype.showCustomOnKeyup=function(e){if(e.keyCode===13)return this.showCustom()},t.prototype.showCustom=function(e){return e!=null&&e.preventDefault(),this.trigger("update-swagger-ui",{url:$("#input_baseUrl").val(),apiKey:$("#input_apiKey").val()})},t.prototype.update=function(e,t,n){n==null&&(n=!1),$("#input_baseUrl").val(e);if(n)return this.trigger("update-swagger-ui",{url:e})},t}(Backbone.View),n=function(e){function t(){return d=t.__super__.constructor.apply(this,arguments),d}return x(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e,t,n,r,i,s,o;$(this.el).html(Handlebars.templates.main(this.model)),r={},e=0,o=this.model.apisArray;for(i=0,s=o.length;ii&&(f=i-a),fs&&(l=s-n),l0&&(i[s.name]=s.value),s.type==="file"&&(r=!0);v=n.find("textarea");for(f=0,h=v.length;f0&&(i.body=s.value);m=n.find("select");for(l=0,p=m.length;l0&&(i[s.name]=u);return o.responseContentType=$("div select[name=responseContentType]",$(this.el)).val(),o.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val(),$(".response_throbber",$(this.el)).show(),r?this.handleFileUpload(i,n):this.model["do"](i,o,this.showCompleteStatus,this.showErrorStatus,this)}},t.prototype.success=function(e,t){return t.showCompleteStatus(e)},t.prototype.handleFileUpload=function(e,t){var n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w=this;log("it's a file upload"),m=t.serializeArray();for(a=0,h=m.length;a0&&(e[s.name]=s.value);n=new FormData,g=this.model.parameters;for(f=0,p=g.length;f"+this.invocationUrl+""),o={type:this.model.method,url:this.invocationUrl,headers:i,data:n,dataType:"json",contentType:!1,processData:!1,error:function(e,t,n){return w.showErrorStatus(w.wrap(e),w)},success:function(e){return w.showResponse(e,w)},complete:function(e){return w.showCompleteStatus(w.wrap(e),w)}},window.authorizations&&window.authorizations.apply(o),jQuery.ajax(o),!1},t.prototype.wrap=function(e){var t,n,r,i,s,o,u;r={},n=e.getAllResponseHeaders().split("\r");for(o=0,u=n.length;o0?n.join(","):null},t.prototype.hideResponse=function(e){return e!=null&&e.preventDefault(),$(".response",$(this.el)).slideUp(),$(".response_hider",$(this.el)).fadeOut()},t.prototype.showResponse=function(e){var t;return t=JSON.stringify(e,null," ").replace(/\n/g,"
"),$(".response_body",$(this.el)).html(escape(t))},t.prototype.showErrorStatus=function(e,t){return t.showStatus(e)},t.prototype.showCompleteStatus=function(e,t){return t.showStatus(e)},t.prototype.formatXml=function(e){var t,n,r,i,s,o,u,a,f,l,c,h,p;a=/(>)(<)(\/*)/g,l=/[ ]*(.*)[ ]+\n/g,t=/(<.+>)(.+\n)/g,e=e.replace(a,"$1\n$2$3").replace(l,"$1\n").replace(t,"$1\n$2"),u=0,n="",s=e.split("\n"),r=0,i="other",f={"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},c=function(e){var t,s,o,u,a,l,c;return l={single:Boolean(e.match(/<.+\/>/)),closing:Boolean(e.match(/<\/.+>/)),opening:Boolean(e.match(/<[^!?].*>/))},a=function(){var e;e=[];for(o in l)c=l[o],c&&e.push(o);return e}()[0],a=a===void 0?"other":a,t=i+"->"+a,i=a,u="",r+=f[t],u=function(){var e,t,n;n=[];for(s=e=0,t=r;0<=t?et;s=0<=t?++e:--e)n.push(" ");return n}().join(""),t==="opening->closing"?n=n.substr(0,n.length-1)+e+"\n":n+=u+e+"\n"};for(h=0,p=s.length;h").text(JSON.stringify(JSON.parse(n),null," ")),s=$('
').append(t)):r==="application/xml"||/\+xml$/.test(r)?(t=$("").text(this.formatXml(n)),s=$('
').append(t)):r==="text/html"?(t=$("").html(n),s=$('
').append(t)):/^image\//.test(r)?s=$("").attr("src",u):(t=$("").text(n),s=$('
').append(t)):(t=$("").text("no content"),s=$('
').append(t)),o=s,$(".request_url",$(this.el)).html("
"+u+"
"),$(".response_code",$(this.el)).html("
"+e.status+" "+e.statusText+"
"),$(".response_body",$(this.el)).html(o),$(".response_headers",$(this.el)).html("
"+JSON.stringify(e.headers,null,"  ").replace(/\n/g,"
")+"
"),$(".response",$(this.el)).slideDown(),$(".response_hider",$(this.el)).show(),$(".response_throbber",$(this.el)).hide(),hljs.highlightBlock($(".response_body",$(this.el))[0])},t.prototype.toggleOperationContent=function(){var e;return e=$("#"+Docs.escapeResourceName(this.model.parentId)+"_"+this.model.nickname+"_content"),e.is(":visible")?Docs.collapseOperation(e):Docs.expandOperation(e)},t}(Backbone.View),f=function(e){function t(){return g=t.__super__.constructor.apply(this,arguments),g}return x(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),this},t.prototype.template=function(){return Handlebars.templates.status_code},t}(Backbone.View),s=function(e){function t(){return y=t.__super__.constructor.apply(this,arguments),y}return x(t,e),t.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(e,t){return e.type.toLowerCase()==="array"||e.allowMultiple?t.fn(this):t.inverse(this)})},t.prototype.render=function(){var e,t,n,r,s,o,f,l;return l=this.model.type||this.model.dataType,this.model.paramType==="body"&&(this.model.isBody=!0),l.toLowerCase()==="file"&&(this.model.isFile=!0),f=this.template(),$(this.el).html(f(this.model)),s={sampleJSON:this.model.sampleJSON,isParam:!0,signature:this.model.signature},this.model.sampleJSON?(o=new a({model:s,tagName:"div"}),$(".model-signature",$(this.el)).append(o.render().el)):$(".model-signature",$(this.el)).html(this.model.signature),t=!1,this.model.isBody&&(t=!0),e={isParam:t},e.consumes=this.model.consumes,t?(n=new i({model:e}),$(".parameter-content-type",$(this.el)).append(n.render().el)):(r=new u({model:e}),$(".response-content-type",$(this.el)).append(r.render().el)),this},t.prototype.template=function(){return this.model.isList?Handlebars.templates.param_list:this.options.readOnly?this.model.required?Handlebars.templates.param_readonly_required:Handlebars.templates.param_readonly:this.model.required?Handlebars.templates.param_required:Handlebars.templates.param},t}(Backbone.View),a=function(e){function t(){return b=t.__super__.constructor.apply(this,arguments),b}return x(t,e),t.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"},t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),this.switchToDescription(),this.isParam=this.model.isParam,this.isParam&&$(".notice",$(this.el)).text("Click to set as parameter value"),this},t.prototype.template=function(){return Handlebars.templates.signature},t.prototype.switchToDescription=function(e){return e!=null&&e.preventDefault(),$(".snippet",$(this.el)).hide(),$(".description",$(this.el)).show(),$(".description-link",$(this.el)).addClass("selected"),$(".snippet-link",$(this.el)).removeClass("selected")},t.prototype.switchToSnippet=function(e){return e!=null&&e.preventDefault(),$(".description",$(this.el)).hide(),$(".snippet",$(this.el)).show(),$(".snippet-link",$(this.el)).addClass("selected"),$(".description-link",$(this.el)).removeClass("selected")},t.prototype.snippetToTextArea=function(e){var t;if(this.isParam){e!=null&&e.preventDefault(),t=$("textarea",$(this.el.parentNode.parentNode.parentNode));if($.trim(t.val())==="")return t.val(this.model.sampleJSON)}},t}(Backbone.View),e=function(e){function t(){return w=t.__super__.constructor.apply(this,arguments),w}return x(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=contentType]",$(this.el)).text("Response Content Type"),this},t.prototype.template=function(){return Handlebars.templates.content_type},t}(Backbone.View),u=function(e){function t(){return E=t.__super__.constructor.apply(this,arguments),E}return x(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=responseContentType]",$(this.el)).text("Response Content Type"),this},t.prototype.template=function(){return Handlebars.templates.response_content_type},t}(Backbone.View),i=function(e){function t(){return p=t.__super__.constructor.apply(this,arguments),p}return x(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:"),this},t.prototype.template=function(){return Handlebars.templates.parameter_content_type},t}(Backbone.View)}.call(this); \ No newline at end of file +function clippyCopiedCallback(e){$("#api_key_copied").fadeIn().delay(1e3).fadeOut()}$(function(){$.fn.vAlign=function(){return this.each(function(e){var t=$(this).height(),n=$(this).parent().height(),a=(n-t)/2;$(this).css("margin-top",a)})},$.fn.stretchFormtasticInputWidthToParent=function(){return this.each(function(e){var t=$(this).closest("form").innerWidth(),n=parseInt($(this).closest("form").css("padding-left"),10)+parseInt($(this).closest("form").css("padding-right"),10),a=parseInt($(this).css("padding-left"),10)+parseInt($(this).css("padding-right"),10);$(this).css("width",t-n-a)})},$("form.formtastic li.string input, form.formtastic textarea").stretchFormtasticInputWidthToParent(),$("ul.downplayed li div.content p").vAlign(),$("form.sandbox").submit(function(){var e=!0;return $(this).find("input.required").each(function(){$(this).removeClass("error"),""==$(this).val()&&($(this).addClass("error"),$(this).wiggle(),e=!1)}),e})}),log=function(){log.history=log.history||[],log.history.push(arguments),this.console&&console.log(Array.prototype.slice.call(arguments))},Function.prototype.bind&&console&&"object"==typeof console.log&&["log","info","warn","error","assert","dir","clear","profile","profileEnd"].forEach(function(e){console[e]=this.bind(console[e],console)},Function.prototype.call);var Docs={shebang:function(){var e=$.param.fragment().split("/");switch(e.shift(),e.length){case 1:log("shebang resource:"+e[0]);var t="resource_"+e[0];Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1});break;case 2:log("shebang endpoint: "+e.join("_")),Docs.expandEndpointListForResource(e[0]),$("#"+t).slideto({highlight:!1});var n=e.join("_"),a=n+"_content";log("li_dom_id "+n),log("li_content_dom_id "+a),Docs.expandOperation($("#"+a)),$("#"+n).slideto({highlight:!1})}},toggleEndpointListForResource:function(e){var t=$("li#resource_"+Docs.escapeResourceName(e)+" ul.endpoints");t.is(":visible")?Docs.collapseEndpointListForResource(e):Docs.expandEndpointListForResource(e)},expandEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);if(""==e)return void $(".resource ul.endpoints").slideDown();$("li#resource_"+e).addClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideDown()},collapseEndpointListForResource:function(e){var e=Docs.escapeResourceName(e);$("li#resource_"+e).removeClass("active");var t=$("li#resource_"+e+" ul.endpoints");t.slideUp()},expandOperationsForResource:function(e){return Docs.expandEndpointListForResource(e),""==e?void $(".resource ul.endpoints li.operation div.content").slideDown():void $("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.expandOperation($(this))})},collapseOperationsForResource:function(e){Docs.expandEndpointListForResource(e),$("li#resource_"+Docs.escapeResourceName(e)+" li.operation div.content").each(function(){Docs.collapseOperation($(this))})},escapeResourceName:function(e){return e.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g,"\\$&")},expandOperation:function(e){e.slideDown()},collapseOperation:function(e){e.slideUp()}};!function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.content_type=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n ",a=n.each.call(e,e.produces,{hash:{},inverse:d.noop,fn:d.program(2,s,t),data:t}),(a||0===a)&&(r+=a),r+="\n"}function s(e,t){var n,a="";return a+='\n\t\n\t"}function i(e,t){return'\n \n'}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var l,p="",c="function",d=this;return p+='\n\n"})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.main=e(function(e,t,n,a,r){function o(e,t){var a,r,o="";return o+='\n
'+h((a=e.info,a=null==a||a===!1?a:a.title,typeof a===u?a.apply(e):a))+'
\n
',a=e.info,a=null==a||a===!1?a:a.description,r=typeof a===u?a.apply(e):a,(r||0===r)&&(o+=r),o+="
\n ",r=n.if.call(e,(a=e.info,null==a||a===!1?a:a.termsOfServiceUrl),{hash:{},inverse:m.noop,fn:m.program(2,s,t),data:t}),(r||0===r)&&(o+=r),o+="\n ",r=n.if.call(e,(a=e.info,null==a||a===!1?a:a.contact),{hash:{},inverse:m.noop,fn:m.program(4,i,t),data:t}),(r||0===r)&&(o+=r),o+="\n ",r=n.if.call(e,(a=e.info,null==a||a===!1?a:a.license),{hash:{},inverse:m.noop,fn:m.program(6,l,t),data:t}),(r||0===r)&&(o+=r),o+="\n "}function s(e,t){var n,a="";return a+=''}function i(e,t){var n,a="";return a+="'}function l(e,t){var n,a="";return a+=""}function p(e,t){var a,r="";return r+='\n , api version: ',(a=n.apiVersion)?a=a.call(e,{hash:{},data:t}):(a=e.apiVersion,a=typeof a===u?a.apply(e):a),r+=h(a)+"\n "}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var c,d="",u="function",h=this.escapeExpression,m=this;return d+="
\n ",c=n.if.call(t,t.info,{hash:{},inverse:m.noop,fn:m.program(1,o,r),data:r}),(c||0===c)&&(d+=c),d+="\n
\n
\n
    \n
\n\n
\n
\n
\n

[ base url: ",(c=n.basePath)?c=c.call(t,{hash:{},data:r}):(c=t.basePath,c=typeof c===u?c.apply(t):c),d+=h(c)+"\n ",c=n.if.call(t,t.apiVersion,{hash:{},inverse:m.noop,fn:m.program(8,p,r),data:r}),(c||0===c)&&(d+=c),d+="]

\n
\n
\n"})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.operation=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n

Implementation Notes

\n

",(a=n.notes)?a=a.call(e,{hash:{},data:t}):(a=e.notes,a=typeof a===$?a.apply(e):a),(a||0===a)&&(r+=a),r+="

\n "}function s(e,t){return'\n
\n '}function i(e,t){var a,r="";return r+='\n \n "}function l(e,t){var n,a,r="";return r+="\n
"+b((n=e.scope,typeof n===$?n.apply(e):n))+"
\n "}function p(e,t){return"
"}function c(e,t){return'\n
\n \n
\n '}function d(e,t){return'\n

Response Class

\n

\n
\n
\n '}function u(e,t){return'\n

Parameters

\n \n \n \n \n \n \n \n \n \n \n \n\n \n
ParameterValueDescriptionParameter TypeData Type
\n '}function h(e,t){return"\n
\n

Error Status Codes

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

\n ",(s=n.name)?s=s.call(t,{hash:{},data:r}):(s=t.name,s=typeof s===p?s.apply(t):s),l+=c(s)+" ",i={hash:{},inverse:d.noop,fn:d.program(1,o,r),data:r},(s=n.description)?s=s.call(t,i):(s=t.description,s=typeof s===p?s.apply(t):s),n.description||(s=u.call(t,s,i)),(s||0===s)&&(l+=s),(s=n.description)?s=s.call(t,{hash:{},data:r}):(s=t.description,s=typeof s===p?s.apply(t):s),(s||0===s)&&(l+=s),l+="\n

\n \n
\n\n"})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.response_content_type=e(function(e,t,n,a,r){function o(e,t){var a,r="";return r+="\n ",a=n.each.call(e,e.produces,{hash:{},inverse:d.noop,fn:d.program(2,s,t),data:t}),(a||0===a)&&(r+=a),r+="\n"}function s(e,t){var n,a="";return a+='\n \n "}function i(e,t){return'\n \n'}this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var l,p="",c="function",d=this;return p+='\n\n"})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.signature=e(function(e,t,n,a,r){this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var o,s="",i="function",l=this.escapeExpression;return s+='
\n\n
\n\n
\n
\n ',(o=n.signature)?o=o.call(t,{hash:{},data:r}):(o=t.signature,o=typeof o===i?o.apply(t):o),(o||0===o)&&(s+=o),s+='\n
\n\n
\n
',(o=n.sampleJSON)?o=o.call(t,{hash:{},data:r}):(o=t.sampleJSON,o=typeof o===i?o.apply(t):o),s+=l(o)+'
\n \n
\n
\n\n'})}(),function(){var e=Handlebars.template,t=Handlebars.templates=Handlebars.templates||{};t.status_code=e(function(e,t,n,a,r){this.compilerInfo=[4,">= 1.0.0"],n=this.merge(n,e.helpers),r=r||{};var o,s="",i="function",l=this.escapeExpression;return s+="",(o=n.code)?o=o.call(t,{hash:{},data:r}):(o=t.code,o=typeof o===i?o.apply(t):o),s+=l(o)+"\n",(o=n.message)?o=o.call(t,{hash:{},data:r}):(o=t.message,o=typeof o===i?o.apply(t):o),(o||0===o)&&(s+=o),s+="\n"})}(),function(){var e,t,n,a,r,o,s,i,l,p,c,d,u,h,m,f,y,g,v,b,_,w,x={}.hasOwnProperty,k=function(e,t){function n(){this.constructor=e}for(var a in t)x.call(t,a)&&(e[a]=t[a]);return n.prototype=t.prototype,e.prototype=new n,e.__super__=t.prototype,e};c=function(e){function a(){return d=a.__super__.constructor.apply(this,arguments)}return k(a,e),a.prototype.dom_id="swagger_ui",a.prototype.options=null,a.prototype.api=null,a.prototype.headerView=null,a.prototype.mainView=null,a.prototype.initialize=function(e){var n=this;return null==e&&(e={}),null!=e.dom_id&&(this.dom_id=e.dom_id,delete e.dom_id),null==$("#"+this.dom_id)&&$("body").append('
'),this.options=e,this.options.success=function(){return n.render()},this.options.progress=function(e){return n.showMessage(e)},this.options.failure=function(e){return n.onLoadFailure(e)},this.headerView=new t({el:$("#header")}),this.headerView.on("update-swagger-ui",function(e){return n.updateSwaggerUi(e)})},a.prototype.updateSwaggerUi=function(e){return this.options.url=e.url,this.load()},a.prototype.load=function(){var e,t;return null!=(t=this.mainView)&&t.clear(),e=this.options.url,0!==e.indexOf("http")&&(e=this.buildUrl(window.location.href.toString(),e)),this.options.url=e,this.headerView.update(e),this.api=new SwaggerApi(this.options),this.api.build(),this.api},a.prototype.render=function(){switch(this.showMessage("Finished Loading Resource Information. Rendering Swagger UI..."),this.mainView=new n({model:this.api,el:$("#"+this.dom_id)}).render(),this.showMessage(),this.options.docExpansion){case"full":Docs.expandOperationsForResource("");break;case"list":Docs.collapseOperationsForResource("")}return this.options.onComplete&&this.options.onComplete(this.api,this),setTimeout(function(){return Docs.shebang()},400)},a.prototype.buildUrl=function(e,t){var n,a;return log("base is "+e),0===t.indexOf("/")?(a=e.split("/"),e=a[0]+"//"+a[2],e+t):(n=e.length,e.indexOf("?")>-1&&(n=Math.min(n,e.indexOf("?"))),e.indexOf("#")>-1&&(n=Math.min(n,e.indexOf("#"))),e=e.substring(0,n),e.indexOf("/",e.length-1)!==-1?e+t:e+"/"+t); +},a.prototype.showMessage=function(e){return null==e&&(e=""),$("#message-bar").removeClass("message-fail"),$("#message-bar").addClass("message-success"),$("#message-bar").html(e)},a.prototype.onLoadFailure=function(e){var t;return null==e&&(e=""),$("#message-bar").removeClass("message-success"),$("#message-bar").addClass("message-fail"),t=$("#message-bar").html(e),null!=this.options.onFailure&&this.options.onFailure(e),t},a}(Backbone.Router),window.SwaggerUi=c,t=function(e){function t(){return u=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.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"},t.prototype.initialize=function(){},t.prototype.showPetStore=function(e){return this.trigger("update-swagger-ui",{url:"http://petstore.swagger.wordnik.com/api/api-docs"})},t.prototype.showWordnikDev=function(e){return this.trigger("update-swagger-ui",{url:"http://api.wordnik.com/v4/resources.json"})},t.prototype.showCustomOnKeyup=function(e){if(13===e.keyCode)return this.showCustom()},t.prototype.showCustom=function(e){return null!=e&&e.preventDefault(),this.trigger("update-swagger-ui",{url:$("#input_baseUrl").text(),apiKey:$("#input_apiKey").text()})},t.prototype.update=function(e,t,n){if(null==n&&(n=!1),$("#input_baseUrl").val(e),n)return this.trigger("update-swagger-ui",{url:e})},t}(Backbone.View),n=function(e){function t(){return m=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e,t,n,a,r,o,s;for($(this.el).html(Handlebars.templates.main(this.model)),a={},e=0,s=this.model.apisArray,r=0,o=s.length;rr&&(p=r-l),po&&(c=o-n),c0&&(r[o.name]=o.value),"file"===o.type&&(a=!0);for(f=n.find("textarea"),p=0,u=f.length;p0&&(r.body=o.value);for(y=n.find("select"),c=0,h=y.length;c0&&(r[o.name]=i);return s.responseContentType=$("div select[name=responseContentType]",$(this.el)).val(),s.requestContentType=$("div select[name=parameterContentType]",$(this.el)).val(),$(".response_throbber",$(this.el)).show(),a?this.handleFileUpload(r,n):this.model.do(r,s,this.showCompleteStatus,this.showErrorStatus,this)}},t.prototype.success=function(e,t){return t.showCompleteStatus(e)},t.prototype.handleFileUpload=function(e,t){var n,a,r,o,s,i,l,p,c,d,u,h,m,f,y,g,v,b,_=this;for(log("it's a file upload"),y=t.serializeArray(),l=0,u=y.length;l0&&(e[o.name]=o.value);for(n=new FormData,g=this.model.parameters,p=0,h=g.length;p"+this.invocationUrl+"
"),s={type:this.model.method,url:this.invocationUrl,headers:r,data:n,dataType:"json",contentType:!1,processData:!1,error:function(e,t,n){return _.showErrorStatus(_.wrap(e),_)},success:function(e){return _.showResponse(e,_)},complete:function(e){return _.showCompleteStatus(_.wrap(e),_)}},window.authorizations&&window.authorizations.apply(s),jQuery.ajax(s),!1},t.prototype.wrap=function(e){var t,n,a,r,o,s,i;for(a={},n=e.getAllResponseHeaders().split("\r"),s=0,i=n.length;s0?n.join(","):null}return e.value},t.prototype.hideResponse=function(e){return null!=e&&e.preventDefault(),$(".response",$(this.el)).slideUp(),$(".response_hider",$(this.el)).fadeOut()},t.prototype.showResponse=function(e){var t;return t=JSON.stringify(e,null,"\t").replace(/\n/g,"
"),$(".response_body",$(this.el)).html(escape(t))},t.prototype.showErrorStatus=function(e,t){return t.showStatus(e)},t.prototype.showCompleteStatus=function(e,t){return t.showStatus(e)},t.prototype.formatXml=function(e){var t,n,a,r,o,s,i,l,p,c,d,u,h;for(l=/(>)(<)(\/*)/g,c=/[ ]*(.*)[ ]+\n/g,t=/(<.+>)(.+\n)/g,e=e.replace(l,"$1\n$2$3").replace(c,"$1\n").replace(t,"$1\n$2"),i=0,n="",o=e.split("\n"),a=0,r="other",p={"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},d=function(e){var t,o,s,i,l,c,d;return c={single:Boolean(e.match(/<.+\/>/)),closing:Boolean(e.match(/<\/.+>/)),opening:Boolean(e.match(/<[^!?].*>/))},l=function(){var e;e=[];for(s in c)d=c[s],d&&e.push(s);return e}()[0],l=void 0===l?"other":l,t=r+"->"+l,r=l,i="",a+=p[t],i=function(){var e,t,n;for(n=[],o=e=0,t=a;0<=t?et;o=0<=t?++e:--e)n.push(" ");return n}().join(""),"opening->closing"===t?n=n.substr(0,n.length-1)+e+"\n":n+=i+e+"\n"},u=0,h=o.length;u").text(JSON.stringify(JSON.parse(n),null," ")),o=$('
').append(t)):"application/xml"===a||/\+xml$/.test(a)?(t=$("").text(this.formatXml(n)),o=$('
').append(t)):"text/html"===a?(t=$("").html(n),o=$('
').append(t)):/^image\//.test(a)?o=$("").attr("src",i):(t=$("").text(n),o=$('
').append(t)):(t=$("").text("no content"),o=$('
').append(t)),s=o,$(".request_url",$(this.el)).html("
"+i+"
"),$(".response_code",$(this.el)).html("
"+e.status+" "+e.statusText+"
"),$(".response_body",$(this.el)).html(s),$(".response_headers",$(this.el)).html("
"+JSON.stringify(e.headers,null,"  ").replace(/\n/g,"
")+"
"),$(".response",$(this.el)).slideDown(),$(".response_hider",$(this.el)).show(),$(".response_throbber",$(this.el)).hide(),hljs.highlightBlock($(".response_body",$(this.el))[0])},t.prototype.toggleOperationContent=function(){var e;return e=$("#"+Docs.escapeResourceName(this.model.parentId)+"_"+this.model.nickname+"_content"),e.is(":visible")?Docs.collapseOperation(e):Docs.expandOperation(e)},t}(Backbone.View),p=function(e){function t(){return g=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),this},t.prototype.template=function(){return Handlebars.templates.status_code},t}(Backbone.View),o=function(e){function t(){return v=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){return Handlebars.registerHelper("isArray",function(e,t){return"array"===e.type.toLowerCase()||e.allowMultiple?t.fn(this):t.inverse(this)})},t.prototype.render=function(){var e,t,n,a,o,s,p,c;return c=this.model.type||this.model.dataType,"body"===this.model.paramType&&(this.model.isBody=!0),"file"===c.toLowerCase()&&(this.model.isFile=!0),p=this.template(),$(this.el).html(p(this.model)),o={sampleJSON:this.model.sampleJSON,isParam:!0,signature:this.model.signature},this.model.sampleJSON?(s=new l({model:o,tagName:"div"}),$(".model-signature",$(this.el)).append(s.render().el)):$(".model-signature",$(this.el)).html(this.model.signature),t=!1,this.model.isBody&&(t=!0),e={isParam:t},e.consumes=this.model.consumes,t?(n=new r({model:e}),$(".parameter-content-type",$(this.el)).append(n.render().el)):(a=new i({model:e}),$(".response-content-type",$(this.el)).append(a.render().el)),this},t.prototype.template=function(){return this.model.isList?Handlebars.templates.param_list:this.options.readOnly?this.model.required?Handlebars.templates.param_readonly_required:Handlebars.templates.param_readonly:this.model.required?Handlebars.templates.param_required:Handlebars.templates.param},t}(Backbone.View),l=function(e){function t(){return b=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.events={"click a.description-link":"switchToDescription","click a.snippet-link":"switchToSnippet","mousedown .snippet":"snippetToTextArea"},t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),this.switchToDescription(),this.isParam=this.model.isParam,this.isParam&&$(".notice",$(this.el)).text("Click to set as parameter value"),this},t.prototype.template=function(){return Handlebars.templates.signature},t.prototype.switchToDescription=function(e){return null!=e&&e.preventDefault(),$(".snippet",$(this.el)).hide(),$(".description",$(this.el)).show(),$(".description-link",$(this.el)).addClass("selected"),$(".snippet-link",$(this.el)).removeClass("selected")},t.prototype.switchToSnippet=function(e){return null!=e&&e.preventDefault(),$(".description",$(this.el)).hide(),$(".snippet",$(this.el)).show(),$(".snippet-link",$(this.el)).addClass("selected"),$(".description-link",$(this.el)).removeClass("selected")},t.prototype.snippetToTextArea=function(e){var t;if(this.isParam&&(null!=e&&e.preventDefault(),t=$("textarea",$(this.el.parentNode.parentNode.parentNode)),""===$.trim(t.val())))return t.val(this.model.sampleJSON)},t}(Backbone.View),e=function(e){function t(){return _=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=contentType]",$(this.el)).text("Response Content Type"),this},t.prototype.template=function(){return Handlebars.templates.content_type},t}(Backbone.View),i=function(e){function t(){return w=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=responseContentType]",$(this.el)).text("Response Content Type"),this},t.prototype.template=function(){return Handlebars.templates.response_content_type},t}(Backbone.View),r=function(e){function t(){return h=t.__super__.constructor.apply(this,arguments)}return k(t,e),t.prototype.initialize=function(){},t.prototype.render=function(){var e;return e=this.template(),$(this.el).html(e(this.model)),$("label[for=parameterContentType]",$(this.el)).text("Parameter content type:"),this},t.prototype.template=function(){return Handlebars.templates.parameter_content_type},t}(Backbone.View)}.call(this); From 49bb233be9cb8626cd85a3488627d4c42e2cb78e Mon Sep 17 00:00:00 2001 From: Marc Gibbons Date: Tue, 19 Jul 2016 21:23:24 -0400 Subject: [PATCH 09/11] Bump version --- rest_framework_swagger/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework_swagger/__init__.py b/rest_framework_swagger/__init__.py index 725f0434..813de1e6 100644 --- a/rest_framework_swagger/__init__.py +++ b/rest_framework_swagger/__init__.py @@ -1,4 +1,4 @@ -VERSION = '0.3.9' +VERSION = '0.3.10' DEFAULT_SWAGGER_SETTINGS = { 'exclude_url_names': [], From 3ff81b8a40818ba81a7e0a9098eece412b9de87b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donovan=20Sch=C3=B6nknecht?= Date: Wed, 12 Jul 2017 14:51:07 +0200 Subject: [PATCH 10/11] Don't use RequestContext in Django 1.11+ --- rest_framework_swagger/views.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/rest_framework_swagger/views.py b/rest_framework_swagger/views.py index 48cde540..515c5fd9 100644 --- a/rest_framework_swagger/views.py +++ b/rest_framework_swagger/views.py @@ -1,4 +1,5 @@ import json +from django import VERSION as DJANGO_VERSION from django.utils import six from django.conf import settings @@ -6,7 +7,8 @@ from django.utils.safestring import mark_safe from django.utils.encoding import smart_text from django.shortcuts import render_to_response -from django.template import RequestContext +if DJANGO_VERSION < (1, 11): + from django.template import RequestContext from django.core.exceptions import PermissionDenied from .compat import import_string @@ -80,8 +82,12 @@ def get(self, request, *args, **kwargs): json.dumps(getattr(settings, 'CSRF_COOKIE_NAME', 'csrftoken'))), } } - response = render_to_response( - template_name, RequestContext(request, data)) + if DJANGO_VERSION < (1, 11): + response = render_to_response( + template_name, RequestContext(request, data)) + else: + data['request'] = request # Not sure if we need to append request? + response = render_to_response(template_name, data) return response From cf97b8c84878fbf49569216860f53cb07a095cc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donovan=20Sch=C3=B6nknecht?= Date: Wed, 12 Jul 2017 15:08:30 +0200 Subject: [PATCH 11/11] Remove request comment --- rest_framework_swagger/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest_framework_swagger/views.py b/rest_framework_swagger/views.py index 515c5fd9..ee47e7f4 100644 --- a/rest_framework_swagger/views.py +++ b/rest_framework_swagger/views.py @@ -86,7 +86,7 @@ def get(self, request, *args, **kwargs): response = render_to_response( template_name, RequestContext(request, data)) else: - data['request'] = request # Not sure if we need to append request? + data['request'] = request response = render_to_response(template_name, data) return response