def root_view(request: Request): gen = schemas.SchemaGenerator() gen.get_schema() root = gen.get_links(request) distribute_links(root) key, res = traverse(request, root, root_key='api') return Response(res)
def get_schema(self, request=None, public=False): """ Generate a `coreapi.Document` representing the API schema. """ if self.endpoints is None: inspector = self.endpoint_inspector_cls(self.patterns, self.urlconf) self.endpoints = inspector.get_api_endpoints() links = self.get_links(None if public else request) if not links: return None url = self.url if not url and request is not None: url = request.build_absolute_uri() distribute_links(links) return CustomCoreApiDocument( title=self.title, description=self.description, url=url, content=links, links=links, )
def get_schema(self, request=None, public=False): if self.endpoints is None: inspector = self.endpoint_inspector_cls(self.patterns, self.urlconf) self.endpoints = inspector.get_api_endpoints() links = self.get_links(None if public else request) if not links: return None url = self.url if not url and request is not None: url = request.build_absolute_uri() distribute_links(links) return OpenApiDocument( version=self.version, title=self.title, description=self.description, url=url, content=links )