microsoft/skills

fastapi-router-py

把一个资源的接口、鉴权依赖和返回模型接入现有 FastAPI

  • SKILL.md 已保存
  • 中文用法已整理
  • 安装与运行未实测
先判断是否解决你的问题

fastapi-router-py 是什么?

fastapi-router-py 按资源名生成 FastAPI CRUD 路由,组织鉴权依赖、Pydantic 输入/响应、404 与创建/删除状态码,并接到现有 service 层。随附模板依赖项目已有 app.auth、User 模型与资源 Service,不能直接复制到任意 Python 文件就运行。

中文说明由本站依据来源整理;英文原文保留在页面下方。

按客户端选择安装入口

怎么接入你的 Agent?

  1. 定位完整 Skill 目录

    打开本项目来源,核对 SKILL.md 及其引用的脚本和资料。

  2. 交给你正在用的 Agent

    在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。

  3. 确认识别,再做具体任务

    让 Agent 回报安装目录和识别到的名称 fastapi-router-py,然后按本页使用示例提供材料。

展开并复制给 Codex 的安装指令
发送给 Codex

安装并检查 fastapi-router-py

请在 Codex 的当前工作环境中安装并检查 fastapi-router-py 这个 Skill。

项目身份:microsoft/skills / fastapi-router-py
来源:https://github.com/microsoft/skills/blob/f03ec5392f7a0f3aca12af47477e92f1edf7b44c/.github/plugins/azure-sdk-python/skills/fastapi-router-py/SKILL.md
已定位的源文件:.github/plugins/azure-sdk-python/skills/fastapi-router-py/SKILL.md

1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。
准备输入,再按步骤执行

装好以后,具体怎么用?

准备哪些材料

  • 提供现有 FastAPI 工程、资源字段、service 方法及鉴权函数;先回读 assets/template.py 并核对实际路径。来源示范目录为 src/backend/app/routers/,需适配工程真实结构。

会得到什么

  • 可对照现有模型与 service 的资源 router、挂载修改和需要补全的鉴权/业务实现。

实际使用顺序

  1. 以 Project/project/projects 这类一致命名替换模板占位符,核对 Create、Update 和 Response 模型及 service 的真实签名。
  2. 列表/单条读取按需求选择可选鉴权,写入使用 get_current_user_required;不存在资源返回404,创建返回201,删除返回204。实际授权规则必须落到代码,不把模板注释当实现。
  3. 在 main.py 挂载 router,按需补 service 与前端 API 调用。异步 I/O 才放 async def,阻塞调用不能直接塞入异步 handler;数据库池和长期客户端按 lifespan 管理并通过 Depends 注入。
使用示例

从一个具体任务开始

本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。

安装并识别 Skill 后发送

复制一个具体任务

教学任务:用 fastapi-router-py 为现有工程添加 Project 的 list/get/create/patch/delete 路由。字段与现有鉴权、ProjectService 以我提供的代码为准。先检查模板依赖,写操作要求登录;只允许资源所有者更新/删除的规则必须真实实现。请检查201/204/404和未登录、非所有者分支,并分别说明实际运行与未运行的验证。
预期结果

预期得到与真实工程衔接的路由和授权分支;本站未在 FastAPI 工程运行此示例。

使用前先看这些限制

使用条件与边界

  • 本次同时读取了 SKILL.md 和随附 router 模板。模板中的所有权检查有注释示例,删除处理没有完整所有权实现,不能声称复制模板就完成权限控制。
  • Skill 不提供真实数据库、User 模型或所有业务 service;这些需要工程自己实现。
针对这个 Skill 的疑问

常见问题

模板写了 ownership,就已经防止越权了吗?

没有。随附 PATCH 模板的 ownership 检查是可选注释,DELETE 也不能从注释推断有完整所有权校验。需要按业务规则实现并检查非所有者分支。

需要核对时再展开原文

来源原文与资料状态

源文件
已保存 SKILL.md,抓取于 2026-11-16T12:36:35.145Z
中文使用说明
已针对下方源文件版本整理用途、用法和常见问题
安装与任务测试
本站未执行安装或任务测试
来源复核
本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料

.github/plugins/azure-sdk-python/skills/fastapi-router-py/SKILL.md · 抓取时间 2026-11-16T12:36:35.145Z

以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。

抓取成功不代表已完成安装或任务测试。

来源 description(原文)

Create FastAPI routers with CRUD operations, authentication dependencies, and proper response models. Use when building REST API endpoints, creating new routes, implementing CRUD operations, or adding authenticated endpoints in FastAPI applications.

查看源文件章节 / Source sections
  • 原文:FastAPI Router
  • 快速开始 / Quick Start
  • 原文:Authentication Patterns
  • 原文:Response Models
  • 原文:HTTP Status Codes
  • 原文:Integration Steps
  • 原文:Best Practices
  • 原文:Reference Files
原文:FastAPI Router

Create FastAPI routers following established patterns with proper authentication, response models, and HTTP status codes.

快速开始 / Quick Start

Copy the template from [assets/template.py](assets/template.py) and replace placeholders: - `{{ResourceName}}` → PascalCase name (e.g., `Project`) - `{{resource_name}}` → snake_case name (e.g., `project`) - `{{resource_plural}}` → plural form (e.g., `projects`)

原文:Authentication Patterns

```python # Optional auth - returns None if not authenticated current_user: Optional[User] = Depends(get_current_user) # Required auth - raises 401 if not authenticated current_user: User = Depends(get_current_user_required) ```

原文:Response Models

```python @router.get("/items/{item_id}", response_model=Item) async def get_item(item_id: str) -> Item: ... @router.get("/items", response_model=list[Item]) async def list_items() -> list[Item]: ... ```

原文:HTTP Status Codes

```python @router.post("/items", status_code=status.HTTP_201_CREATED) async def create_item(item: ItemCreate) -> Item: ... @router.delete("/items/{id}", status_code=status.HTTP_204_NO_CONTENT) async def delete_item(id: str) -> None: ... ```

原文:Integration Steps

1. Create router in `src/backend/app/routers/` 2. Mount in `src/backend/app/main.py` 3. Create corresponding Pydantic models 4. Create service layer if needed 5. Add frontend API functions

文件 SHA256:a8c5911b2c67af768af99d0a1972e16c364ddd8194506d574ae90f375dca6bdf

仓库许可证记录:MIT;skill-declaration-captured-not-interpreted,查看来源。

SKILL.md原文description · 2026-11-16T12:36:35.145Z

Create FastAPI routers with CRUD operations, authentication dependencies, and proper response models. Use when building REST API endpoints, creating new routes, implementing CRUD operations, or adding authenticated endpoints in FastAPI applications.

查看历史简介来源

历史收录数据

来源仓库microsoft/skills
Skill源路径.github/plugins/azure-sdk-python/skills/fastapi-router-py/SKILL.md

安装前请让使用的Agent先读取这个SKILL.md及其所在目录,确认依赖和所需权限。此页不生成未经来源验证的安装命令。

返回 Skills 目录,按任务继续筛选 · MCP与Skills教程与资源