"""Search router."""
from rest_framework.routers import DefaultRouter, Route


class SearchRouter(DefaultRouter):
    """Custom router for search endpoints.

    Search endpoints don't follow REST principles and thus don't need
    routes that default router provides.
    """

    routes = [
        Route(
            url=r"^{prefix}{trailing_slash}$",
            mapping={"get": "list", "post": "list_with_post"},
            name="{basename}",
            initkwargs={},
            detail=False,
        )
    ]

"""Search router."""
from rest_framework.routers import DefaultRouter, DynamicRoute, Route


class SearchRouter(DefaultRouter):
    """Custom router for search endpoints.

    Search endpoints don't follow REST principles and thus don't need
    routes that default router provides.
    """

    routes = [
        Route(
            url=r"^{prefix}{trailing_slash}$",
            mapping={"get": "list", "post": "list_with_post"},
            name="{basename}",
            initkwargs={},
            detail=False,
        ),
        # Dynamically generated list routes. Generated using
        # @action(detail=False) decorator on methods of the viewset.
        DynamicRoute(
            url=r'^{prefix}/{url_path}{trailing_slash}$',
            name='{basename}-{url_name}',
            detail=False,
            initkwargs={}
        ),
        Route(
            url=r'^{prefix}/{lookup}{trailing_slash}$',
            mapping={
                'get': 'retrieve',
                'put': 'update',
                'patch': 'partial_update',
                'delete': 'destroy'
            },
            name='{basename}-detail',
            detail=True,
            initkwargs={'suffix': 'Instance'}
        ),
        # Dynamically generated detail routes. Generated using
        # @action(detail=True) decorator on methods of the viewset.
        DynamicRoute(
            url=r'^{prefix}/{lookup}/{url_path}{trailing_slash}$',
            name='{basename}-{url_name}',
            detail=True,
            initkwargs={}
        ),
    ]

Support custom actions in search router
Support custom actions in search router

  """Search router."""
- from rest_framework.routers import DefaultRouter, Route
+ from rest_framework.routers import DefaultRouter, DynamicRoute, Route
  
  
  class SearchRouter(DefaultRouter):
      """Custom router for search endpoints.
  
      Search endpoints don't follow REST principles and thus don't need
      routes that default router provides.
      """
  
      routes = [
          Route(
              url=r"^{prefix}{trailing_slash}$",
              mapping={"get": "list", "post": "list_with_post"},
              name="{basename}",
              initkwargs={},
              detail=False,
-         )
+         ),
+         # Dynamically generated list routes. Generated using
+         # @action(detail=False) decorator on methods of the viewset.
+         DynamicRoute(
+             url=r'^{prefix}/{url_path}{trailing_slash}$',
+             name='{basename}-{url_name}',
+             detail=False,
+             initkwargs={}
+         ),
+         Route(
+             url=r'^{prefix}/{lookup}{trailing_slash}$',
+             mapping={
+                 'get': 'retrieve',
+                 'put': 'update',
+                 'patch': 'partial_update',
+                 'delete': 'destroy'
+             },
+             name='{basename}-detail',
+             detail=True,
+             initkwargs={'suffix': 'Instance'}
+         ),
+         # Dynamically generated detail routes. Generated using
+         # @action(detail=True) decorator on methods of the viewset.
+         DynamicRoute(
+             url=r'^{prefix}/{lookup}/{url_path}{trailing_slash}$',
+             name='{basename}-{url_name}',
+             detail=True,
+             initkwargs={}
+         ),
      ]
  
Support custom actions in search router
## Code Before:
"""Search router."""
from rest_framework.routers import DefaultRouter, Route


class SearchRouter(DefaultRouter):
    """Custom router for search endpoints.

    Search endpoints don't follow REST principles and thus don't need
    routes that default router provides.
    """

    routes = [
        Route(
            url=r"^{prefix}{trailing_slash}$",
            mapping={"get": "list", "post": "list_with_post"},
            name="{basename}",
            initkwargs={},
            detail=False,
        )
    ]

## Instruction:
Support custom actions in search router
## Code After:
"""Search router."""
from rest_framework.routers import DefaultRouter, DynamicRoute, Route


class SearchRouter(DefaultRouter):
    """Custom router for search endpoints.

    Search endpoints don't follow REST principles and thus don't need
    routes that default router provides.
    """

    routes = [
        Route(
            url=r"^{prefix}{trailing_slash}$",
            mapping={"get": "list", "post": "list_with_post"},
            name="{basename}",
            initkwargs={},
            detail=False,
        ),
        # Dynamically generated list routes. Generated using
        # @action(detail=False) decorator on methods of the viewset.
        DynamicRoute(
            url=r'^{prefix}/{url_path}{trailing_slash}$',
            name='{basename}-{url_name}',
            detail=False,
            initkwargs={}
        ),
        Route(
            url=r'^{prefix}/{lookup}{trailing_slash}$',
            mapping={
                'get': 'retrieve',
                'put': 'update',
                'patch': 'partial_update',
                'delete': 'destroy'
            },
            name='{basename}-detail',
            detail=True,
            initkwargs={'suffix': 'Instance'}
        ),
        # Dynamically generated detail routes. Generated using
        # @action(detail=True) decorator on methods of the viewset.
        DynamicRoute(
            url=r'^{prefix}/{lookup}/{url_path}{trailing_slash}$',
            name='{basename}-{url_name}',
            detail=True,
            initkwargs={}
        ),
    ]
