feat: fastapi integration added. - #137
Open
lbukr wants to merge 1 commit into
Open
Conversation
lbukr
commented
Jul 18, 2026
dapper91
reviewed
Jul 19, 2026
|
|
||
| jsonrpc_app = integration.Application('/api/v1') | ||
| jsonrpc_app.add_methods(methods) | ||
|
|
Owner
There was a problem hiding this comment.
I think it worth to define a fastapi app variable like:
app = jsonrpc_app.http_appto be able to start it with fastapi dev or fastapi run command.
Author
There was a problem hiding this comment.
A more useful example is
jsonrpc_app = integration.Application('/api/v1')
jsonrpc_app.add_methods(methods)
app = fastapi.FastAPI()
app.mount("/rpc", jsonrpc_app.http_app)The same example is described in openapi + fastapi docs
| if annotation is None: | ||
| return False | ||
|
|
||
| return inspect.isclass(annotation) and issubclass(annotation, fastapi.Request) |
Owner
There was a problem hiding this comment.
fastapi request is a generic type so inspect.isclass always returns False. We must check the origin of the type not the type itself:
def is_fastapi_request(idx: int, name: str, annotation: Optional[type[Any]], default: Optional[Any]) -> bool:
if annotation is None:
return False
annotation_origin = typing.get_origin(annotation)
return inspect.isclass(annotation_origin) and issubclass(annotation_origin, fastapi.Request)| """ | ||
| Creates a user. | ||
|
|
||
| :param request: http request |
Owner
There was a problem hiding this comment.
http request is not passed. Let's pass it with to make the example more fulfilling:
@methods.add(
pass_context=True,
metadata=[
openapi.metadata(
summary="Creates a user",
tags=['users'],
errors=[AlreadyExistsError],
),
],
)
def add_user(request: fastapi.Request[Mapping[str, Any]], user: UserIn) -> UserOut:
"""
Creates a user.
:param request: http request
:param object user: user data
:return object: registered user
:raise AlreadyExistsError: user already exists
"""
Owner
|
aiohttp 3.14 and aioresponses compatibility is broken pnuckowski/aioresponses#289 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implementation of fastapi server based