diff --git a/README.md b/README.md index 143ceb6..6b54f44 100644 --- a/README.md +++ b/README.md @@ -119,43 +119,6 @@ app.Run(); > **Note** The `MapEndpoints` method is generated by the Source Generator. -## MinimalHelpers.OpenApi - -[![Nuget](https://img.shields.io/nuget/v/MinimalHelpers.OpenApi)](https://www.nuget.org/packages/MinimalHelpers.OpenApi) -[![Nuget](https://img.shields.io/nuget/dt/MinimalHelpers.OpenApi)](https://www.nuget.org/packages/MinimalHelpers.OpenApi) - -A library that provides OpenAPI helpers for Minimal API projects. - -### Installation - -The library is available on [NuGet](https://www.nuget.org/packages/MinimalHelpers.OpenApi). Search for *MinimalHelpers.OpenApi* in the **Package Manager GUI** or run the following command in the **.NET CLI**: - -```shell -dotnet add package MinimalHelpers.OpenApi -``` - -### Usage - - ***Extension methods for RouteHandlerBuilder*** - - Often, endpoints have multiple 4xx return values, each producing a `ProblemDetails` response: - - ```csharp - endpoints.MapGet("/api/people/{id:guid}", Get) - .ProducesProblem(StatusCodes.Status400BadRequest) - .ProducesProblem(StatusCodes.Status401Unauthorized) - .ProducesProblem(StatusCodes.Status403Forbidden) - .ProducesProblem(StatusCodes.Status404NotFound); - ``` - -To avoid multiple calls to `ProducesProblem`, use the `ProducesDefaultProblem` extension method provided by the library: - - ```csharp -endpoints.MapGet("/api/people/{id:guid}", Get) - .ProducesDefaultProblem(StatusCodes.Status400BadRequest, StatusCodes.Status401Unauthorized, - StatusCodes.Status403Forbidden, StatusCodes.Status404NotFound); - ``` - ## MinimalHelpers.FluentValidation [![Nuget](https://img.shields.io/nuget/v/MinimalHelpers.FluentValidation)](https://www.nuget.org/packages/MinimalHelpers.FluentValidation) diff --git a/samples/MinimalSample/MinimalSample.csproj b/samples/MinimalSample/MinimalSample.csproj index b45cdef..a1d8965 100644 --- a/samples/MinimalSample/MinimalSample.csproj +++ b/samples/MinimalSample/MinimalSample.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/MinimalHelpers.OpenApi/RouteHandlerBuilderExtensions.cs b/src/MinimalHelpers.OpenApi/RouteHandlerBuilderExtensions.cs index 2bb0c90..66f37a5 100644 --- a/src/MinimalHelpers.OpenApi/RouteHandlerBuilderExtensions.cs +++ b/src/MinimalHelpers.OpenApi/RouteHandlerBuilderExtensions.cs @@ -16,6 +16,7 @@ public static class RouteHandlerBuilderExtensions /// The . /// The list of status codes to be added as responses. /// The with the new status codes responses. + [Obsolete("This method will be removed in future versions. Use the ProducesDefaultProblem method that is available in the TinyHelpers.AspNetCoore library instead.")] public static RouteHandlerBuilder ProducesDefaultProblem(this RouteHandlerBuilder builder, params int[] statusCodes) { foreach (var statusCode in statusCodes)