본문으로 건너뛰기
Skillpedia
API 및 서버 (백엔드)5.8k · #14560

dotnet-webapi

하는 일

이 스킬은 컨트롤러나 미니멀 API를 사용해 ASP.NET Core Web API 엔드포인트를 만들고 바꾸는 과정을 안내합니다. 깔끔한 응답과 문서화된 엔드포인트를 원하는 HTTP API 개발자를 위한 스킬입니다.

사용하는 경우

  • ✓ASP.NET Core 프로젝트에서 Web API 엔드포인트를 추가하거나 바꿔야 할 때.
  • ✓API에 OpenAPI나 Swagger 문서가 필요할 때.
  • ✓일관된 오류 응답을 주는 전역 오류 처리기가 필요할 때.

스킬 링크

https://github.com/dotnet/skills/blob/main/plugins/dotnet-aspnetcore/skills/dotnet-webapi/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/dotnet/skills/blob/main/plugins/dotnet-aspnetcore/skills/dotnet-webapi/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“주문을 만들고, 올바른 상태 코드를 반환하며, OpenAPI에 문서화된 Web API 엔드포인트를 추가해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

에이전트가 프로젝트의 기존 API 방식에 맞추고, 올바른 HTTP 상태 코드와 데이터 전송 객체를 갖춘 엔드포인트를 쓰고, OpenAPI 메타데이터를 추가한 뒤, 중앙 오류 처리를 설정합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

ASP.NET Core Web API

Produce well-structured ASP.NET Core Web API endpoints with proper HTTP semantics, OpenAPI documentation, and error handling.

When to Use

Use this skill when working on ASP.NET Core HTTP APIs, including:

  • adding or modifying Web API endpoints implemented with controllers or minimal APIs;
  • wiring up OpenAPI/Swagger metadata and endpoint documentation;
  • defining request/response DTOs and consistent HTTP status code behavior;
  • adding .http files or similar request-based API testing artifacts;
  • configuring centralized API error handling middleware or exception mapping.

When Not to Use

Do not use this skill for:

  • general C# coding style or non-API refactoring;
  • EF Core data modeling or query optimization work; use optimizing-ef-core-queries;
  • frontend, Razor, or Blazor UI changes;
  • gRPC services;
  • SignalR hubs or real-time messaging flows.

Inputs / prerequisites

Before applying this skill, gather the project context needed to match the existing API style and wiring:

  • the ASP.NET Core entry point, typically Program.cs;
  • any existing controllers, especially classes inheriting ControllerBase or using [ApiController];
  • any existing minimal API registrations such as app.MapGet, app.MapPost, app.MapPut, or app.MapDelete;
  • related DTO, model, validation, and error-handling types already used by the project;
  • available build, run, and test commands so changes can be verified.

If the user asks for a new endpoint, inspect the current project structure first so the implementation follows the established conventions rather than mixing styles.

Workflow

Step 1: Determine the API style

Scan the project for existing endpoint patterns before writing any code.

  1. Search for classes inheriting ControllerBase or decorated with [ApiController].
  2. Search Program.cs or endpoint files for app.MapGet, app.MapPost, etc.
  3. If the project already uses controllers, continue with controllers.
  4. If the project already uses minimal APIs, continue with minimal APIs.
  5. If neither exists (new project), default to minimal APIs unless the user explicitly requests controllers.

Do not mix styles in the same project.

Step 2: Define request and response types

Create dedicated types for API input and output. Never expose EF Core entities directly in request or response bodies.

Use sealed record for all DTOs. Records enforce immutability, provide value-based equality, and produce concise code. Seal them to prevent unintended inheritance and enable JIT devirtualization (CA1852).

Naming convention:

Role Convention Example
Input (create) Create{Entity}Request CreateProductRequest
Input (update) Update{Entity}Request UpdateProductRequest
Output (single) {Entity}Response ProductResponse
Output (list) {Entity}ListResponse ProductListResponse

XML doc comments on all DTOs: Add <summary> XML doc comments to every request and response type exposed in the API. These comments are automatically included in the generated OpenAPI specification, producing richer documentation without extra metadata calls.

Reference: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/openapi-comments

Date and time values — use DateTimeOffset: When a DTO includes a date or time property, always use DateTimeOffset instead of DateTime. DateTimeOffset preserves the UTC offset, avoids ambiguous timezone conversions, and serializes to ISO 8601 with offset information in JSON — which is what API consumers expect.

Reference: https://learn.microsoft.com/en-us/dotnet/api/system.datetimeoffset JSON serialization options — preserve existing behavior by default: For existing APIs, do not introduce stricter serialization/deserialization settings unless the project already uses them or the user explicitly asks for them. Settings such as case-sensitive property matching and strict number handling can break existing clients. For new projects, or when strict JSON handling is explicitly requested, configure options like the following to minimize the potential of processing malicious requests:

// Apply these settings only for new projects, when the existing project already
// uses them, or when the user explicitly requests stricter JSON behavior.
builder.Services.ConfigureHttpJsonOptions(options =>
{
    // disallow reading numbers fro
자주 묻는 질문

데이터베이스 쿼리도 다루나요?

아니요. Entity Framework 데이터 접근은 별도의 스킬이 다룹니다.

테스트용 요청 파일을 만들 수 있나요?

네. 엔드포인트를 테스트하는 .http 파일을 추가할 수 있습니다.

gRPC나 SignalR도 되나요?

아니요. 그것들은 이 스킬의 범위 밖입니다.

상세 정보

작성자의 원본 설명

Guides creation and modification of ASP.NET Core Web API endpoints with correct HTTP semantics, OpenAPI metadata, and error handling. USE FOR: adding new API endpoints (controllers or minimal APIs), wiring up OpenAPI/Swagger, creating .http test files, setting up global error handling middleware. DO NOT USE FOR: general C# coding style, EF Core data access or query optimization (use optimizing-ef-core-queries), frontend/Blazor work, gRPC services, or SignalR hubs.

repo: dotnet/skills

인기도

GitHub 스타
5.8k
순위
#14560
라이선스
MIT
업데이트
2026. 11. 2.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬