Commit cb08973
authored
refactor: refactor FastAPI route setup and docs (#280)
# Description
## Summary
This PR improves the current implementation of `A2AFastAPIApplication`
class that enables serving A2A endpoints using a FastAPI application.
(#104)
### Implementation Details
Refactors the `add_routes_to_app` method in
`src/a2a/server/apps/jsonrpc/fastapi_app.py` to simplify route
definitions by:
* Directly associating handler methods with FastAPI route decorators
* Removing unnecessary nested async function definitions by directly
passing handler methods (`self._handle_requests`,
`self._handle_get_agent_card`, and
`self._handle_get_authenticated_extended_agent_card`) to the FastAPI
decorators (`app.post` and `app.get`)
* Enabling method descriptions to appear in Swagger documentation,
improving developer experience
These changes make the code more readable, maintainable, and better
integrated with FastAPI's documentation features.
### Screenshots
#### Before


#### After


---
Continues #104 🦕1 parent 1c8e12e commit cb08973
1 file changed
+6
-15
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 72 | + | |
| 73 | + | |
80 | 74 | | |
81 | 75 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
87 | | - | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
88 | 79 | | |
89 | 80 | | |
90 | 81 | | |
| |||
0 commit comments