[python-fastapi][REQ] Add `Fastapi Request` parameter to api methods
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 70/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- fastapi, openapi, python
调研方向
首先阅读 python-fastapi 生成器模板中的 api.mustache 和 base_api.mustache,并结合 issue 中链接的 FastAPI Request 文档。重新生成一个小的 FastAPI 示例,查看端点和 base 方法是如何输出的,然后向两个模板签名中都添加 Request 参数,并将其传递到实现中。当生成的端点接受并转发 Request,且生成器的 python-fastapi 示例/测试仍能构建时,即完成。
由索引模型根据 Issue 内容生成。
描述
Need Fastapi Request in the implementation of the api
As the Fastapi documentation says here it would be good to have access to the request object in the implementation of the api.
Modify api.moustache and base_api.moustache
Add the request to the method in the moustache files, e.g.
async def {{operationId}}(
request: Request,
{{#allParams}}
{{>endpoint_argument_definition}},
{{/allParams}}
{{#hasAuthMethods}}
{{#authMethods}}
token_{{name}}: TokenModel = Security(
get_token_{{name}}{{#isOAuth}}, scopes=[{{#scopes}}"{{scope}}"{{^-last}}, {{/-last}}{{/scopes}}]{{/isOAuth}}
),
{{/authMethods}}
{{/hasAuthMethods}}
) -> {{returnType}}{{^returnType}}None{{/returnType}}:
{{#notes}}"""{{.}}"""
{{/notes}}if not Base{{classname}}.subclasses:
raise HTTPException(status_code=500, detail="Not implemented")
return await Base{{classname}}.subclasses[0]().{{operationId}}(request, {{#allParams}}{{>impl_argument}}{{^-last}}, {{/-last}}{{/allParams}})
{{^-last}}
class Base{{classname}}:
subclasses: ClassVar[Tuple] = ()
def __init_subclass__(cls, **kwargs):
super().__init_subclass__(**kwargs)
Base{{classname}}.subclasses = Base{{classname}}.subclasses + (cls,)
{{#operations}}
{{#operation}}
async def {{operationId}}(
self,
request: Request,
{{#allParams}}
{{>impl_argument_definition}},
{{/allParams}}
) -> {{returnType}}{{^returnType}}None{{/returnType}}:
{{#notes}}"""{{.}}"""
...{{/notes}}{{^notes}}...{{/notes}}
- 主要语言
- Java
- 星标
- 26.9k
- 派生
- 7.8k
- 平均合并
- 2 天 23 分钟
- 30 天内合并 PR
- 177
环境准备
在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
OpenAPITools/openapi-generator 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
OpenAPITools/openapi-generator#25768 ·
维护者通常 1 天内回复
-
[BUG][RUBY-NEXTGEN] A non-String value in a pattern-constrained attribute raises NoMethodError可能已有人在做 @Inf1mum 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
OpenAPITools/openapi-generator#25724 · 1 条评论 ·
维护者通常 1 天内回复
-
[BUG][RUBY-NEXTGEN] Response#to_hash is advertised and raises when the data is an Array可能已有人在做 @Inf1mum 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 77/100
OpenAPITools/openapi-generator#25723 · 1 条评论 ·
维护者通常 1 天内回复
-
[BUG][RUBY-NEXTGEN] A JSON string response raises ApiError because the body is parsed twice可能已有人在做 @Inf1mum 于 2 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 77/100
OpenAPITools/openapi-generator#25719 · 1 条评论 ·
维护者通常 1 天内回复
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)可能已有人在做 @Inf1mum 于 11 天前认领。 未关闭Issue: Bug
难度 2/5 1-3 小时 新手友好度 82/100
OpenAPITools/openapi-generator#25567 ·
维护者通常 1 天内回复
查看 OpenAPITools/openapi-generator 的全部 Issue
相似的 Issue
-
good first issue kernel
难度 2/5 1-3 小时 新手友好度 76/100
JackFurton/who-would-build-a-kernel-in-java#316 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
GTNewHorizons/Angelica#2370 ·
维护者通常 1 天内回复
-
Long working directory path draws over the Console pane's buttons when the Console has no other tabs未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
proposal
难度 1/5 1 小时以内 新手友好度 82/100
beemdevelopment/Aegis#1861 ·
-
bug
难度 2/5 1-3 小时 新手友好度 78/100
foam-foundation/foam3#5917 ·
维护者通常 1 天内回复