Bishwas-py / djapy

No bullshit, Django Rest API Framework
https://djapy.io
59 stars 3 forks source link

Optional[str] accepted not accepted as queriable type (accepted as body) #4

Closed Bishwas-py closed 5 months ago

Bishwas-py commented 5 months ago

search_title: Optional[str] is supposed to be an optional query type, not request body type, but djapy is make is request body type.

from datetime import datetime
from typing import Optional

from djapy import djapify, Schema

class TodoItemSchema(Schema):
    title: str
    description: str
    completed_at: Optional[datetime]
    created_at: Optional[datetime]
    updated_at: Optional[datetime]

@djapify
def get_todo_items(request, search_title: Optional[str]) -> {200: list[TodoItemSchema]}:
    from .models import TodoItem
    todo_items = TodoItem.objects.all()
    return todo_items
Bishwas-py commented 5 months ago

Issue has been fixed in new commits.

Bishwas-py commented 5 months ago

Testing using:

pip install git+https://github.com/Bishwas-py/djapy.git@main
or
pip install git+https://github.com/Bishwas-py/djapy.git@aa195e3202b324207eb5a8a244cc3a3e920be794
Bishwas-py commented 5 months ago

Has been fixed with new commit