Skip to content

Commit

Permalink
Extend websocket swagger documentation (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexMacocian authored Nov 27, 2023
1 parent 69b999e commit 1cac7c3
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 3 deletions.
2 changes: 1 addition & 1 deletion GuildWarsPartySearch/Launch/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace GuildWarsPartySearch.Server.Launch;

public class Program
{
public static CancellationTokenSource CancellationTokenSource = new();
public static readonly CancellationTokenSource CancellationTokenSource = new();

private static async Task Main()
{
Expand Down
88 changes: 86 additions & 2 deletions GuildWarsPartySearch/Launch/WebSocketEndpointsDocumentFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,55 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
Name = "PartySearch"
}
},
Description = "WebSocket endpoint for live feed.",
Description = @"
WebSocket endpoint for live feed.
Sends periodic party search updates. Example:
```json
{
""Searches"":
[
{
""Campaign"":""Prophecies"",
""Continent"":""Tyria"",
""Region"":""Kryta"",
""Map"":""Lions Arch"",
""District"":""En - 1"",
""PartySearchEntries"":
[
{
""CharName"":""Shiro Tagachi"",
""PartySize"":8,
""PartyMaxSize"":8,
""Npcs"":0
},
{
""CharName"":""Kormir Sucks"",
""PartySize"":8,
""PartyMaxSize"":8,
""Npcs"":0
}
]
},
{
""Campaign"":""Prophecies"",
""Continent"":""Tyria"",
""Region"":""Kryta"",
""Map"":""Warrior's Isle"",
""District"":""En - 1"",
""PartySearchEntries"":
[
{
""CharName"":""Don Abaddon"",
""PartySize"":0,
""PartyMaxSize"":16,
""Npcs"":2
}
]
}
]
}
```",
Responses = new OpenApiResponses
{
{ "200", new OpenApiResponse(){ Description = "Success" } },
Expand Down Expand Up @@ -78,7 +126,43 @@ public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
Name = "PartySearch"
}
},
Description = $"WebSocket endpoint for posting party search updates. Protected by {ApiKeyProtected.ApiKeyHeader} header.",
Description = @$"
WebSocket endpoint for posting party search updates.
Protected by *{ApiKeyProtected.ApiKeyHeader}* header.
Accepts json payloads. Example:
```json
{{
""Continent"": ""Tyria"",
""Campaign"": ""Prophecies"",
""Region"": ""Kryta"",
""Map"": 4,
""District"": ""En - 1"",
""PartySearchEntries"": [
{{
""PartySize"": 8,
""PartyMaxSize"": 8,
""Npcs"": 0,
""CharName"": ""Shiro Tagachi"",
}},
{{
""PartySize"": 8,
""PartyMaxSize"": 8,
""Npcs"": 0,
""CharName"": ""Kormir Sucks"",
}}
]
}}
```
Returns json payloads. Example:
```json
{{
""Result"": 0,
""Description"": ""Success""
}}
```",
Responses = new OpenApiResponses
{
{ "200", new OpenApiResponse(){ Description = "Success" } },
Expand Down

0 comments on commit 1cac7c3

Please sign in to comment.