Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend websocket swagger documentation #34

Merged
merged 1 commit into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading