mirror of
https://gitlab.com/megazordpobeda/DataRush.git
synced 2026-11-20 16:47:53 +00:00
add swagger docs to signin and signup endooints
This commit is contained in:
1 parent
5fece08457
commit
a066c9a8b5
9 files changed
+82
No files matched your search
Whitespace-only changes.
@@ -0,0 +1,20 @@
|
||||
from ninja import Schema, ModelSchema
|
||||
|
||||
|
||||
from apps.users.models import User
|
||||
|
||||
|
||||
class TokenSchema(Schema):
|
||||
token: str
|
||||
|
||||
|
||||
class RegisterSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ["email", "username", "password"]
|
||||
|
||||
|
||||
class LoginSchema(ModelSchema):
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ["email", "password"]
|
||||
@@ -0,0 +1,31 @@
|
||||
from ninja import Router
|
||||
|
||||
from api.v1.users.schemas import LoginSchema, RegisterSchema, TokenSchema
|
||||
from api.v1.schemas import BadRequestError, ForbiddenError
|
||||
from apps.users.models import User
|
||||
|
||||
|
||||
router = Router(tags=["users"])
|
||||
|
||||
|
||||
@router.post(
|
||||
path="/sign-up",
|
||||
response={
|
||||
201: TokenSchema,
|
||||
400: BadRequestError,
|
||||
}
|
||||
)
|
||||
def sign_up(data: RegisterSchema):
|
||||
...
|
||||
|
||||
|
||||
@router.post(
|
||||
path="/sign-in",
|
||||
response={
|
||||
200: TokenSchema,
|
||||
400: BadRequestError,
|
||||
403: ForbiddenError,
|
||||
}
|
||||
)
|
||||
def sign_in(data: LoginSchema):
|
||||
...
|
||||
Reference in new issue
Block a user