diff --git a/cli/Squidex.CLI/Squidex.CLI.sln b/cli/Squidex.CLI/Squidex.CLI.sln
index 84536fb9..fd02a6b5 100644
--- a/cli/Squidex.CLI/Squidex.CLI.sln
+++ b/cli/Squidex.CLI/Squidex.CLI.sln
@@ -20,6 +20,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.ClientLibrary.Tests
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.CLI.Core", "Squidex.CLI.Core\Squidex.CLI.Core.csproj", "{2E2862C3-F689-4A93-8C27-48536E03C4C5}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Squidex.ClientLibrary.ServiceExtensions", "..\..\csharp\Squidex.ClientLibrary\Squidex.ClientLibrary.ServiceExtensions\Squidex.ClientLibrary.ServiceExtensions.csproj", "{E226A98A-E0A6-47E2-AB75-03D6354E703D}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -50,6 +52,10 @@ Global
{2E2862C3-F689-4A93-8C27-48536E03C4C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2E2862C3-F689-4A93-8C27-48536E03C4C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2E2862C3-F689-4A93-8C27-48536E03C4C5}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E226A98A-E0A6-47E2-AB75-03D6354E703D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E226A98A-E0A6-47E2-AB75-03D6354E703D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E226A98A-E0A6-47E2-AB75-03D6354E703D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E226A98A-E0A6-47E2-AB75-03D6354E703D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/csharp/Squidex.ClientLibrary/CodeGeneration/CodeGeneration.csproj b/csharp/Squidex.ClientLibrary/CodeGeneration/CodeGeneration.csproj
index bfacfa04..be9bdf68 100644
--- a/csharp/Squidex.ClientLibrary/CodeGeneration/CodeGeneration.csproj
+++ b/csharp/Squidex.ClientLibrary/CodeGeneration/CodeGeneration.csproj
@@ -2,7 +2,7 @@
Exe
- net6.0
+ net7.0
latest
false
@@ -12,6 +12,7 @@
all
+
all
diff --git a/csharp/Squidex.ClientLibrary/CodeGeneration/Program.cs b/csharp/Squidex.ClientLibrary/CodeGeneration/Program.cs
index 8802bc22..8f143f00 100644
--- a/csharp/Squidex.ClientLibrary/CodeGeneration/Program.cs
+++ b/csharp/Squidex.ClientLibrary/CodeGeneration/Program.cs
@@ -22,7 +22,14 @@ public static async Task Main()
{
var document = await OpenApiDocument.FromUrlAsync("https://localhost:5001/api/swagger/v1/swagger.json");
- SchemaCleaner.Clean(document);
+ SchemaCleaner.AddExtensions(document);
+
+ // We write a more complete schema for fern code generation.
+ File.WriteAllText("openapi.json", document.ToJson());
+
+ // This cleanup is only needed for .NET.
+ SchemaCleaner.RemoveAppName(document);
+ SchemaCleaner.RemoveUnusedSchemas(document);
var generatorSettings = new CSharpClientGeneratorSettings();
generatorSettings.ExceptionClass = "SquidexManagementException";
@@ -47,7 +54,7 @@ public static async Task Main()
.GenerateFile();
// Use a static version to keep the changes low.
- sourceCode = sourceCode.Replace("13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v10.0.0.0))", "13.17.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v9.0.0.0))");
+ sourceCode = sourceCode.Replace("13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v12.0.0.0))", "13.17.0.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v9.0.0.0))");
File.WriteAllText(@"..\..\..\..\Squidex.ClientLibrary\Management\Generated.cs", sourceCode);
}
diff --git a/csharp/Squidex.ClientLibrary/CodeGeneration/SchemaCleaner.cs b/csharp/Squidex.ClientLibrary/CodeGeneration/SchemaCleaner.cs
index b4dbe2c7..e9bc082f 100644
--- a/csharp/Squidex.ClientLibrary/CodeGeneration/SchemaCleaner.cs
+++ b/csharp/Squidex.ClientLibrary/CodeGeneration/SchemaCleaner.cs
@@ -7,12 +7,44 @@
using NJsonSchema;
using NSwag;
+using Squidex.Text;
namespace CodeGeneration;
internal static class SchemaCleaner
{
- public static void Clean(OpenApiDocument document)
+ public static void AddExtensions(OpenApiDocument document)
+ {
+ static void AddExtensions(OpenApiOperation operation)
+ {
+ operation.ExtensionData ??= new Dictionary();
+ operation.ExtensionData["x-fern-sdk-group-name"] = operation.Tags[0].ToCamelCase();
+ operation.ExtensionData["x-fern-sdk-method-name"] = operation.OperationId.Split('_').Last().ToCamelCase();
+ }
+
+ foreach (var description in document.Operations.ToList())
+ {
+ AddExtensions(description.Operation);
+ }
+ }
+
+ public static void RemoveAppName(OpenApiDocument document)
+ {
+ foreach (var description in document.Operations.ToList())
+ {
+ var parameters = description.Operation.Parameters;
+
+ foreach (var parameter in parameters.ToList())
+ {
+ if (parameter.Kind == OpenApiParameterKind.Path && parameter.Name == "app")
+ {
+ parameters.Remove(parameter);
+ }
+ }
+ }
+ }
+
+ public static void RemoveUnusedSchemas(OpenApiDocument document)
{
var usedRefs = new Dictionary();
@@ -44,16 +76,6 @@ void RemoveSchema(JsonSchema schema)
foreach (var description in document.Operations.ToList())
{
- var parameters = description.Operation.Parameters;
-
- foreach (var parameter in parameters.ToList())
- {
- if (parameter.Kind == OpenApiParameterKind.Path && parameter.Name == "app")
- {
- parameters.Remove(parameter);
- }
- }
-
HandleOperation(description.Operation, AddSchema);
}