def test_it_formats_link_objects_as_dicts(self, templater): link = _service_link(name="flat") formatted = links.format_nested_links([link], "v1", templater) assert "flat" in formatted assert formatted["flat"] == { "method": link.primary_method(), "url": templater.route_template(link.route_name), "desc": link.description, }
def index_v2(context, request): """Return the API descriptor document. Clients may use this to discover endpoints for the API. """ api_links = request.registry.api_links["v2"] templater = AngularRouteTemplater( request.route_url, params=["id", "pubid", "user", "userid", "username"]) return {"links": link_helpers.format_nested_links(api_links, templater)}
def index_v2(context, request): """Return the API descriptor document. Clients may use this to discover endpoints for the API. """ api_links = request.registry.api_links["v2"] templater = AngularRouteTemplater( request.route_url, params=["id", "pubid", "user", "userid", "username"] ) return {"links": link_helpers.format_nested_links(api_links, templater)}
def index(context, request): """Return the API descriptor document. Clients may use this to discover endpoints for the API. """ api_links = request.registry.api_links["v1"] # We currently need to keep a list of the parameter names we use in our API # paths and pass these explicitly into the templater. As and when new # parameter names are added, we'll need to add them here, or this view will # break (and get caught by the `test_api_index` functional test). templater = AngularRouteTemplater( request.route_url, params=["id", "pubid", "user", "userid", "username"]) return {"links": link_helpers.format_nested_links(api_links, templater)}
def index(context, request): """Return the API descriptor document. Clients may use this to discover endpoints for the API. """ api_links = request.registry.api_links["v1"] # We currently need to keep a list of the parameter names we use in our API # paths and pass these explicitly into the templater. As and when new # parameter names are added, we'll need to add them here, or this view will # break (and get caught by the `test_api_index` functional test). templater = AngularRouteTemplater( request.route_url, params=["id", "pubid", "user", "userid", "username"] ) return {"links": link_helpers.format_nested_links(api_links, templater)}
def test_it_nests_links_based_on_service_name_split_on_periods( self, templater): api_links = [ _service_link(name="1"), _service_link(name="1.2"), _service_link(name="1.2.3"), _service_link(name="1.2.A"), _service_link(name="1.B"), ] formatted = links.format_nested_links([api_links], "v1", templater) assert "1" in formatted assert "2" in formatted["1"] assert "B" in formatted["1"] assert "3" in formatted["1"]["2"] assert "A" in formatted["1"]["2"]