Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Serve resources from API routes ending in / (#926)
## Description of changes #895 Serve registered API routes regardless of whether they end in "/". In the linked bug @HammadB and I discussed looping over all the routes at the end of `__init__`, but the typechecker complains: the only thing we know about `self._app.routes` is that they're instances of `BaseRoute`, which may not have the fields we need. Rather than do type coercion I subclassed `fastapi.APIRouter`. The logic to set `kwargs["include_in_schema"]` is maybe too clever, should we just do an if-else instead? ## Test plan ``` 0 ~ beggers % curl http://localhost:8000/api/v1/collections/ -v * Trying 127.0.0.1:8000... * Connected to localhost (127.0.0.1) port 8000 (#0) > GET /api/v1/collections/ HTTP/1.1 > Host: localhost:8000 > User-Agent: curl/8.1.2 > Accept: */* > < HTTP/1.1 200 OK < date: Thu, 03 Aug 2023 19:14:01 GMT < server: uvicorn < content-length: 2 < content-type: application/json < * Connection #0 to host localhost left intact []% 0 ~ beggers % curl http://localhost:8000/api/v1/collections -v * Trying 127.0.0.1:8000... * Connected to localhost (127.0.0.1) port 8000 (#0) > GET /api/v1/collections HTTP/1.1 > Host: localhost:8000 > User-Agent: curl/8.1.2 > Accept: */* > < HTTP/1.1 200 OK < date: Thu, 03 Aug 2023 19:14:02 GMT < server: uvicorn < content-length: 2 < content-type: application/json < * Connection #0 to host localhost left intact []% ``` Also, `pytest` locally and CI. I'd like to confirm this doesn't break JS client generation and doc generation -- how can I do that? ## Documentation Changes *Are all docstrings for user-facing APIs updated if required? Do we need to make documentation changes in the [docs repository](https://github.com/chroma-core/docs)?* No documentation changes needed for this.
- Loading branch information