Skip to content
Open
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
7 changes: 6 additions & 1 deletion src/KubernetesCRDModelGen.Base/CodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Xml.Linq;

namespace KubernetesCRDModelGen.Base;
Expand Down Expand Up @@ -398,7 +399,7 @@ private string GetOrGenerateType(IOpenApiSchema schema, List<BaseTypeDeclaration

return $"IList<{GetOrGenerateType(schema.Items, types, parentClassName, propertyName)}>";
default:
throw new Exception("Unsupported Type: " + JsonSerializer.Serialize(schema));
throw new Exception("Unsupported Type: " + JsonSerializer.Serialize(schema, CodeGeneratorSourceGenerationContext.Default.IOpenApiSchema));
}
}

Expand Down Expand Up @@ -663,3 +664,7 @@ public static string RemoveIllegalFileNameCharacters(string fileName)
}
}

[JsonSerializable(typeof(IOpenApiSchema))]
internal partial class CodeGeneratorSourceGenerationContext : JsonSerializerContext
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
<PackageReference Include="Microsoft.OpenApi" Version="2.3.5" />
<PackageReference Include="Microsoft.OpenApi" Version="2.3.8" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'net8.0'">
Expand Down
18 changes: 16 additions & 2 deletions src/KubernetesCRDModelGen/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
using System.Reflection;
using System.Runtime.Loader;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Xml;
using static k8s.KubernetesJson;

namespace KubernetesCRDModelGen;

Expand Down Expand Up @@ -121,8 +123,7 @@

var reader = new OpenApiJsonReader();

var node = JsonSerializer.SerializeToNode(version.Schema.OpenAPIV3Schema);

var node = JsonSerializer.SerializeToNode(version.Schema.OpenAPIV3Schema, GeneratorSourceGenerationContext.Default.V1JSONSchemaProps);
var doc = reader.ReadFragment<OpenApiSchema>(node, OpenApiSpecVersion.OpenApi3_0, new OpenApiDocument(), out var diag);

if (diag != null && diag.Errors.Count > 0)
Expand Down Expand Up @@ -155,3 +156,16 @@
return [.. references];
}
}

[JsonSerializable(typeof(V1JSONSchemaProps))]
[JsonSerializable(typeof(Dictionary<object, object>))]
[JsonSerializable(typeof(byte))]
[JsonSourceGenerationOptions(
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase,
UseStringEnumConverter = true,
Converters = new[] { typeof(Iso8601TimeSpanConverter), typeof(KubernetesDateTimeConverter), typeof(KubernetesDateTimeOffsetConverter)})

Check failure on line 167 in src/KubernetesCRDModelGen/Generator.cs

View workflow job for this annotation

GitHub Actions / Create Release

'KubernetesJson.Iso8601TimeSpanConverter' is inaccessible due to its protection level

Check failure on line 167 in src/KubernetesCRDModelGen/Generator.cs

View workflow job for this annotation

GitHub Actions / Create Release

'KubernetesJson.KubernetesDateTimeOffsetConverter' is inaccessible due to its protection level

Check failure on line 167 in src/KubernetesCRDModelGen/Generator.cs

View workflow job for this annotation

GitHub Actions / Create Release

'KubernetesJson.KubernetesDateTimeConverter' is inaccessible due to its protection level

Check failure on line 167 in src/KubernetesCRDModelGen/Generator.cs

View workflow job for this annotation

GitHub Actions / Create Release

'KubernetesJson.Iso8601TimeSpanConverter' is inaccessible due to its protection level

Check failure on line 167 in src/KubernetesCRDModelGen/Generator.cs

View workflow job for this annotation

GitHub Actions / Create Release

'KubernetesJson.KubernetesDateTimeOffsetConverter' is inaccessible due to its protection level

Check failure on line 167 in src/KubernetesCRDModelGen/Generator.cs

View workflow job for this annotation

GitHub Actions / Create Release

'KubernetesJson.KubernetesDateTimeConverter' is inaccessible due to its protection level

Check failure on line 167 in src/KubernetesCRDModelGen/Generator.cs

View workflow job for this annotation

GitHub Actions / Create Release

'KubernetesJson.Iso8601TimeSpanConverter' is inaccessible due to its protection level

Check failure on line 167 in src/KubernetesCRDModelGen/Generator.cs

View workflow job for this annotation

GitHub Actions / Create Release

'KubernetesJson.KubernetesDateTimeOffsetConverter' is inaccessible due to its protection level

Check failure on line 167 in src/KubernetesCRDModelGen/Generator.cs

View workflow job for this annotation

GitHub Actions / Create Release

'KubernetesJson.KubernetesDateTimeConverter' is inaccessible due to its protection level

Check failure on line 167 in src/KubernetesCRDModelGen/Generator.cs

View workflow job for this annotation

GitHub Actions / Create Release

'KubernetesJson.Iso8601TimeSpanConverter' is inaccessible due to its protection level
]
internal partial class GeneratorSourceGenerationContext : JsonSerializerContext
{
}
Loading