Skip to content

Commit 8b4fef3

Browse files
committed
Added tests, fixed _serialize_response, added CHANGELOG.md
1 parent 8754de9 commit 8b4fef3

File tree

10 files changed

+619
-11
lines changed

10 files changed

+619
-11
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
source = fastopenapi
33
omit =
44
*/site-packages/*
5-
branch = True
5+
branch = False
66

77
[report]
88
show_missing = True

CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Changelog
2+
3+
All notable changes to FastOpenAPI are documented in this file.
4+
5+
FastOpenAPI follows the [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format.
6+
7+
## [0.2.1] - 2025-03-12
8+
9+
### Fixed
10+
- Fixed an issue in `_serialize_response` where `BaseModel` was converted to a dictionary incorrectly.
11+
- Resolved a bug causing `DataLoader` to crash when processing empty datasets.
12+
- Added tests.
13+
- Added `CHANGELOG.md`
14+
15+
## [0.2.0] - 2025-03-11
16+
17+
### Added
18+
- Implemented `resolve_endpoint_params` in `BaseRouter`.
19+
- Added the `prefix` parameter to the `include_router` method.
20+
- Implemented `status_code` support for responses.
21+
22+
### Changed
23+
- Refactored all routers.
24+
25+
### Removed
26+
- Removed the `register_routes` method from `Starlette`.
27+
28+
## [0.1.0] - 2025-03-01
29+
30+
### Added
31+
- Initial release of the library.
32+
- Implemented core modules: `base`, `falcon`, `flask`, `sanic`, `starlette`.
33+
- Added basic documentation and tests.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<p align="center">
2-
<img src="logo.png" alt="Logo">
2+
<img src="https://raw.githubusercontent.com/mr-fatalyst/fastopenapi/master/logo.png" alt="Logo">
33
</p>
44

55
<p align="center">

fastopenapi/base_router.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,14 @@ def _register_docs_endpoints(self):
249249

250250
@staticmethod
251251
def _serialize_response(result: Any) -> Any:
252+
from pydantic import BaseModel
253+
252254
if isinstance(result, BaseModel):
253255
return result.model_dump()
254256
if isinstance(result, list):
255257
return [BaseRouter._serialize_response(item) for item in result]
258+
if isinstance(result, dict):
259+
return {k: BaseRouter._serialize_response(v) for k, v in result.items()}
256260
return result
257261

258262
@staticmethod

tests/conftest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Any
2+
13
from pydantic import BaseModel
24

35

@@ -24,3 +26,11 @@ def use_default_param(x: int = 42):
2426

2527
def raise_value_error():
2628
raise ValueError("Something went wrong")
29+
30+
31+
def echo_both(x: int, item: Item):
32+
return {"x": x, "item": item}
33+
34+
35+
def echo(x: Any):
36+
return x

0 commit comments

Comments
 (0)