From 503733dfc73a31cf51aca97376ed8aa965649b26 Mon Sep 17 00:00:00 2001 From: SeungYongShim Date: Sun, 18 Feb 2024 23:22:51 +0900 Subject: [PATCH] . --- README.md | 57 ++++++++++++++++++++++++ src/WebApplicationMinimalApi8/Program.cs | 10 +++++ 2 files changed, 67 insertions(+) diff --git a/README.md b/README.md index 843463b..308b8ba 100644 --- a/README.md +++ b/README.md @@ -59,3 +59,60 @@ builder.Services.AddProblemDetails(options => } ); ``` + +## CRUD API 작성하기 +* https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html +``` +Create +--------------------------------------------------------------------- +Success - 201 Created - Return created object +Failure - 400 Invalid request - Return details about the failure +Async fire and forget operation - 202 Accepted - Optionally return url for polling status + +Update +--------------------------------------------------------------------- +Success - 200 Ok - Return the updated object +Success - 204 NoContent +Failure - 404 NotFound - The targeted entity identifier does not exist +Failure - 400 Invalid request - Return details about the failure +Async fire and forget operation - 202 Accepted - Optionally return url for polling status + +Patch +--------------------------------------------------------------------- +Success - 200 Ok - Return the patched object +Success - 204 NoContent +Failure - 404 NotFound - The targeted entity identifier does not exist +Failure - 400 Invalid request - Return details about the failure +Async fire and forget operation - 202 Accepted - Optionally return url for polling status + +Delete +--------------------------------------------------------------------- +Success - 200 Ok - No content +Success - 200 Ok - When element attempting to be deleted does not exist +Async fire and forget operation - 202 Accepted - Optionally return url for polling status + +Get +--------------------------------------------------------------------- +Success - 200 Ok - With the list of resulting entities matching the search criteria +Success - 200 Ok - With an empty array + +Get specific +--------------------------------------------------------------------- +Success - 200 Ok - The entity matching the identifier specified is returned as content +Failure - 404 NotFound - No content + +Action +--------------------------------------------------------------------- +Success - 200 Ok - Return content where appropriate +Success - 204 NoContent +Failure - 400 - Return details about the failure +Async fire and forget operation - 202 Accepted - Optionally return url for polling status + +Generic results +--------------------------------------------------------------------- +Authorization error 401 Unauthorized +Authentication error 403 Forbidden +For methods not supported 405 +Generic server error 500 +``` + diff --git a/src/WebApplicationMinimalApi8/Program.cs b/src/WebApplicationMinimalApi8/Program.cs index f052a3c..0c5be07 100644 --- a/src/WebApplicationMinimalApi8/Program.cs +++ b/src/WebApplicationMinimalApi8/Program.cs @@ -79,6 +79,16 @@ .WithDescription("사람을 생성합니다.") .WithOpenApi(); +root.MapPut("/Persons", (PersonDto person) => Results.Created("/Persons/1", new + { + Id = 1, + person.Name, + person.Age, + person.Emails + })) + .WithDescription("사람을 생성합니다.") + .WithOpenApi(); + app.Run(); static void InterceptNullSetter(JsonTypeInfo typeInfo)