此代码生成器从一个 openapi 文件中创建 FastAPI 应用程序。
从 OpenAPI 文档生成 FastAPI 应用程序。
维护者更新: 积极迎接机遇。 koxudaxi.dev
文档网站是面向用户的文档的真实来源:
uv tool install fastapi-code-generatorpip install fastapi-code-generatorfastapi-codegen --input openapi.yaml --output app --output-model-type pydantic_v2.BaseModelfastapi-code-generator 使用 datamodel-code-generator 构建模型层。如需完整的端到端示例、自定义模板、自定义访问者和路由生成,请参阅 概述指南。
fastapi-codegen --input openapi.yaml --output app - 为更大的应用程序生成路由模块: fastapi-codegen --input openapi.yaml --output app --template-dir modular_template --generate-routers - 将路由重生限制在特定标签中: fastapi-codegen --input openapi.yaml --output app --template-dir modular_template --generate-routers --specify-tags "Wild Boars, Fat Cats" - 目标 Pydantic v2 输出: fastapi-codegen --input openapi.yaml --output app --output-model-type pydantic_v2.BaseModel暂无开放 Issues,或尚未同步最近议题。