def get_api_schema(request): """ Returns a hash of all API endpoints and their descriptions. Returns:: { '/example/url/here': { 'name': endpoint name, 'description': endpoint description }... } .. todo:: Format docstrings better. """ endpoints = get_api_endpoints() resp = {} for url, fn in endpoints.items(): desc = format_api_docstring(fn.func_doc) endpoint_details = {'name': fn.func_name, 'description': desc} resp[url] = endpoint_details return JsonResponse(resp)
def test_get_api_endpoints_utils(self): """ Test of function that traverses all URLs looking for api endpoints. """ res = get_api_endpoints() for url, fn in res.items(): self.assertTrue(fn.is_api_endpoint) self.assertTrue(url.startswith('/')) # these urls are generated by the DRF router and with /? if not url.startswith(( '/api/v2/projects', '/api/v2/property_views', '/api/v2/property_states', '/api/v2/properties', '/api/v2/labels', '/api/v2/green_assessment', '/api/v2/green_assessment_url', '/api/v2/cycles', '/api/v2/green_assessment_property', '/api/v2/gbr_properties', '/api/v2\.1/properties', )): self.assertTrue( url.endswith('/'), "Endpoint %s does not end with / as expected" % url)
def get_api_schema(request): """ Returns a hash of all API endpoints and their descriptions. Returns:: { '/example/url/here': { 'name': endpoint name, 'description': endpoint description }... } .. todo:: Should this require authentication? Should it return only endpoints the user has authorization for? .. todo:: Format docstrings better. """ endpoints = get_api_endpoints() resp = {} for url, fn in endpoints.items(): desc = format_api_docstring(fn.func_doc) endpoint_details = {'name': fn.func_name, 'description': desc} resp[url] = endpoint_details return JsonResponse(resp)
def get_api_schema(request): """ Returns a hash of all API endpoints and their descriptions. Returns:: {'/example/url/here': { 'name': endpoint name, 'description': endpoint description }... } TODO: Should this require authentication? Should it limit the return to endpoints the user has authorization for? TODO: Format docstrings better. """ endpoints = get_api_endpoints() resp = {} for url, fn in endpoints.items(): desc = format_api_docstring(fn.func_doc) endpoint_details = {'name': fn.func_name, 'description': desc} resp[url] = endpoint_details return resp
def test_get_api_endpoints_utils(self): """ Test of function that traverses all URLs looking for api endpoints. """ res = get_api_endpoints() for url, fn in res.items(): self.assertTrue(fn.is_api_endpoint) self.assertTrue(url.startswith('/'))
def test_get_api_endpoints_utils(self): """ Test of function that traverses all urls looking for api endpoints. """ res = get_api_endpoints() for url, fn in res.items(): self.assertTrue(fn.is_api_endpoint) self.assertTrue(url.startswith('/')) self.assertTrue(url.endswith('/'))
def test_get_api_endpoints_utils(self): """ Test of function that traverses all URLs looking for api endpoints. """ res = get_api_endpoints() for url, fn in res.items(): self.assertTrue(fn.is_api_endpoint) self.assertTrue(url.startswith("/")) self.assertTrue(url.endswith("/"), "Endpoint %s doesn't end with / as expected" % url)
def test_get_api_endpoints_utils(self): """ Test of function that traverses all urls looking for api endpoints. """ res = get_api_endpoints() for url, fn in res.items(): self.assertTrue(fn.is_api_endpoint) self.assertTrue(url.startswith('/')) self.assertTrue(url.endswith('/'), "Endpoint %s doesn't end with / as expected" % url)
def test_get_api_endpoints_utils(self): """ Test of function that traverses all URLs looking for api endpoints. """ res = get_api_endpoints() for url, fn in res.items(): self.assertTrue(fn.is_api_endpoint) self.assertTrue(url.startswith('/')) # these urls are generated by the DRF router and with /? if not (url.startswith('/api/v2/projects') or url.startswith('/api/v2/cycles') or url.startswith('/api/v2/labels')): self.assertTrue( url.endswith('/'), "Endpoint %s doesn't end with / as expected" % url )
# How to display URL addresses: 'footnote', 'no', or 'inline'. #epub_show_urls = 'inline' # If false, no index is generated. #epub_use_index = True # # formatters for API auto documentation import django django.setup() from seed.utils.api import get_api_endpoints api_endpoints = get_api_endpoints() endpoints_by_function = {fn.func_name: url for url, fn in api_endpoints.items()} def skip_non_api_methods(app, what, name, obj, skip, options): """ Callback function for sphinx, to skip functions in modules linked from api.rst that don't have is_api_endpoint set. """ if app.env.docname != 'api': # only apply this to api.rst return skip # if is_api_endpoint is True, don't skip (i.e. return False) is_api_endpoint = getattr(obj, 'is_api_endpoint', False) if is_api_endpoint: return False # don't skip api endpoints
# Documents to append as an appendix to all manuals. #texinfo_appendices = [] # If false, no module index is generated. #texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. #texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. #texinfo_no_detailmenu = False # formatters for API autodocumentation from seed.utils.api import get_api_endpoints api_endpoints = get_api_endpoints() endpoints_by_function = {fn.func_name: url for url, fn in api_endpoints.items()} def skip_non_api_methods(app, what, name, obj, skip, options): """ Callback function for sphinx, to skip functions in modules linked from api.rst that don't have is_api_endpoint set. """ if app.env.docname != 'api': # only apply this to api.rst return skip # if is_api_endpoint is True, don't skip (i.e. return False) is_api_endpoint = getattr(obj, 'is_api_endpoint', False) if is_api_endpoint: