-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic Swagger UI (+Swashbuckle) documentation. #4
- Loading branch information
1 parent
fbb3183
commit dfa8204
Showing
66 changed files
with
1,085 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# OpenApi Docs | ||
|
||
* status: accepted | ||
* date: 2024-05-02 | ||
* deciders: jezzsantos | ||
|
||
# Context and Problem Statement | ||
|
||
Adding OpenAPI documentation to the project will help developers better understand the API and how to use it. | ||
|
||
In .net8.0 there is partial support for OpenAPI by ASP.NET Core, but it is not as feature rich as the Swashbuckle or NSwag libraries. | ||
That wil ultimately change in .net9.0 as Swashbuckle has gone out of support. As per [this announcement](https://github.com/dotnet/aspnetcore/issues/54599) | ||
|
||
We need the following capabilities. | ||
|
||
1. Provide a developer fo the API some documentation about the API. | ||
2. Enables the developer to try out the API with a built-in tool | ||
3. Allows the backend to publish to other tools that can derive code from the API documentation. For example, JS/TS classes to be consumed by the WebsiteHost | ||
|
||
## Considered Options | ||
|
||
The options are: | ||
|
||
1. Swashbuckle | ||
2. NSwag | ||
3. AspNetCore OpenAPI | ||
|
||
## Decision Outcome | ||
|
||
`Swashbuckle` | ||
|
||
- It is mostly supported in .net8.0. | ||
- It does the basics of what we need now, with some custom extensions | ||
- NSwag has serious issues with correctly generating "multipart/form-data" data requests | ||
- We will switch to .net9.0 when released |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rastructure.Shared/ApplicationServices/External/FlagsmithHttpServiceClient.TestingOnly.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Infrastructure.Web.Api.Common.UnitTests/Endpoints/RequestCorrelationFilterSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Infrastructure.Web.Api.Common.UnitTests/Extensions/HttpResponseExtensionsSpec.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
src/Infrastructure.Web.Api.Common/Endpoints/RequestCorrelationFilter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
src/Infrastructure.Web.Api.Common/Extensions/OperationMethodExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Infrastructure.Web.Api.Interfaces; | ||
|
||
namespace Infrastructure.Web.Api.Common.Extensions; | ||
|
||
public static class OperationMethodExtensions | ||
{ | ||
/// <summary> | ||
/// Converts the <see cref="OperationMethod" /> to an appropriate <see cref="HttpMethod" /> | ||
/// </summary> | ||
public static HttpMethod ToHttpMethod(this OperationMethod method) | ||
{ | ||
return method switch | ||
{ | ||
OperationMethod.Get => HttpMethod.Get, | ||
OperationMethod.Search => HttpMethod.Get, | ||
OperationMethod.Post => HttpMethod.Post, | ||
OperationMethod.PutPatch => HttpMethod.Put, | ||
OperationMethod.Delete => HttpMethod.Delete, | ||
_ => HttpMethod.Get | ||
}; | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
src/Infrastructure.Web.Api.Common/Extensions/ResponseExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System.Net; | ||
using Infrastructure.Web.Api.Interfaces; | ||
|
||
namespace Infrastructure.Web.Api.Common.Extensions; | ||
|
||
public static class ResponseExtensions | ||
{ | ||
/// <summary> | ||
/// Returns the default <see cref="HttpStatusCode" /> for the specified <see cref="responseType" /> | ||
/// and <see cref="options" /> | ||
/// </summary> | ||
public static HttpStatusCode GetDefaultResponseCode(this HttpMethod method, ResponseCodeOptions options) | ||
{ | ||
if (method == HttpMethod.Get) | ||
{ | ||
return HttpStatusCode.OK; | ||
} | ||
|
||
if (method == HttpMethod.Post) | ||
{ | ||
return options.HasLocation | ||
? HttpStatusCode.Created | ||
: HttpStatusCode.OK; | ||
} | ||
|
||
if (method == HttpMethod.Put | ||
|| method == HttpMethod.Patch) | ||
{ | ||
return HttpStatusCode.Accepted; | ||
} | ||
|
||
if (method == HttpMethod.Delete) | ||
{ | ||
return options.HasContent | ||
? HttpStatusCode.Accepted | ||
: HttpStatusCode.NoContent; | ||
} | ||
|
||
return HttpStatusCode.OK; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 0 additions & 9 deletions
9
src/Infrastructure.Web.Api.Common/Validation/ValidationResources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.