Skip to content

Commit

Permalink
Improve code cleaner.
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianStehle committed Jun 23, 2023
1 parent d3c14fb commit 2b0a308
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions csharp/Squidex.ClientLibrary/CodeGeneration/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace CodeGeneration;

public static partial class Program
public static class Program
{
public static async Task Main()
{
Expand All @@ -23,8 +23,19 @@ public static async Task Main()

// This cleanup is only needed for .NET.
SchemaCleaner.RemoveAppName(document);

// We also need a version without app name.
File.WriteAllText(@"..\..\..\..\..\..\..\sdk-fern\fern\api\openapi\openapi-noapp.json", document.ToJson().UseCloudUrl());

SchemaCleaner.RemoveUnusedSchemas(document);

var sourceCode = GenerateCode(document);

File.WriteAllText(@"..\..\..\..\Squidex.ClientLibrary\Generated.cs", sourceCode);
}

private static string GenerateCode(OpenApiDocument document)
{
var generatorSettings = new CSharpClientGeneratorSettings();
generatorSettings.CSharpGeneratorSettings.TemplateDirectory = Directory.GetCurrentDirectory();
generatorSettings.CSharpGeneratorSettings.ArrayBaseType = "System.Collections.Generic.List";
Expand All @@ -48,7 +59,6 @@ public static async Task Main()
var sourceCode =
new CSharpClientGenerator(document, generatorSettings)
.GenerateFile().UseFixedVersion(); // Use a static version to keep the changes low.

File.WriteAllText(@"..\..\..\..\Squidex.ClientLibrary\Generated.cs", sourceCode);
return sourceCode;
}
}

0 comments on commit 2b0a308

Please sign in to comment.