Skip to content

move all search endpoints to fastapi#11634

Merged
cdrini merged 20 commits intomasterfrom
fastapi-more-search-endpoints
Jan 7, 2026
Merged

move all search endpoints to fastapi#11634
cdrini merged 20 commits intomasterfrom
fastapi-more-search-endpoints

Conversation

@RayBB
Copy link
Collaborator

@RayBB RayBB commented Dec 28, 2025

This PR moves all the search endpoints to fastapi.

Note: most of the test code here will be deleted quickly once this stuff is running on production. It's AI generated but gives me a bit more confidence that there aren't any major discrepancies in how we call things. The small ones are noted in the tests. Mostly differences around when to pass none due to the unified Pagination model.

Technical

Testing

Screenshot

Stakeholders

Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niiiice, great work! The APIs look so much tighter in their own file like this, too!

A few bugs while testing:

Tested

from pydantic import BaseModel, Field, model_validator


class Pagination(BaseModel):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niiiice! Love seeing this dried up!

@cdrini cdrini added the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Jan 2, 2026
@RayBB RayBB force-pushed the fastapi-more-search-endpoints branch from c0139c0 to f89a200 Compare January 3, 2026 04:03
@github-actions github-actions bot removed the Needs: Submitter Input Waiting on input from the creator of the issue/pr [managed] label Jan 3, 2026
@RayBB RayBB force-pushed the fastapi-more-search-endpoints branch from f89a200 to 829e60f Compare January 3, 2026 04:06
@RayBB RayBB requested a review from cdrini January 3, 2026 07:30
@RayBB
Copy link
Collaborator Author

RayBB commented Jan 3, 2026

@cdrini all the issues mentioned above should be resolved now!

Copy link
Collaborator

@cdrini cdrini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! All the tests now pass! 🥳

Comment on lines +216 to +218
page=pagination.page,
offset=pagination.offset,
limit=pagination.limit,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to update these to take the pagination model directly.

Comment on lines +341 to +344
class AuthorSearchRequestParams(Pagination):
q: str = Field("", description="The search query")
fields: str = Field("*", description="Fields to return")
sort: AuthorSortOption = Field("", description="Sort order") # type: ignore[valid-type]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Debating on whether we can inline this class object ; having these be params is a bit easier to read and list indirection. Ray said that having Depends() twice with query params is "broken" in fastapi (causes some sort of conflict between fastapi + pydantic).

@cdrini cdrini merged commit 13a715a into master Jan 7, 2026
8 checks passed
@cdrini cdrini deleted the fastapi-more-search-endpoints branch January 7, 2026 18:11
mystic-06 pushed a commit to mystic-06/openlibrary that referenced this pull request Jan 11, 2026
* feat: Add FastAPI subject search endpoint and deprecate old implementation.

* feat: migrate author search to a new FastAPI endpoint and deprecate the legacy implementation.

* feat: Add FastAPI endpoint for list search and deprecate old list search JSON implementation.

* feat: Extract Pagination model to a shared module and integrate it into search endpoints.

* refactor: Consolidate individual search endpoints to search.py

* feat: Add tests for `/search/inside.json` endpoint parameter handling and a mock for its fulltext search dependency.

* feat: Add contract test comparing parameter passing for FastAPI and webpy `search/inside` endpoints, including a new mock for the synchronous search function.

* feat: Add API contract test for `/search/subjects` endpoint and introduce Solr query mocks.

* feat: add `/search/lists` endpoint to the web.py test app and a new contract test for it.

* feat: Add contract test for `/search/authors` endpoint.

* refactor: restrict 'api' query parameter to literal values 'next' or empty string

* feat: Introduce direct offset parameter for fulltext search and its FastAPI integration.

* fix: default search results start to 0 if offset is falsy

* fix pagination issue for list search

* feat: Add `ListSortOption` type with validation and schema for search sort parameter.

* feat: Refactor sort option validation into a Pydantic type factory and update the author search endpoint to use a new Pydantic request model.

* refactor: Simplify list search offset calculation by passing page to Solr and using Solr's start value.

* feat: Pass page parameter in subject and author search API calls.

* fix: Provide a default 'start' value in search response if the key is missing.

* Remove commented-out ValueError exception handler.
lokesh pushed a commit to lokesh/openlibrary that referenced this pull request Feb 4, 2026
* feat: Add FastAPI subject search endpoint and deprecate old implementation.

* feat: migrate author search to a new FastAPI endpoint and deprecate the legacy implementation.

* feat: Add FastAPI endpoint for list search and deprecate old list search JSON implementation.

* feat: Extract Pagination model to a shared module and integrate it into search endpoints.

* refactor: Consolidate individual search endpoints to search.py

* feat: Add tests for `/search/inside.json` endpoint parameter handling and a mock for its fulltext search dependency.

* feat: Add contract test comparing parameter passing for FastAPI and webpy `search/inside` endpoints, including a new mock for the synchronous search function.

* feat: Add API contract test for `/search/subjects` endpoint and introduce Solr query mocks.

* feat: add `/search/lists` endpoint to the web.py test app and a new contract test for it.

* feat: Add contract test for `/search/authors` endpoint.

* refactor: restrict 'api' query parameter to literal values 'next' or empty string

* feat: Introduce direct offset parameter for fulltext search and its FastAPI integration.

* fix: default search results start to 0 if offset is falsy

* fix pagination issue for list search

* feat: Add `ListSortOption` type with validation and schema for search sort parameter.

* feat: Refactor sort option validation into a Pydantic type factory and update the author search endpoint to use a new Pydantic request model.

* refactor: Simplify list search offset calculation by passing page to Solr and using Solr's start value.

* feat: Pass page parameter in subject and author search API calls.

* fix: Provide a default 'start' value in search response if the key is missing.

* Remove commented-out ValueError exception handler.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants