Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api route have to use unique name #14

Open
boot-sandre opened this issue Oct 7, 2023 · 1 comment
Open

Api route have to use unique name #14

boot-sandre opened this issue Oct 7, 2023 · 1 comment
Assignees
Labels
good first issue Good for newcomers

Comments

@boot-sandre
Copy link
Owner

Django ninja use for route url reverse the name of the method/view or a provided named arg on view decorateur args.

@router.get(
    path="/fetch/{pk}/",
    response={
        200: RouterContract,
        422: FormInvalidResponseContract,
    },
)
def record_read(request: HttpRequest, pk: IntStrUUID4):

In this case the reverse url of format "api_name:view_name" will be "skii:record_read"

If we have many view with record_read view function name, it's will be impossible to determine which road needs to provide the url resolver.

We need to check all endpoints and use unique name for all of them.
For our example it's will be:

@router.get(
    path="/fetch/{pk}/",
    response={
        200: RouterContract,
        422: FormInvalidResponseContract,
    },
)
def lesson_read(request: HttpRequest, pk: IntStrUUID4):

With unique route name skii:lesson_read

@boot-sandre boot-sandre converted this from a draft issue Oct 7, 2023
@boot-sandre boot-sandre added this to the Skii Platform 0.0.5 milestone Oct 7, 2023
@boot-sandre boot-sandre added the good first issue Good for newcomers label Oct 7, 2023
@boot-sandre boot-sandre moved this from Todo to In Progress in @boot-sandre's Skii Platform Oct 20, 2023
@boot-sandre boot-sandre self-assigned this Oct 20, 2023
@boot-sandre
Copy link
Owner Author

boot-sandre commented Oct 20, 2023

This issue will also permit to not use anymore legacy testclient:

class SkiiClient(Client):
pass

And fully use:

class SkiiTestClient(Client):
"""Custom api client dedicated to skii api.
This test client is customized to fetch skii ninja api with:
- The content type is always json payload.
- The GET/POST/DELETE use django reverse url ("skii:v0-4-1:route_name").
- Filter/query arguments are documented as possible.
"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
Status: In Progress
Development

When branches are created from issues, their pull requests are automatically linked.

1 participant