BVB Source Codes

django-rest-framework Show documentation.py Source code

Return Download django-rest-framework: download documentation.py Source code - Download django-rest-framework Source code - Type:.py
  1. from django.conf.urls import include, url
  2.  
  3. from rest_framework.renderers import (
  4.     CoreJSONRenderer, DocumentationRenderer, SchemaJSRenderer
  5. )
  6. from rest_framework.schemas import SchemaGenerator, get_schema_view
  7.  
  8.  
  9. def get_docs_view(
  10.         title=None, description=None, schema_url=None, public=True,
  11.         patterns=None, generator_class=SchemaGenerator):
  12.     renderer_classes = [DocumentationRenderer, CoreJSONRenderer]
  13.  
  14.     return get_schema_view(
  15.         title=title,
  16.         url=schema_url,
  17.         description=description,
  18.         renderer_classes=renderer_classes,
  19.         public=public,
  20.         patterns=patterns,
  21.         generator_class=generator_class,
  22.     )
  23.  
  24.  
  25. def get_schemajs_view(
  26.         title=None, description=None, schema_url=None, public=True,
  27.         patterns=None, generator_class=SchemaGenerator):
  28.     renderer_classes = [SchemaJSRenderer]
  29.  
  30.     return get_schema_view(
  31.         title=title,
  32.         url=schema_url,
  33.         description=description,
  34.         renderer_classes=renderer_classes,
  35.         public=public,
  36.         patterns=patterns,
  37.         generator_class=generator_class,
  38.     )
  39.  
  40.  
  41. def include_docs_urls(
  42.         title=None, description=None, schema_url=None, public=True,
  43.         patterns=None, generator_class=SchemaGenerator):
  44.     docs_view = get_docs_view(
  45.         title=title,
  46.         description=description,
  47.         schema_url=schema_url,
  48.         public=public,
  49.         patterns=patterns,
  50.         generator_class=generator_class,
  51.     )
  52.     schema_js_view = get_schemajs_view(
  53.         title=title,
  54.         description=description,
  55.         schema_url=schema_url,
  56.         public=public,
  57.         patterns=patterns,
  58.         generator_class=generator_class,
  59.     )
  60.     urls = [
  61.         url(r'^$', docs_view, name='docs-index'),
  62.         url(r'^schema.js$', schema_js_view, name='schema-js')
  63.     ]
  64.     return include(urls, namespace='api-docs')
  65.  
downloaddocumentation.py Source code - Download django-rest-framework Source code
Related Source Codes/Software:
lectures - Oxford Deep NLP 2017 course 2017-06-10
algorithms - Minimal examples of data structures and algorithms... 2017-06-10
Awesome-Hacking - A collection of various awesome lists for hackers,... 2017-06-09
lottie-ios - An iOS library to natively render After Effects ve... 2017-06-09
Public-APIs - 2017-06-09
angular-starter - 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11

 Back to top