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

fix .NET 9 breakages #122

Merged
merged 1 commit into from
Nov 15, 2024
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
22 changes: 7 additions & 15 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,36 +26,28 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
- name: Install DocFX
run: dotnet tool install -g docfx
- name: Initial static JSON schema submodule
run: git submodule update --init ./src/Helldivers-2-Models/json
- name: Generate OpenAPI JSON files
run: dotnet build -c Debug
- name: Generate DocFX metadata
run: docfx metadata
- name: Generate DocFX site
run: docfx build docfx.json
- name: Upload DocFX website
- name: Copy README
run: cp README.md docs/README.md
- name: Upload docsify website
uses: actions/upload-artifact@master
with:
name: 'docfx'
path: './_site/'
name: 'docs'
path: './docs/'
deploy:
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Download DocFX website
- name: Download docsify website
uses: actions/download-artifact@master
with:
name: 'docfx'
name: 'docs'
path: '.'
- name: Setup Pages
uses: actions/configure-pages@v4
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,8 @@ FodyWeavers.xsd
# Jetbrains generated folders
.idea/

# DocFX generates files
_site/
api/
# docsify files
docs/README.md

# Ignore OpenAPI documents
docs/openapi/*.json
1 change: 0 additions & 1 deletion Helldivers-2.sln
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
Directory.Build.props = Directory.Build.props
fly.toml = fly.toml
.dockerignore = .dockerignore
docfx.json = docfx.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Helldivers-2-Models", "src\Helldivers-2-Models\Helldivers-2-Models.csproj", "{9B017849-C756-4B98-9B98-885AEBE9EAD4}"
Expand Down
46 changes: 0 additions & 46 deletions docfx.json

This file was deleted.

Empty file added docs/.nojekyll
Empty file.
12 changes: 12 additions & 0 deletions docs/_coverpage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
![logo](https://avatars.githubusercontent.com/u/164774207?s=200&v=4)

# Helldivers 2<small>API</small>

> A community driven API wrapper for Helldivers 2

- Provides fast & cached access to the official Helldivers 2 API
- Convenience abstractions for modern API design
- You can self host!

[GitHub](https://github.com/helldivers-2/api)
[Get Started](README.md)
4 changes: 4 additions & 0 deletions docs/_navbar.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
* [Self host](containers.md)
* OpenAPI
* [Redoc](openapi/redoc.html ':ignore')
* [Swagger UI](openapi/swagger-ui.html ':ignore')
1 change: 0 additions & 1 deletion docs/getting-started.md

This file was deleted.

27 changes: 27 additions & 0 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Helldivers 2 API</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/docsify@4/lib/themes/vue.css">
</head>
<body>
<div id="app"></div>
<script>
window.$docsify = {
name: 'Helldivers 2 API',
repo: 'helldivers-2/api',
coverpage: true,
loadNavbar: true,
executeScript: true,
oCompileLinks: ['*.html'],
}
</script>
<!-- Docsify v4 -->
<script src="//cdn.jsdelivr.net/npm/docsify@4"></script>
<script src="//cdn.jsdelivr.net/npm/docsify-copy-code/dist/docsify-copy-code.min.js"></script>
</body>
</html>
1 change: 0 additions & 1 deletion docs/introduction.md

This file was deleted.

12 changes: 0 additions & 12 deletions docs/toc.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if DEBUG
using NSwag;
using NSwag.Generation.Processors;
using NSwag.Generation.Processors.Contexts;
Expand Down Expand Up @@ -40,3 +41,4 @@ public bool Process(OperationProcessorContext context)
return true;
}
}
#endif
3 changes: 1 addition & 2 deletions src/Helldivers-2-API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Helldivers.API.Controllers.V1;
using Helldivers.API.Metrics;
using Helldivers.API.Middlewares;
using Helldivers.API.OpenApi.OperationProcessors;
using Helldivers.Core.Extensions;
using Helldivers.Models;
using Helldivers.Models.Domain.Localization;
Expand Down Expand Up @@ -163,7 +162,7 @@
new Helldivers.API.OpenApi.TypeMappers.LocalizedMessageTypeMapper(languages)
);

document.OperationProcessors.Add(new SuperHeadersProcessor());
document.OperationProcessors.Add(new Helldivers.API.OpenApi.OperationProcessors.SuperHeadersProcessor());

document.DocumentProcessors.Add(new Helldivers.API.OpenApi.DocumentProcessors.HelldiversDocumentProcessor());
});
Expand Down
64 changes: 0 additions & 64 deletions src/Helldivers-2-SourceGen/StaticJsonSourceGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,68 +73,4 @@ private static IJsonParser GetParserForFile(AdditionalText file)
_ => throw new Exception($"Generator does not know how to parse {name}")
};
}



#if false
/// <inheritdoc />
public void Execute(GeneratorExecutionContext context)
{
foreach (var file in context.AdditionalFiles)
{
if (file is null)
continue;

var name = Path.GetFileNameWithoutExtension(file.Path);
name = $"{char.ToUpper(name[0])}{name.Substring(1)}";

try
{
var json = file.GetText(context.CancellationToken)?.ToString() ?? throw new InvalidOperationException($"Cannot generate C# from missing JSON file {file.Path}");

var (type, value) = name.ToLowerInvariant() switch
{
"planets" => ParsePlanetsDictionary(json),
"biomes" => ParseBiomesDictionary(json),
"environmentals" => ParseEnvironmentalsDictionary(json),
"factions" => ParseFactionsDictionary(json),
_ => throw new Exception($"Generator does not know how to parse {name}")
};

var source = $@"// <auto-generated />
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
using global::System.Collections.Generic;
using global::Helldivers.Models.Domain.Localization;

namespace Helldivers.Models;

public static partial class Static
{{
/// <summary>Public list of {name} entries from {Path.GetFileName(file.Path)}</summary>
public static {type} {name} = {value};
}}
";

context.AddSource($"{name}.g.cs", source);
}
catch (Exception exception)
{
context.AddSource($"{name}.g.cs", $"// An exception was thrown processing {name}.json\n{exception.ToString()}");
context.ReportDiagnostic(
Diagnostic.Create(
new DiagnosticDescriptor(
id: "HDJSON", // Unique ID for your error
title: "JSON source generator failed", // Title of the error
messageFormat: $"An error occured generating C# code from JSON files: {exception}", // Message format
category: "HD2", // Category of the error
DiagnosticSeverity.Error, // Severity of the error
isEnabledByDefault: true // Whether the error is enabled by default
),
Location.None // No specific location provided for simplicity
)
);
}
}
}
#endif
}