-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add Fly server to swagger (#40)
- Loading branch information
1 parent
e5f5953
commit b4d3cc1
Showing
3 changed files
with
222 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
src/Helldivers-2-API/OpenApi/HelldiversDocumentProcessor.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,40 @@ | ||
#if DEBUG | ||
using NSwag; | ||
using NSwag.Generation.Processors; | ||
using NSwag.Generation.Processors.Contexts; | ||
|
||
namespace Helldivers.API.OpenApi; | ||
|
||
/// <summary> | ||
/// Handles processing of the OpenAPI specification of the Production Helldivers API. | ||
/// </summary> | ||
public class HelldiversDocumentProcessor : IDocumentProcessor | ||
{ | ||
private const string HelldiversFlyServer = "https://helldivers-2-dotnet.fly.dev/"; | ||
private const string LocalServer = "/"; | ||
|
||
/// <inheritdoc /> | ||
public void Process(DocumentProcessorContext context) | ||
{ | ||
// First we make a copy of the Paths, since C# doesn't like it when collections are modified during iteration. | ||
var paths = context.Document.Paths.ToList(); | ||
var server = new OpenApiServer | ||
{ | ||
Description = "The dotnet helldivers server", | ||
Url = HelldiversFlyServer | ||
}; | ||
var local = new OpenApiServer | ||
{ | ||
Description = "The development server", | ||
Url = LocalServer | ||
}; | ||
|
||
foreach (var (_, item) in paths) | ||
{ | ||
item.Servers.Clear(); | ||
item.Servers.Add(server); | ||
item.Servers.Add(local); | ||
} | ||
} | ||
} | ||
#endif |
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