Loading...
Loading...
Compare original and translation side by side
rules/rules/| Category | Rules | Impact | When to Use |
|---|---|---|---|
| API Framework | 3 | HIGH | REST conventions, resource modeling, OpenAPI specifications |
| Versioning | 3 | HIGH | URL path versioning, header versioning, deprecation/sunset policies |
| Error Handling | 3 | HIGH | RFC 9457 Problem Details, validation errors, error type registries |
| GraphQL | 2 | HIGH | Strawberry code-first, DataLoader, permissions, subscriptions |
| gRPC | 2 | HIGH | Protobuf services, streaming, interceptors, retry |
| Streaming | 2 | HIGH | SSE endpoints, WebSocket bidirectional, async generators |
| Rule | File | Key Pattern |
|---|---|---|
| REST Conventions | | Plural nouns, HTTP methods, status codes, pagination |
| Resource Modeling | | Hierarchical URLs, filtering, sorting, field selection |
| OpenAPI | | OpenAPI 3.1 specs, documentation, schema definitions |
| 规则 | 文件 | 核心模式 |
|---|---|---|
| REST规范 | | 复数名词、HTTP方法、状态码、分页 |
| 资源建模 | | 层级URL、过滤、排序、字段选择 |
| OpenAPI | | OpenAPI 3.1规范、文档、Schema定义 |
| Rule | File | Key Pattern |
|---|---|---|
| URL Path | | |
| Header | | |
| Deprecation | | Sunset headers, lifecycle management, breaking change policy |
| 规则 | 文件 | 核心模式 |
|---|---|---|
| URL路径版本 | | |
| 请求头版本 | | |
| 废弃策略 | | Sunset请求头、生命周期管理、破坏性变更政策 |
| Rule | File | Key Pattern |
|---|---|---|
| Problem Details | | RFC 9457 schema, |
| Validation | | Field-level errors, Pydantic integration, 422 responses |
| Error Catalog | | Problem type registry, error type URIs, client handling |
| 规则 | 文件 | 核心模式 |
|---|---|---|
| Problem Details | | RFC 9457 Schema、 |
| 校验错误 | | 字段级错误、Pydantic集成、422响应 |
| 错误目录 | | Problem类型注册表、错误类型URI、客户端处理 |
| Rule | File | Key Pattern |
|---|---|---|
| Schema Design | | Type-safe schema, DataLoader, union errors, Private fields |
| Patterns & Auth | | Permission classes, FastAPI integration, subscriptions |
| 规则 | 文件 | 核心模式 |
|---|---|---|
| Schema设计 | | 类型安全Schema、DataLoader、联合错误、私有字段 |
| 模式与认证 | | 权限类、FastAPI集成、订阅功能 |
| Rule | File | Key Pattern |
|---|---|---|
| Service Definition | | Protobuf, async server, client timeout, code generation |
| Streaming & Interceptors | | Server/bidirectional streaming, auth, retry backoff |
| 规则 | 文件 | 核心模式 |
|---|---|---|
| 服务定义 | | Protobuf、异步服务器、客户端超时、代码生成 |
| 流处理与拦截器 | | 服务端/双向流、认证、重试退避 |
| Rule | File | Key Pattern |
|---|---|---|
| SSE | | SSE endpoints, LLM streaming, reconnection, keepalive |
| WebSocket | | Bidirectional, heartbeat, aclosing(), backpressure |
| 规则 | 文件 | 核心模式 |
|---|---|---|
| SSE | | SSE端点、LLM流处理、重连、保活机制 |
| WebSocket | | 双向通信、心跳、aclosing()、背压处理 |
undefinedundefinedundefinedundefined| Decision | Recommendation |
|---|---|
| Versioning strategy | URL path ( |
| Resource naming | Plural nouns, kebab-case |
| Pagination | Cursor-based for large datasets |
| Error format | RFC 9457 Problem Details with |
| Error type URI | Your API domain + |
| Support window | Current + 1 previous version |
| Deprecation notice | 3 months minimum before sunset |
| Sunset period | 6 months after deprecation |
| GraphQL schema | Code-first with Strawberry types |
| N+1 prevention | DataLoader for all nested resolvers |
| GraphQL auth | Permission classes (context-based) |
| gRPC proto | One service per file, shared common.proto |
| gRPC streaming | Server stream for lists, bidirectional for real-time |
| SSE keepalive | Every 30 seconds |
| WebSocket heartbeat | ping-pong every 30 seconds |
| Async generator cleanup | aclosing() for all external resources |
| 决策项 | 推荐方案 |
|---|---|
| 版本控制策略 | 面向公开API使用URL路径前缀( |
| 资源命名 | 复数名词、短横线分隔(kebab-case) |
| 分页方案 | 针对大数据集使用基于游标(Cursor-based)的分页 |
| 错误格式 | 采用RFC 9457 Problem Details,使用 |
| 错误类型URI | 你的API域名 + |
| 版本支持窗口 | 当前版本 + 前一个版本 |
| 废弃通知周期 | 下线前至少3个月通知 |
| 下线过渡期 | 废弃后保留6个月 |
| GraphQL Schema | 使用Strawberry类型的代码优先方案 |
| N+1问题预防 | 所有嵌套解析器使用DataLoader |
| GraphQL认证 | 基于上下文的权限类 |
| gRPC Protobuf | 每个服务对应一个文件,共享common.proto |
| gRPC流处理 | 列表数据使用服务端流,实时场景使用双向流 |
| SSE保活 | 每30秒发送一次 |
| WebSocket心跳 | 每30秒发送一次ping-pong |
| 异步生成器清理 | 对所有外部资源使用aclosing() |
POST /createUserPOST /usersContent-Type: application/problem+jsonPOST /createUserPOST /usersContent-Type: application/problem+jsontest-cases.jsontest-cases.jsonfastapi-advancedrate-limitingobservability-monitoringinput-validationstreaming-api-patternsfastapi-advancedrate-limitingobservability-monitoringinput-validationstreaming-api-patterns