Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions openlibrary/fastapi/search.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

import json
from typing import Annotated, Any
from typing import Annotated, Any, Literal

from fastapi import APIRouter, Depends, Query, Request
from fastapi.responses import JSONResponse
Expand Down Expand Up @@ -50,8 +50,8 @@ class PublicQueryOptions(BaseModel):
person: str | None = None
time: str | None = None
# from workscheme facet_fields
has_fulltext: bool | None = None
public_scan_b: bool | None = None
has_fulltext: Literal['true', 'false'] | None = None
public_scan_b: Literal['true', 'false'] | None = None

"""
The day will come when someone asks, why do we have Field wrapping Query
Expand Down
6 changes: 3 additions & 3 deletions openlibrary/tests/fastapi/test_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ def test_pagination_validation_errors(self, client, mock_work_search, params):
[
# Case 1: publisher should pass as a string
({'publisher': 'Lab of Thought'}, 'publisher', 'Lab of Thought'),
# Case 2: has_fulltext should pass as a boolean
({'has_fulltext': 'true'}, 'has_fulltext', True),
({'has_fulltext': 'false'}, 'has_fulltext', False),
# Case 2: has_fulltext should pass as a string
({'has_fulltext': 'true'}, 'has_fulltext', 'true'),
({'has_fulltext': 'false'}, 'has_fulltext', 'false'),
],
)
def test_search_parameter_types(
Expand Down
Loading