diff --git a/licenses/bootstrap.md b/licenses/bootstrap.md new file mode 100644 index 000000000..17fb503e7 --- /dev/null +++ b/licenses/bootstrap.md @@ -0,0 +1,22 @@ +https://github.com/twbs/bootstrap/ + +The MIT License (MIT) + +Copyright (c) 2011-2016 Twitter, Inc. + +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 diff --git a/licenses/jquery.json-view.md b/licenses/jquery.json-view.md new file mode 100644 index 000000000..146db3aa9 --- /dev/null +++ b/licenses/jquery.json-view.md @@ -0,0 +1,22 @@ +https://github.com/bazh/jquery.json-view/ + +The MIT License (MIT) + +Copyright (c) 2014 bazh. (http://github.com/bazh) + +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. diff --git a/rest_framework/renderers.py b/rest_framework/renderers.py index ac0f49e5b..e456d1dac 100644 --- a/rest_framework/renderers.py +++ b/rest_framework/renderers.py @@ -801,7 +801,7 @@ class DocumentationRenderer(BaseRenderer): template = 'rest_framework/docs/index.html' code_style = 'emacs' - def get_context(self, data): + def get_context(self, data, request): from pygments.formatters import HtmlFormatter from django.utils.html import mark_safe formatter = HtmlFormatter(style=self.code_style) @@ -813,12 +813,13 @@ class DocumentationRenderer(BaseRenderer): 'document': data, 'langs': langs, 'code_style': code_style, - 'schema': schema + 'schema': schema, + 'request': request } def render(self, data, accepted_media_type=None, renderer_context=None): template = loader.get_template(self.template) - context = self.get_context(data) + context = self.get_context(data, renderer_context['request']) return template_render(template, context, request=renderer_context['request']) diff --git a/rest_framework/schemas.py b/rest_framework/schemas.py index 1b3df23af..844bcc5da 100644 --- a/rest_framework/schemas.py +++ b/rest_framework/schemas.py @@ -57,13 +57,13 @@ def field_to_schema(field): return coreschema.String(title=title, description=description) elif isinstance(field, serializers.MultipleChoiceField): return coreschema.Array( - items=coreschema.Enum(enum=list(field.choices.values())), + items=coreschema.Enum(enum=list(field.choices.keys())), title=title, description=description ) elif isinstance(field, serializers.ChoiceField): return coreschema.Enum( - enum=list(field.choices.values()), + enum=list(field.choices.keys()), title=title, description=description ) diff --git a/rest_framework/static/rest_framework/docs/css/base.css b/rest_framework/static/rest_framework/docs/css/base.css index c1acaadc7..aa9550287 100644 --- a/rest_framework/static/rest_framework/docs/css/base.css +++ b/rest_framework/static/rest_framework/docs/css/base.css @@ -30,30 +30,28 @@ margin-bottom: 0; } +.sidebar .brand a { + color: #FFF; +} + +.sidebar .brand a:hover, +.sidebar .brand a:active, +.sidebar .brand a:focus { + text-decoration: none; +} + .sidebar .toggle-btn { display: none; } .sidebar .menu-list ul, .sidebar .menu-list li { + background: #2e353d; list-style: none; padding: 0px; margin: 0px; line-height: 35px; cursor: pointer; - /* - .collapsed{ - .arrow:before{ - font-family: FontAwesome; - content: "\f053"; - display: inline-block; - padding-left:10px; - padding-right: 10px; - vertical-align: middle; - float:right; - } - } -*/ } .sidebar .menu-list ul :not(collapsed) .arrow:before, @@ -97,8 +95,14 @@ background-color: #020203; } -.sidebar .menu-list ul .sub-menu li:before, -.sidebar .menu-list li .sub-menu li:before { + +.sidebar .menu-list ul .sub-menu li a, +.sidebar .menu-list li .sub-menu li a { + display: block; +} + +.sidebar .menu-list ul .sub-menu li a:before, +.sidebar .menu-list li .sub-menu li a:before { font-family: FontAwesome; content: "\f105"; display: inline-block; @@ -273,8 +277,9 @@ body { } .api-modal .modal-body .request-awaiting { - text-align: center; padding: 35px 10px; + color: #7F8177; + text-align: center; } .api-modal .modal-body .meta { diff --git a/rest_framework/static/rest_framework/docs/css/jquery.json-view.min.css b/rest_framework/static/rest_framework/docs/css/jquery.json-view.min.css new file mode 100755 index 000000000..a07568136 --- /dev/null +++ b/rest_framework/static/rest_framework/docs/css/jquery.json-view.min.css @@ -0,0 +1,11 @@ +.json-view{position:relative} +.json-view .collapser{width:20px;height:18px;display:block;position:absolute;left:-1.7em;top:-.2em;z-index:5;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAD1JREFUeNpiYGBgOADE%2F3Hgw0DM4IRHgSsDFOzFInmMAQnY49ONzZRjDFiADT7dMLALiE8y4AGW6LoBAgwAuIkf%2F%2FB7O9sAAAAASUVORK5CYII%3D);background-repeat:no-repeat;background-position:center center;opacity:.5;cursor:pointer} +.json-view .collapsed{-ms-transform:rotate(-90deg);-moz-transform:rotate(-90deg);-khtml-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);-o-transform:rotate(-90deg);transform:rotate(-90deg)} +.json-view .bl{display:block;padding-left:20px;margin-left:-20px;position:relative} +.json-view{font-family:monospace} +.json-view ul{list-style-type:none;padding-left:2em;border-left:1px dotted;margin:.3em} +.json-view ul li{position:relative} +.json-view .comments,.json-view .dots{display:none;-moz-user-select:none;-ms-user-select:none;-khtml-user-select:none;-webkit-user-select:none;-o-user-select:none;user-select:none} +.json-view .comments{padding-left:.8em;font-style:italic;color:#888} +.json-view .bool,.json-view .null,.json-view .num,.json-view .undef{font-weight:700;color:#1A01CC} +.json-view .str{color:#800} \ No newline at end of file diff --git a/rest_framework/static/rest_framework/docs/img/favicon.ico b/rest_framework/static/rest_framework/docs/img/favicon.ico index e85006a3c..17b2c5d98 100644 Binary files a/rest_framework/static/rest_framework/docs/img/favicon.ico and b/rest_framework/static/rest_framework/docs/img/favicon.ico differ diff --git a/rest_framework/static/rest_framework/docs/js/jquery.json-view.min.js b/rest_framework/static/rest_framework/docs/js/jquery.json-view.min.js new file mode 100755 index 000000000..ce3a60435 --- /dev/null +++ b/rest_framework/static/rest_framework/docs/js/jquery.json-view.min.js @@ -0,0 +1,7 @@ +/** + * jquery.json-view - jQuery collapsible JSON plugin + * @version v1.0.0 + * @link http://github.com/bazh/jquery.json-view + * @license MIT + */ +!function(e){"use strict";var n=function(n){var a=e("",{"class":"collapser",on:{click:function(){var n=e(this);n.toggleClass("collapsed");var a=n.parent().children(".block"),p=a.children("ul");n.hasClass("collapsed")?(p.hide(),a.children(".dots, .comments").show()):(p.show(),a.children(".dots, .comments").hide())}}});return n&&a.addClass("collapsed"),a},a=function(a,p){var t=e.extend({},{nl2br:!0},p),r=function(e){return e.toString()?e.toString().replace(/&/g,"&").replace(/"/g,""").replace(//g,">"):""},s=function(n,a){return e("",{"class":a,html:r(n)})},l=function(a,p){switch(e.type(a)){case"object":p||(p=0);var c=e("",{"class":"block"}),d=Object.keys(a).length;if(!d)return c.append(s("{","b")).append(" ").append(s("}","b"));c.append(s("{","b"));var i=e("