跳到正文
Skillpedia
API 与服务器(后端)40k · #7067

aspnet-minimal-api-openapi

它能做什么

这个工具可以帮你使用 ASP.NET 为网站或 Web 应用创建代码片段。它能确保收发的信息结构清晰,并让文档(类似说明手册)清楚、完整。

适用场景

  • ✓当你需要为网站开发新功能时。
  • ✓当你需要组织 Web 应用的多个部分时。
  • ✓当你想让代码文档始终保持最新时。

技能链接

https://github.com/github/awesome-copilot/blob/main/skills/aspnet-minimal-api-openapi/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/github/awesome-copilot/blob/main/skills/aspnet-minimal-api-openapi/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“创建一个端点,用于注册新用户,接收姓名和邮箱,并返回新建用户的 ID。”

每周 5 个新技能,1 分钟读完。

工作原理

你描述代码需要接收的信息以及应返回的内容。工具会整理这些内容,并自动生成文档,相当于为其他开发者提供的一张地图。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

ASP.NET Minimal API with OpenAPI

Your goal is to help me create well-structured ASP.NET Minimal API endpoints with correct types and comprehensive OpenAPI/Swagger documentation.

API Organization

  • Group related endpoints using MapGroup() extension
  • Use endpoint filters for cross-cutting concerns
  • Structure larger APIs with separate endpoint classes
  • Consider using a feature-based folder structure for complex APIs

Request and Response Types

  • Define explicit request and response DTOs/models
  • Create clear model classes with proper validation attributes
  • Use record types for immutable request/response objects
  • Use meaningful property names that align with API design standards
  • Apply [Required] and other validation attributes to enforce constraints
  • Use the ProblemDetailsService and StatusCodePages to get standard error responses

Type Handling

  • Use strongly-typed route parameters with explicit type binding
  • Use Results<T1, T2> to represent multiple response types
  • Return TypedResults instead of Results for strongly-typed responses
  • Leverage C# 10+ features like nullable annotations and init-only properties

OpenAPI Documentation

  • Use the built-in OpenAPI document support added in .NET 9
  • Define operation summary and description
  • Add operationIds using the WithName extension method
  • Add descriptions to properties and parameters with [Description()]
  • Set proper content types for requests and responses
  • Use document transformers to add elements like servers, tags, and security schemes
  • Use schema transformers to apply customizations to OpenAPI schemas
常见问题

什么是 'endpoints'?

'Endpoints' 就像应用的入口,用于收发特定的信息。

什么是 'OpenAPI/Swagger'?

这是一种标准方式,用于描述和记录 API(即上面提到的“入口”),让其他人能够理解如何使用它们。

什么是 'DTOs/models'?

这些是数据结构,定义了数据在被应用发送或接收时应如何组织。

详情

作者的原始描述

Create ASP.NET Minimal API endpoints with proper OpenAPI documentation

repo: github/awesome-copilot

热度

GitHub 星标
40k
排名
#7067
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能