diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6b034147..0ed319c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -141,6 +141,7 @@ jobs: run: | ./test/Docker.DotNet.Tests/bin/Release/${{ matrix.dotnet.tfm }}/linux-x64/publish/Docker.DotNet.Tests ./test/Docker.DotNet.TestsV2/bin/Release/${{ matrix.dotnet.tfm }}/linux-x64/publish/Docker.DotNet.TestsV2 + ./test/Docker.DotNet.Tests.StrictJson/bin/Release/${{ matrix.dotnet.tfm }}/linux-x64/publish/Docker.DotNet.Tests.StrictJson env: DOCKER_HOST: ${{ matrix.docker.docker_host }} DOCKER_TLS_VERIFY: ${{ matrix.docker.tls_verify }} diff --git a/Docker.DotNet.slnx b/Docker.DotNet.slnx index 89c36932..e7facdc8 100644 --- a/Docker.DotNet.slnx +++ b/Docker.DotNet.slnx @@ -21,6 +21,7 @@ + diff --git a/README.md b/README.md index 56e696b9..20bbaa8b 100644 --- a/README.md +++ b/README.md @@ -323,6 +323,21 @@ var client = new DockerClientBuilder() .Build(); ``` +### Strict JSON deserialization + +Docker-compatible container runtimes and older Docker Engine versions do not always send what the Docker Engine API declares. +That is why the client ignores the global System.Text.Json `RespectNullableAnnotationsDefault` and `RespectRequiredConstructorParametersDefault` feature switches and deserializes responses leniently. +On .NET 9 and later, you can opt in to strict deserialization with the client's own switches: + +```xml + + + + +``` + +The switches apply to the whole process and are read once. If you set them with `AppContext.SetSwitch` instead, call it before you create the first client. + ### Error Handling Here are typical exceptions thrown from the client library: diff --git a/src/Docker.DotNet/Docker.DotNet.csproj b/src/Docker.DotNet/Docker.DotNet.csproj index 06b038af..15c789a4 100644 --- a/src/Docker.DotNet/Docker.DotNet.csproj +++ b/src/Docker.DotNet/Docker.DotNet.csproj @@ -25,6 +25,7 @@ + diff --git a/src/Docker.DotNet/JsonSerializer.cs b/src/Docker.DotNet/JsonSerializer.cs index 8a4fb964..d8ed9d43 100644 --- a/src/Docker.DotNet/JsonSerializer.cs +++ b/src/Docker.DotNet/JsonSerializer.cs @@ -23,6 +23,19 @@ private JsonSerializer() _options.Converters.Add(new JsonEnumMemberConverter()); _options.Converters.Add(new JsonDateTimeConverter()); _options.Converters.Add(new JsonTimeSpanNanosecondsConverter()); +#if NET9_0_OR_GREATER + // Docker-compatible container runtimes do not always send what the Docker + // Engine API declares. Ignore the global System.Text.Json feature switches + // and enable strict deserialization only on explicit opt-in: + // https://github.com/testcontainers/Docker.DotNet/issues/129 + _options.RespectNullableAnnotations = IsSwitchEnabled("Docker.DotNet.Serialization.RespectNullableAnnotations"); + _options.RespectRequiredConstructorParameters = IsSwitchEnabled("Docker.DotNet.Serialization.RespectRequiredConstructorParameters"); +#else + // Applications can upgrade to System.Text.Json 9.0 or later, which honors + // the global feature switches, too. Disable the options if they exist. + typeof(JsonSerializerOptions).GetProperty("RespectNullableAnnotations")?.SetValue(_options, false); + typeof(JsonSerializerOptions).GetProperty("RespectRequiredConstructorParameters")?.SetValue(_options, false); +#endif _options.MakeReadOnly(); } @@ -98,6 +111,13 @@ public async IAsyncEnumerable DeserializeAsync(Stream stream, [EnumeratorC await reader.CompleteAsync(); } +#if NET9_0_OR_GREATER + private static bool IsSwitchEnabled(string switchName) + { + return AppContext.TryGetSwitch(switchName, out var isEnabled) && isEnabled; + } +#endif + private static bool TryParseJson(ref ReadOnlySequence buffer, out JsonDocument? jsonDocument) { var reader = new Utf8JsonReader(buffer, isFinalBlock: false, default); diff --git a/src/Docker.DotNet/Models/Actor.Generated.cs b/src/Docker.DotNet/Models/Actor.Generated.cs index 36343edd..d0364284 100644 --- a/src/Docker.DotNet/Models/Actor.Generated.cs +++ b/src/Docker.DotNet/Models/Actor.Generated.cs @@ -14,6 +14,6 @@ public class Actor // (events.Actor) public string ID { get; set; } = string.Empty; [JsonPropertyName("Attributes")] - public IDictionary Attributes { get; set; } = default!; + public IDictionary? Attributes { get; set; } } } diff --git a/src/Docker.DotNet/Models/Annotations.Generated.cs b/src/Docker.DotNet/Models/Annotations.Generated.cs index 272c1bce..f9e81841 100644 --- a/src/Docker.DotNet/Models/Annotations.Generated.cs +++ b/src/Docker.DotNet/Models/Annotations.Generated.cs @@ -10,6 +10,6 @@ public class Annotations // (swarm.Annotations) public string? Name { get; set; } [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } } } diff --git a/src/Docker.DotNet/Models/BlkioStats.Generated.cs b/src/Docker.DotNet/Models/BlkioStats.Generated.cs index 5213823f..f53dcdf1 100644 --- a/src/Docker.DotNet/Models/BlkioStats.Generated.cs +++ b/src/Docker.DotNet/Models/BlkioStats.Generated.cs @@ -13,27 +13,27 @@ public class BlkioStats // (container.BlkioStats) /// number of bytes transferred to and from the block device /// [JsonPropertyName("io_service_bytes_recursive")] - public IList IoServiceBytesRecursive { get; set; } = default!; + public IList? IoServiceBytesRecursive { get; set; } [JsonPropertyName("io_serviced_recursive")] - public IList IoServicedRecursive { get; set; } = default!; + public IList? IoServicedRecursive { get; set; } [JsonPropertyName("io_queue_recursive")] - public IList IoQueuedRecursive { get; set; } = default!; + public IList? IoQueuedRecursive { get; set; } [JsonPropertyName("io_service_time_recursive")] - public IList IoServiceTimeRecursive { get; set; } = default!; + public IList? IoServiceTimeRecursive { get; set; } [JsonPropertyName("io_wait_time_recursive")] - public IList IoWaitTimeRecursive { get; set; } = default!; + public IList? IoWaitTimeRecursive { get; set; } [JsonPropertyName("io_merged_recursive")] - public IList IoMergedRecursive { get; set; } = default!; + public IList? IoMergedRecursive { get; set; } [JsonPropertyName("io_time_recursive")] - public IList IoTimeRecursive { get; set; } = default!; + public IList? IoTimeRecursive { get; set; } [JsonPropertyName("sectors_recursive")] - public IList SectorsRecursive { get; set; } = default!; + public IList? SectorsRecursive { get; set; } } } diff --git a/src/Docker.DotNet/Models/ClusterInfo.Generated.cs b/src/Docker.DotNet/Models/ClusterInfo.Generated.cs index 57a3df54..9466d4b3 100644 --- a/src/Docker.DotNet/Models/ClusterInfo.Generated.cs +++ b/src/Docker.DotNet/Models/ClusterInfo.Generated.cs @@ -43,7 +43,7 @@ public ClusterInfo(Meta Meta) public bool RootRotationInProgress { get; set; } = default!; [JsonPropertyName("DefaultAddrPool")] - public IList DefaultAddrPool { get; set; } = default!; + public IList? DefaultAddrPool { get; set; } [JsonPropertyName("SubnetSize")] public uint SubnetSize { get; set; } = default!; diff --git a/src/Docker.DotNet/Models/CommitContainerChangesParameters.Generated.cs b/src/Docker.DotNet/Models/CommitContainerChangesParameters.Generated.cs index 754ed822..b3b915ef 100644 --- a/src/Docker.DotNet/Models/CommitContainerChangesParameters.Generated.cs +++ b/src/Docker.DotNet/Models/CommitContainerChangesParameters.Generated.cs @@ -123,13 +123,13 @@ public CommitContainerChangesParameters(ContainerConfig Config) /// List of environment variable to set in the container /// [JsonPropertyName("Env")] - public IList Env { get; set; } = default!; + public IList? Env { get; set; } /// /// Command to run when starting the container /// [JsonPropertyName("Cmd")] - public IList Cmd { get; set; } = default!; + public IList? Cmd { get; set; } /// /// Healthcheck describes how to check the container is healthy @@ -153,7 +153,7 @@ public CommitContainerChangesParameters(ContainerConfig Config) /// List of volumes (mounts) used for the container /// [JsonPropertyName("Volumes")] - public IDictionary Volumes { get; set; } = default!; + public IDictionary? Volumes { get; set; } /// /// Current directory (PWD) in the command will be launched @@ -165,7 +165,7 @@ public CommitContainerChangesParameters(ContainerConfig Config) /// Entrypoint to run when starting the container /// [JsonPropertyName("Entrypoint")] - public IList Entrypoint { get; set; } = default!; + public IList? Entrypoint { get; set; } /// /// Is network disabled @@ -183,7 +183,7 @@ public CommitContainerChangesParameters(ContainerConfig Config) /// List of labels set to this container /// [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } /// /// Signal to stop a container diff --git a/src/Docker.DotNet/Models/ContainerConfig.Generated.cs b/src/Docker.DotNet/Models/ContainerConfig.Generated.cs index 098afeb2..d12ea1ce 100644 --- a/src/Docker.DotNet/Models/ContainerConfig.Generated.cs +++ b/src/Docker.DotNet/Models/ContainerConfig.Generated.cs @@ -75,13 +75,13 @@ public class ContainerConfig // (container.Config) /// List of environment variable to set in the container /// [JsonPropertyName("Env")] - public IList Env { get; set; } = default!; + public IList? Env { get; set; } /// /// Command to run when starting the container /// [JsonPropertyName("Cmd")] - public IList Cmd { get; set; } = default!; + public IList? Cmd { get; set; } /// /// Healthcheck describes how to check the container is healthy @@ -105,7 +105,7 @@ public class ContainerConfig // (container.Config) /// List of volumes (mounts) used for the container /// [JsonPropertyName("Volumes")] - public IDictionary Volumes { get; set; } = default!; + public IDictionary? Volumes { get; set; } /// /// Current directory (PWD) in the command will be launched @@ -117,7 +117,7 @@ public class ContainerConfig // (container.Config) /// Entrypoint to run when starting the container /// [JsonPropertyName("Entrypoint")] - public IList Entrypoint { get; set; } = default!; + public IList? Entrypoint { get; set; } /// /// Is network disabled @@ -135,7 +135,7 @@ public class ContainerConfig // (container.Config) /// List of labels set to this container /// [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } /// /// Signal to stop a container diff --git a/src/Docker.DotNet/Models/ContainerExecCreateParameters.Generated.cs b/src/Docker.DotNet/Models/ContainerExecCreateParameters.Generated.cs index 299349c9..a6f2272e 100644 --- a/src/Docker.DotNet/Models/ContainerExecCreateParameters.Generated.cs +++ b/src/Docker.DotNet/Models/ContainerExecCreateParameters.Generated.cs @@ -29,12 +29,12 @@ public class ContainerExecCreateParameters // (main.ContainerExecCreateParameter public string DetachKeys { get; set; } = string.Empty; [JsonPropertyName("Env")] - public IList Env { get; set; } = default!; + public IList? Env { get; set; } [JsonPropertyName("WorkingDir")] public string WorkingDir { get; set; } = string.Empty; [JsonPropertyName("Cmd")] - public IList Cmd { get; set; } = default!; + public IList? Cmd { get; set; } } } diff --git a/src/Docker.DotNet/Models/ContainerExecInspectResponse.Generated.cs b/src/Docker.DotNet/Models/ContainerExecInspectResponse.Generated.cs index 97260487..52183c68 100644 --- a/src/Docker.DotNet/Models/ContainerExecInspectResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ContainerExecInspectResponse.Generated.cs @@ -35,7 +35,7 @@ public class ContainerExecInspectResponse // (container.ExecInspectResponse) public string ContainerID { get; set; } = string.Empty; [JsonPropertyName("DetachKeys")] - public string DetachKeys { get; set; } = string.Empty; + public string? DetachKeys { get; set; } [JsonPropertyName("Pid")] public long Pid { get; set; } = default!; diff --git a/src/Docker.DotNet/Models/ContainerInspectResponse.Generated.cs b/src/Docker.DotNet/Models/ContainerInspectResponse.Generated.cs index 1e0979f1..3cfc4b3e 100644 --- a/src/Docker.DotNet/Models/ContainerInspectResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ContainerInspectResponse.Generated.cs @@ -17,7 +17,7 @@ public class ContainerInspectResponse // (container.InspectResponse) public string Path { get; set; } = string.Empty; [JsonPropertyName("Args")] - public IList Args { get; set; } = default!; + public IList? Args { get; set; } [JsonPropertyName("State")] public State? State { get; set; } @@ -59,7 +59,7 @@ public class ContainerInspectResponse // (container.InspectResponse) public string AppArmorProfile { get; set; } = string.Empty; [JsonPropertyName("ExecIDs")] - public IList ExecIDs { get; set; } = default!; + public IList? ExecIDs { get; set; } [JsonPropertyName("HostConfig")] public HostConfig? HostConfig { get; set; } @@ -83,7 +83,7 @@ public class ContainerInspectResponse // (container.InspectResponse) public long? SizeRootFs { get; set; } [JsonPropertyName("Mounts")] - public IList Mounts { get; set; } = default!; + public IList? Mounts { get; set; } [JsonPropertyName("Config")] public ContainerConfig? Config { get; set; } diff --git a/src/Docker.DotNet/Models/ContainerListResponse.Generated.cs b/src/Docker.DotNet/Models/ContainerListResponse.Generated.cs index ddb62119..03714345 100644 --- a/src/Docker.DotNet/Models/ContainerListResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ContainerListResponse.Generated.cs @@ -11,7 +11,7 @@ public class ContainerListResponse // (container.Summary) public string ID { get; set; } = string.Empty; [JsonPropertyName("Names")] - public IList Names { get; set; } = default!; + public IList? Names { get; set; } [JsonPropertyName("Image")] public string Image { get; set; } = string.Empty; @@ -29,7 +29,7 @@ public class ContainerListResponse // (container.Summary) public DateTime Created { get; set; } = default!; [JsonPropertyName("Ports")] - public IList Ports { get; set; } = default!; + public IList? Ports { get; set; } [JsonPropertyName("SizeRw")] public long? SizeRw { get; set; } @@ -38,7 +38,7 @@ public class ContainerListResponse // (container.Summary) public long? SizeRootFs { get; set; } [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } [JsonPropertyName("State")] public string State { get; set; } = string.Empty; @@ -56,6 +56,6 @@ public class ContainerListResponse // (container.Summary) public NetworkSettingsSummary? NetworkSettings { get; set; } [JsonPropertyName("Mounts")] - public IList Mounts { get; set; } = default!; + public IList? Mounts { get; set; } } } diff --git a/src/Docker.DotNet/Models/ContainerProcessesResponse.Generated.cs b/src/Docker.DotNet/Models/ContainerProcessesResponse.Generated.cs index 3c4f1940..fd6b299f 100644 --- a/src/Docker.DotNet/Models/ContainerProcessesResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ContainerProcessesResponse.Generated.cs @@ -16,13 +16,13 @@ public class ContainerProcessesResponse // (container.TopResponse) /// Example: {"Processes":[["root","13642","882","0","17:03","pts/0","00:00:00","/bin/bash"],["root","13735","13642","0","17:06","pts/0","00:00:00","sleep 10"]]} /// [JsonPropertyName("Processes")] - public IList> Processes { get; set; } = default!; + public IList>? Processes { get; set; } /// /// The ps column titles /// Example: {"Titles":["UID","PID","PPID","C","STIME","TTY","TIME","CMD"]} /// [JsonPropertyName("Titles")] - public IList Titles { get; set; } = default!; + public IList? Titles { get; set; } } } diff --git a/src/Docker.DotNet/Models/ContainerUpdateParameters.Generated.cs b/src/Docker.DotNet/Models/ContainerUpdateParameters.Generated.cs index 8f93e143..57595b1e 100644 --- a/src/Docker.DotNet/Models/ContainerUpdateParameters.Generated.cs +++ b/src/Docker.DotNet/Models/ContainerUpdateParameters.Generated.cs @@ -75,19 +75,19 @@ public ContainerUpdateParameters(UpdateConfig UpdateConfig) public ushort BlkioWeight { get; set; } = default!; [JsonPropertyName("BlkioWeightDevice")] - public IList BlkioWeightDevice { get; set; } = default!; + public IList? BlkioWeightDevice { get; set; } [JsonPropertyName("BlkioDeviceReadBps")] - public IList BlkioDeviceReadBps { get; set; } = default!; + public IList? BlkioDeviceReadBps { get; set; } [JsonPropertyName("BlkioDeviceWriteBps")] - public IList BlkioDeviceWriteBps { get; set; } = default!; + public IList? BlkioDeviceWriteBps { get; set; } [JsonPropertyName("BlkioDeviceReadIOps")] - public IList BlkioDeviceReadIOps { get; set; } = default!; + public IList? BlkioDeviceReadIOps { get; set; } [JsonPropertyName("BlkioDeviceWriteIOps")] - public IList BlkioDeviceWriteIOps { get; set; } = default!; + public IList? BlkioDeviceWriteIOps { get; set; } /// /// CPU CFS (Completely Fair Scheduler) period @@ -129,19 +129,19 @@ public ContainerUpdateParameters(UpdateConfig UpdateConfig) /// List of devices to map inside the container /// [JsonPropertyName("Devices")] - public IList Devices { get; set; } = default!; + public IList? Devices { get; set; } /// /// List of rule to be added to the device cgroup /// [JsonPropertyName("DeviceCgroupRules")] - public IList DeviceCgroupRules { get; set; } = default!; + public IList? DeviceCgroupRules { get; set; } /// /// List of device requests for device drivers /// [JsonPropertyName("DeviceRequests")] - public IList DeviceRequests { get; set; } = default!; + public IList? DeviceRequests { get; set; } /// /// Memory soft limit (in bytes) @@ -177,7 +177,7 @@ public ContainerUpdateParameters(UpdateConfig UpdateConfig) /// List of ulimits to be set in the container /// [JsonPropertyName("Ulimits")] - public IList Ulimits { get; set; } = default!; + public IList? Ulimits { get; set; } /// /// Applicable to Windows diff --git a/src/Docker.DotNet/Models/ContainerUpdateResponse.Generated.cs b/src/Docker.DotNet/Models/ContainerUpdateResponse.Generated.cs index 1dcf5204..3de2888e 100644 --- a/src/Docker.DotNet/Models/ContainerUpdateResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ContainerUpdateResponse.Generated.cs @@ -4,6 +4,6 @@ namespace Docker.DotNet.Models public class ContainerUpdateResponse // (main.ContainerUpdateResponse) { [JsonPropertyName("Warnings")] - public IList Warnings { get; set; } = default!; + public IList? Warnings { get; set; } } } diff --git a/src/Docker.DotNet/Models/ContainersPruneResponse.Generated.cs b/src/Docker.DotNet/Models/ContainersPruneResponse.Generated.cs index 2ed63e0a..3dcdcfc3 100644 --- a/src/Docker.DotNet/Models/ContainersPruneResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ContainersPruneResponse.Generated.cs @@ -8,7 +8,7 @@ namespace Docker.DotNet.Models public class ContainersPruneResponse // (container.PruneReport) { [JsonPropertyName("ContainersDeleted")] - public IList ContainersDeleted { get; set; } = default!; + public IList? ContainersDeleted { get; set; } [JsonPropertyName("SpaceReclaimed")] public ulong SpaceReclaimed { get; set; } = default!; diff --git a/src/Docker.DotNet/Models/CreateContainerParameters.Generated.cs b/src/Docker.DotNet/Models/CreateContainerParameters.Generated.cs index b4a79abd..e84b0e43 100644 --- a/src/Docker.DotNet/Models/CreateContainerParameters.Generated.cs +++ b/src/Docker.DotNet/Models/CreateContainerParameters.Generated.cs @@ -108,13 +108,13 @@ public CreateContainerParameters(ContainerConfig Config) /// List of environment variable to set in the container /// [JsonPropertyName("Env")] - public IList Env { get; set; } = default!; + public IList? Env { get; set; } /// /// Command to run when starting the container /// [JsonPropertyName("Cmd")] - public IList Cmd { get; set; } = default!; + public IList? Cmd { get; set; } /// /// Healthcheck describes how to check the container is healthy @@ -138,7 +138,7 @@ public CreateContainerParameters(ContainerConfig Config) /// List of volumes (mounts) used for the container /// [JsonPropertyName("Volumes")] - public IDictionary Volumes { get; set; } = default!; + public IDictionary? Volumes { get; set; } /// /// Current directory (PWD) in the command will be launched @@ -150,7 +150,7 @@ public CreateContainerParameters(ContainerConfig Config) /// Entrypoint to run when starting the container /// [JsonPropertyName("Entrypoint")] - public IList Entrypoint { get; set; } = default!; + public IList? Entrypoint { get; set; } /// /// Is network disabled @@ -168,7 +168,7 @@ public CreateContainerParameters(ContainerConfig Config) /// List of labels set to this container /// [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } /// /// Signal to stop a container diff --git a/src/Docker.DotNet/Models/CreateContainerResponse.Generated.cs b/src/Docker.DotNet/Models/CreateContainerResponse.Generated.cs index 9b11e0ef..4cfc9799 100644 --- a/src/Docker.DotNet/Models/CreateContainerResponse.Generated.cs +++ b/src/Docker.DotNet/Models/CreateContainerResponse.Generated.cs @@ -24,6 +24,6 @@ public class CreateContainerResponse // (container.CreateResponse) /// Required: true /// [JsonPropertyName("Warnings")] - public IList Warnings { get; set; } = default!; + public IList? Warnings { get; set; } } } diff --git a/src/Docker.DotNet/Models/DeviceRequest.Generated.cs b/src/Docker.DotNet/Models/DeviceRequest.Generated.cs index d9527bf6..f06584bc 100644 --- a/src/Docker.DotNet/Models/DeviceRequest.Generated.cs +++ b/src/Docker.DotNet/Models/DeviceRequest.Generated.cs @@ -23,18 +23,18 @@ public class DeviceRequest // (container.DeviceRequest) /// List of device IDs as recognizable by the device driver /// [JsonPropertyName("DeviceIDs")] - public IList DeviceIDs { get; set; } = default!; + public IList? DeviceIDs { get; set; } /// /// An OR list of AND lists of device capabilities (e.g. "gpu") /// [JsonPropertyName("Capabilities")] - public IList> Capabilities { get; set; } = default!; + public IList>? Capabilities { get; set; } /// /// Options to pass onto the device driver /// [JsonPropertyName("Options")] - public IDictionary Options { get; set; } = default!; + public IDictionary? Options { get; set; } } } diff --git a/src/Docker.DotNet/Models/DistributionInspectResponse.Generated.cs b/src/Docker.DotNet/Models/DistributionInspectResponse.Generated.cs index 081ba156..291312e4 100644 --- a/src/Docker.DotNet/Models/DistributionInspectResponse.Generated.cs +++ b/src/Docker.DotNet/Models/DistributionInspectResponse.Generated.cs @@ -19,6 +19,6 @@ public class DistributionInspectResponse // (registry.DistributionInspect) /// obtained by parsing the manifest /// [JsonPropertyName("Platforms")] - public IList Platforms { get; set; } = default!; + public IList? Platforms { get; set; } } } diff --git a/src/Docker.DotNet/Models/DriverData.Generated.cs b/src/Docker.DotNet/Models/DriverData.Generated.cs index 99efd932..35e71dc8 100644 --- a/src/Docker.DotNet/Models/DriverData.Generated.cs +++ b/src/Docker.DotNet/Models/DriverData.Generated.cs @@ -19,7 +19,7 @@ public class DriverData // (storage.DriverData) /// Required: true /// [JsonPropertyName("Data")] - public IDictionary Data { get; set; } = default!; + public IDictionary? Data { get; set; } /// /// Name of the storage driver. diff --git a/src/Docker.DotNet/Models/EndpointIPAMConfig.Generated.cs b/src/Docker.DotNet/Models/EndpointIPAMConfig.Generated.cs index e6d1ea2d..8e565e17 100644 --- a/src/Docker.DotNet/Models/EndpointIPAMConfig.Generated.cs +++ b/src/Docker.DotNet/Models/EndpointIPAMConfig.Generated.cs @@ -7,10 +7,10 @@ namespace Docker.DotNet.Models public class EndpointIPAMConfig // (network.EndpointIPAMConfig) { [JsonPropertyName("IPv4Address")] - public string IPv4Address { get; set; } = string.Empty; + public string? IPv4Address { get; set; } [JsonPropertyName("IPv6Address")] - public string IPv6Address { get; set; } = string.Empty; + public string? IPv6Address { get; set; } [JsonPropertyName("LinkLocalIPs")] public IList? LinkLocalIPs { get; set; } diff --git a/src/Docker.DotNet/Models/EndpointSettings.Generated.cs b/src/Docker.DotNet/Models/EndpointSettings.Generated.cs index de0c1548..d95a8124 100644 --- a/src/Docker.DotNet/Models/EndpointSettings.Generated.cs +++ b/src/Docker.DotNet/Models/EndpointSettings.Generated.cs @@ -13,16 +13,16 @@ public class EndpointSettings // (network.EndpointSettings) public EndpointIPAMConfig? IPAMConfig { get; set; } [JsonPropertyName("Links")] - public IList Links { get; set; } = default!; + public IList? Links { get; set; } /// /// Aliases holds the list of extra, user-specified DNS names for this endpoint. /// [JsonPropertyName("Aliases")] - public IList Aliases { get; set; } = default!; + public IList? Aliases { get; set; } [JsonPropertyName("DriverOpts")] - public IDictionary DriverOpts { get; set; } = default!; + public IDictionary? DriverOpts { get; set; } /// /// GwPriority determines which endpoint will provide the default gateway @@ -70,6 +70,6 @@ public class EndpointSettings // (network.EndpointSettings) /// endpoint. The first entry is used to generate PTR records. /// [JsonPropertyName("DNSNames")] - public IList DNSNames { get; set; } = default!; + public IList? DNSNames { get; set; } } } diff --git a/src/Docker.DotNet/Models/EndpointVirtualIP.Generated.cs b/src/Docker.DotNet/Models/EndpointVirtualIP.Generated.cs index cd7fd9a4..10c71ccb 100644 --- a/src/Docker.DotNet/Models/EndpointVirtualIP.Generated.cs +++ b/src/Docker.DotNet/Models/EndpointVirtualIP.Generated.cs @@ -15,6 +15,6 @@ public class EndpointVirtualIP // (swarm.EndpointVirtualIP) /// compatibility, but only the IP address is used. /// [JsonPropertyName("Addr")] - public string Addr { get; set; } = string.Empty; + public string? Addr { get; set; } } } diff --git a/src/Docker.DotNet/Models/ExecProcessConfig.Generated.cs b/src/Docker.DotNet/Models/ExecProcessConfig.Generated.cs index 6722dcf6..30a89998 100644 --- a/src/Docker.DotNet/Models/ExecProcessConfig.Generated.cs +++ b/src/Docker.DotNet/Models/ExecProcessConfig.Generated.cs @@ -14,7 +14,7 @@ public class ExecProcessConfig // (container.ExecProcessConfig) public string Entrypoint { get; set; } = string.Empty; [JsonPropertyName("arguments")] - public IList Arguments { get; set; } = default!; + public IList? Arguments { get; set; } [JsonPropertyName("privileged")] public bool? Privileged { get; set; } diff --git a/src/Docker.DotNet/Models/Health.Generated.cs b/src/Docker.DotNet/Models/Health.Generated.cs index fc8f6d7b..f7a9235a 100644 --- a/src/Docker.DotNet/Models/Health.Generated.cs +++ b/src/Docker.DotNet/Models/Health.Generated.cs @@ -22,6 +22,6 @@ public class Health // (container.Health) /// Log contains the last few results (oldest first) /// [JsonPropertyName("Log")] - public IList Log { get; set; } = default!; + public IList? Log { get; set; } } } diff --git a/src/Docker.DotNet/Models/HostConfig.Generated.cs b/src/Docker.DotNet/Models/HostConfig.Generated.cs index 1e28345c..a404c6f2 100644 --- a/src/Docker.DotNet/Models/HostConfig.Generated.cs +++ b/src/Docker.DotNet/Models/HostConfig.Generated.cs @@ -52,7 +52,7 @@ public HostConfig(Resources Resources) /// Applicable to all platforms /// [JsonPropertyName("Binds")] - public IList Binds { get; set; } = default!; + public IList? Binds { get; set; } /// /// File (path) where the containerId is written @@ -76,7 +76,7 @@ public HostConfig(Resources Resources) /// Port mapping between the exposed port (container) and the host /// [JsonPropertyName("PortBindings")] - public IDictionary> PortBindings { get; set; } = default!; + public IDictionary>? PortBindings { get; set; } /// /// Restart policy to be used for the container @@ -100,7 +100,7 @@ public HostConfig(Resources Resources) /// List of volumes to take from other container /// [JsonPropertyName("VolumesFrom")] - public IList VolumesFrom { get; set; } = default!; + public IList? VolumesFrom { get; set; } /// /// Initial console size (height,width) @@ -119,13 +119,13 @@ public HostConfig(Resources Resources) /// Applicable to UNIX platforms /// [JsonPropertyName("CapAdd")] - public IList CapAdd { get; set; } = default!; + public IList? CapAdd { get; set; } /// /// List of kernel capabilities to remove from the container /// [JsonPropertyName("CapDrop")] - public IList CapDrop { get; set; } = default!; + public IList? CapDrop { get; set; } /// /// Cgroup namespace mode to use for the container @@ -137,31 +137,31 @@ public HostConfig(Resources Resources) /// List of DNS server to lookup /// [JsonPropertyName("Dns")] - public IList DNS { get; set; } = default!; + public IList? DNS { get; set; } /// /// List of DNSOption to look for /// [JsonPropertyName("DnsOptions")] - public IList DNSOptions { get; set; } = default!; + public IList? DNSOptions { get; set; } /// /// List of DNSSearch to look for /// [JsonPropertyName("DnsSearch")] - public IList DNSSearch { get; set; } = default!; + public IList? DNSSearch { get; set; } /// /// List of extra hosts /// [JsonPropertyName("ExtraHosts")] - public IList ExtraHosts { get; set; } = default!; + public IList? ExtraHosts { get; set; } /// /// List of additional groups that the container process will run as /// [JsonPropertyName("GroupAdd")] - public IList GroupAdd { get; set; } = default!; + public IList? GroupAdd { get; set; } /// /// IPC namespace to use for the container @@ -179,7 +179,7 @@ public HostConfig(Resources Resources) /// List of links (in the name:alias form) /// [JsonPropertyName("Links")] - public IList Links { get; set; } = default!; + public IList? Links { get; set; } /// /// Container preference for OOM-killing @@ -215,7 +215,7 @@ public HostConfig(Resources Resources) /// List of string values to customize labels for MLS systems, such as SELinux. /// [JsonPropertyName("SecurityOpt")] - public IList SecurityOpt { get; set; } = default!; + public IList? SecurityOpt { get; set; } /// /// Storage driver options per container. @@ -302,19 +302,19 @@ public HostConfig(Resources Resources) public ushort BlkioWeight { get; set; } = default!; [JsonPropertyName("BlkioWeightDevice")] - public IList BlkioWeightDevice { get; set; } = default!; + public IList? BlkioWeightDevice { get; set; } [JsonPropertyName("BlkioDeviceReadBps")] - public IList BlkioDeviceReadBps { get; set; } = default!; + public IList? BlkioDeviceReadBps { get; set; } [JsonPropertyName("BlkioDeviceWriteBps")] - public IList BlkioDeviceWriteBps { get; set; } = default!; + public IList? BlkioDeviceWriteBps { get; set; } [JsonPropertyName("BlkioDeviceReadIOps")] - public IList BlkioDeviceReadIOps { get; set; } = default!; + public IList? BlkioDeviceReadIOps { get; set; } [JsonPropertyName("BlkioDeviceWriteIOps")] - public IList BlkioDeviceWriteIOps { get; set; } = default!; + public IList? BlkioDeviceWriteIOps { get; set; } /// /// CPU CFS (Completely Fair Scheduler) period @@ -356,19 +356,19 @@ public HostConfig(Resources Resources) /// List of devices to map inside the container /// [JsonPropertyName("Devices")] - public IList Devices { get; set; } = default!; + public IList? Devices { get; set; } /// /// List of rule to be added to the device cgroup /// [JsonPropertyName("DeviceCgroupRules")] - public IList DeviceCgroupRules { get; set; } = default!; + public IList? DeviceCgroupRules { get; set; } /// /// List of device requests for device drivers /// [JsonPropertyName("DeviceRequests")] - public IList DeviceRequests { get; set; } = default!; + public IList? DeviceRequests { get; set; } /// /// Memory soft limit (in bytes) @@ -404,7 +404,7 @@ public HostConfig(Resources Resources) /// List of ulimits to be set in the container /// [JsonPropertyName("Ulimits")] - public IList Ulimits { get; set; } = default!; + public IList? Ulimits { get; set; } /// /// Applicable to Windows @@ -440,13 +440,13 @@ public HostConfig(Resources Resources) /// MaskedPaths is the list of paths to be masked inside the container (this overrides the default set of paths) /// [JsonPropertyName("MaskedPaths")] - public IList MaskedPaths { get; set; } = default!; + public IList? MaskedPaths { get; set; } /// /// ReadonlyPaths is the list of paths to be set as read-only inside the container (this overrides the default set of paths) /// [JsonPropertyName("ReadonlyPaths")] - public IList ReadonlyPaths { get; set; } = default!; + public IList? ReadonlyPaths { get; set; } /// /// Run a custom init inside the container, if null, use the daemon's configured settings diff --git a/src/Docker.DotNet/Models/IPAM.Generated.cs b/src/Docker.DotNet/Models/IPAM.Generated.cs index 3aaf794c..a9d33d69 100644 --- a/src/Docker.DotNet/Models/IPAM.Generated.cs +++ b/src/Docker.DotNet/Models/IPAM.Generated.cs @@ -13,9 +13,9 @@ public class IPAM // (network.IPAM) /// Per network IPAM driver options /// [JsonPropertyName("Options")] - public IDictionary Options { get; set; } = default!; + public IDictionary? Options { get; set; } [JsonPropertyName("Config")] - public IList Config { get; set; } = default!; + public IList? Config { get; set; } } } diff --git a/src/Docker.DotNet/Models/IPAMConfig.Generated.cs b/src/Docker.DotNet/Models/IPAMConfig.Generated.cs index 5276609a..7262ff9c 100644 --- a/src/Docker.DotNet/Models/IPAMConfig.Generated.cs +++ b/src/Docker.DotNet/Models/IPAMConfig.Generated.cs @@ -7,13 +7,13 @@ namespace Docker.DotNet.Models public class IPAMConfig // (network.IPAMConfig) { [JsonPropertyName("Subnet")] - public string Subnet { get; set; } = string.Empty; + public string? Subnet { get; set; } [JsonPropertyName("IPRange")] - public string IPRange { get; set; } = string.Empty; + public string? IPRange { get; set; } [JsonPropertyName("Gateway")] - public string Gateway { get; set; } = string.Empty; + public string? Gateway { get; set; } [JsonPropertyName("AuxiliaryAddresses")] public IDictionary? AuxAddress { get; set; } diff --git a/src/Docker.DotNet/Models/Identity.Generated.cs b/src/Docker.DotNet/Models/Identity.Generated.cs index d249e7cf..fadc16f8 100644 --- a/src/Docker.DotNet/Models/Identity.Generated.cs +++ b/src/Docker.DotNet/Models/Identity.Generated.cs @@ -12,7 +12,7 @@ public class Identity // (image.Identity) /// Signature contains the properties of verified signatures for the image. /// [JsonPropertyName("Signature")] - public IList Signature { get; set; } = default!; + public IList? Signature { get; set; } /// /// Pull contains remote location information if image was created via pull. @@ -20,12 +20,12 @@ public class Identity // (image.Identity) /// After successful push this images also contains the pushed repository location. /// [JsonPropertyName("Pull")] - public IList Pull { get; set; } = default!; + public IList? Pull { get; set; } /// /// Build contains build reference information if image was created via build. /// [JsonPropertyName("Build")] - public IList Build { get; set; } = default!; + public IList? Build { get; set; } } } diff --git a/src/Docker.DotNet/Models/ImageBuildParameters.Generated.cs b/src/Docker.DotNet/Models/ImageBuildParameters.Generated.cs index 70480e7f..3208491f 100644 --- a/src/Docker.DotNet/Models/ImageBuildParameters.Generated.cs +++ b/src/Docker.DotNet/Models/ImageBuildParameters.Generated.cs @@ -79,6 +79,6 @@ public class ImageBuildParameters // (main.ImageBuildParameters) public string? Version { get; set; } [JsonPropertyName("AuthConfigs")] - public IDictionary AuthConfigs { get; set; } = default!; + public IDictionary? AuthConfigs { get; set; } } } diff --git a/src/Docker.DotNet/Models/ImageBuildResult.Generated.cs b/src/Docker.DotNet/Models/ImageBuildResult.Generated.cs index 5ec6570c..098728ae 100644 --- a/src/Docker.DotNet/Models/ImageBuildResult.Generated.cs +++ b/src/Docker.DotNet/Models/ImageBuildResult.Generated.cs @@ -9,6 +9,6 @@ namespace Docker.DotNet.Models public class ImageBuildResult // (client.ImageBuildResult) { [JsonPropertyName("Body")] - public object Body { get; set; } = default!; + public object? Body { get; set; } } } diff --git a/src/Docker.DotNet/Models/ImageHistoryResponse.Generated.cs b/src/Docker.DotNet/Models/ImageHistoryResponse.Generated.cs index 53842da6..db291f7d 100644 --- a/src/Docker.DotNet/Models/ImageHistoryResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ImageHistoryResponse.Generated.cs @@ -50,6 +50,6 @@ public class ImageHistoryResponse // (image.HistoryResponseItem) /// Required: true /// [JsonPropertyName("Tags")] - public IList Tags { get; set; } = default!; + public IList? Tags { get; set; } } } diff --git a/src/Docker.DotNet/Models/ImageInspectResponse.Generated.cs b/src/Docker.DotNet/Models/ImageInspectResponse.Generated.cs index 5d022f3f..3e098b8e 100644 --- a/src/Docker.DotNet/Models/ImageInspectResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ImageInspectResponse.Generated.cs @@ -29,7 +29,7 @@ public class ImageInspectResponse // (image.InspectResponse) /// "untagged", in which case it can still be referenced by its ID. /// [JsonPropertyName("RepoTags")] - public IList RepoTags { get; set; } = default!; + public IList? RepoTags { get; set; } /// /// RepoDigests is a list of content-addressable digests of locally available @@ -41,7 +41,7 @@ public class ImageInspectResponse // (image.InspectResponse) /// the manifest is generated and its digest calculated. /// [JsonPropertyName("RepoDigests")] - public IList RepoDigests { get; set; } = default!; + public IList? RepoDigests { get; set; } /// /// Comment is an optional message that can be set when committing or diff --git a/src/Docker.DotNet/Models/ImageProperties.Generated.cs b/src/Docker.DotNet/Models/ImageProperties.Generated.cs index 0a1c70ac..cf3b7f3a 100644 --- a/src/Docker.DotNet/Models/ImageProperties.Generated.cs +++ b/src/Docker.DotNet/Models/ImageProperties.Generated.cs @@ -29,6 +29,6 @@ public class ImageProperties // (image.ImageProperties) /// Required: true /// [JsonPropertyName("Containers")] - public IList Containers { get; set; } = default!; + public IList? Containers { get; set; } } } diff --git a/src/Docker.DotNet/Models/ImagesListResponse.Generated.cs b/src/Docker.DotNet/Models/ImagesListResponse.Generated.cs index 97cb5c19..fab0d0ce 100644 --- a/src/Docker.DotNet/Models/ImagesListResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ImagesListResponse.Generated.cs @@ -44,7 +44,7 @@ public class ImagesListResponse // (image.Summary) /// Required: true /// [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } /// /// ID of the parent image. @@ -91,7 +91,7 @@ public class ImagesListResponse // (image.Summary) /// Required: true /// [JsonPropertyName("RepoDigests")] - public IList RepoDigests { get; set; } = default!; + public IList? RepoDigests { get; set; } /// /// List of image names/tags in the local image cache that reference this @@ -104,7 +104,7 @@ public class ImagesListResponse // (image.Summary) /// Required: true /// [JsonPropertyName("RepoTags")] - public IList RepoTags { get; set; } = default!; + public IList? RepoTags { get; set; } /// /// Total size of image layers that are shared between this image and other diff --git a/src/Docker.DotNet/Models/ImagesPruneResponse.Generated.cs b/src/Docker.DotNet/Models/ImagesPruneResponse.Generated.cs index fbedfedb..aa41f66c 100644 --- a/src/Docker.DotNet/Models/ImagesPruneResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ImagesPruneResponse.Generated.cs @@ -8,7 +8,7 @@ namespace Docker.DotNet.Models public class ImagesPruneResponse // (image.PruneReport) { [JsonPropertyName("ImagesDeleted")] - public IList ImagesDeleted { get; set; } = default!; + public IList? ImagesDeleted { get; set; } [JsonPropertyName("SpaceReclaimed")] public ulong SpaceReclaimed { get; set; } = default!; diff --git a/src/Docker.DotNet/Models/IndexInfo.Generated.cs b/src/Docker.DotNet/Models/IndexInfo.Generated.cs index c7ce81b4..64377279 100644 --- a/src/Docker.DotNet/Models/IndexInfo.Generated.cs +++ b/src/Docker.DotNet/Models/IndexInfo.Generated.cs @@ -44,7 +44,7 @@ public class IndexInfo // (registry.IndexInfo) /// Mirrors is a list of mirrors, expressed as URIs /// [JsonPropertyName("Mirrors")] - public IList Mirrors { get; set; } = default!; + public IList? Mirrors { get; set; } /// /// Secure is set to false if the registry is part of the list of diff --git a/src/Docker.DotNet/Models/Info.Generated.cs b/src/Docker.DotNet/Models/Info.Generated.cs index ad49bf14..6dc5b00c 100644 --- a/src/Docker.DotNet/Models/Info.Generated.cs +++ b/src/Docker.DotNet/Models/Info.Generated.cs @@ -22,7 +22,7 @@ public class Info // (swarm.Info) public string Error { get; set; } = string.Empty; [JsonPropertyName("RemoteManagers")] - public IList RemoteManagers { get; set; } = default!; + public IList? RemoteManagers { get; set; } [JsonPropertyName("Nodes")] public long? Nodes { get; set; } diff --git a/src/Docker.DotNet/Models/LogConfig.Generated.cs b/src/Docker.DotNet/Models/LogConfig.Generated.cs index 1bb47793..2ff264be 100644 --- a/src/Docker.DotNet/Models/LogConfig.Generated.cs +++ b/src/Docker.DotNet/Models/LogConfig.Generated.cs @@ -10,6 +10,6 @@ public class LogConfig // (container.LogConfig) public string Type { get; set; } = string.Empty; [JsonPropertyName("Config")] - public IDictionary Config { get; set; } = default!; + public IDictionary? Config { get; set; } } } diff --git a/src/Docker.DotNet/Models/Network.Generated.cs b/src/Docker.DotNet/Models/Network.Generated.cs index 2ad1a659..19e112a0 100644 --- a/src/Docker.DotNet/Models/Network.Generated.cs +++ b/src/Docker.DotNet/Models/Network.Generated.cs @@ -120,7 +120,7 @@ public class Network // (network.Network) /// Example: {"com.docker.network.bridge.default_bridge":"true","com.docker.network.bridge.enable_icc":"true","com.docker.network.bridge.enable_ip_masquerade":"true","com.docker.network.bridge.host_binding_ipv4":"0.0.0.0","com.docker.network.bridge.name":"docker0","com.docker.network.driver.mtu":"1500"} /// [JsonPropertyName("Options")] - public IDictionary Options { get; set; } = default!; + public IDictionary? Options { get; set; } /// /// Metadata specific to the network being created. @@ -128,7 +128,7 @@ public class Network // (network.Network) /// Example: {"com.example.some-label":"some-value","com.example.some-other-label":"some-other-value"} /// [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } /// /// List of peer nodes for an overlay network. This field is only present diff --git a/src/Docker.DotNet/Models/NetworkResponse.Generated.cs b/src/Docker.DotNet/Models/NetworkResponse.Generated.cs index db68179e..c4ab7631 100644 --- a/src/Docker.DotNet/Models/NetworkResponse.Generated.cs +++ b/src/Docker.DotNet/Models/NetworkResponse.Generated.cs @@ -147,7 +147,7 @@ public NetworkResponse(Network Network) /// Example: {"com.docker.network.bridge.default_bridge":"true","com.docker.network.bridge.enable_icc":"true","com.docker.network.bridge.enable_ip_masquerade":"true","com.docker.network.bridge.host_binding_ipv4":"0.0.0.0","com.docker.network.bridge.name":"docker0","com.docker.network.driver.mtu":"1500"} /// [JsonPropertyName("Options")] - public IDictionary Options { get; set; } = default!; + public IDictionary? Options { get; set; } /// /// Metadata specific to the network being created. @@ -155,7 +155,7 @@ public NetworkResponse(Network Network) /// Example: {"com.example.some-label":"some-value","com.example.some-other-label":"some-other-value"} /// [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } /// /// List of peer nodes for an overlay network. This field is only present @@ -170,7 +170,7 @@ public NetworkResponse(Network Network) /// Example: {"19a4d5d687db25203351ed79d478946f861258f018fe384f229f2efa4b23513c":{"EndpointID":"628cadb8bcb92de107b2a1e516cbffe463e321f548feb37697cce00ad694f21a","IPv4Address":"172.19.0.2/16","IPv6Address":"","MacAddress":"02:42:ac:13:00:02","Name":"test"}} /// [JsonPropertyName("Containers")] - public IDictionary Containers { get; set; } = default!; + public IDictionary? Containers { get; set; } /// /// List of services using the network. This field is only present for diff --git a/src/Docker.DotNet/Models/NetworkSettings.Generated.cs b/src/Docker.DotNet/Models/NetworkSettings.Generated.cs index 533abeb9..8032f8ba 100644 --- a/src/Docker.DotNet/Models/NetworkSettings.Generated.cs +++ b/src/Docker.DotNet/Models/NetworkSettings.Generated.cs @@ -22,9 +22,9 @@ public class NetworkSettings // (container.NetworkSettings) /// Ports is a collection of [network.PortBinding] indexed by [network.Port] /// [JsonPropertyName("Ports")] - public IDictionary> Ports { get; set; } = default!; + public IDictionary>? Ports { get; set; } [JsonPropertyName("Networks")] - public IDictionary Networks { get; set; } = default!; + public IDictionary? Networks { get; set; } } } diff --git a/src/Docker.DotNet/Models/NetworkSettingsSummary.Generated.cs b/src/Docker.DotNet/Models/NetworkSettingsSummary.Generated.cs index 898ee823..6241a5c2 100644 --- a/src/Docker.DotNet/Models/NetworkSettingsSummary.Generated.cs +++ b/src/Docker.DotNet/Models/NetworkSettingsSummary.Generated.cs @@ -8,6 +8,6 @@ namespace Docker.DotNet.Models public class NetworkSettingsSummary // (container.NetworkSettingsSummary) { [JsonPropertyName("Networks")] - public IDictionary Networks { get; set; } = default!; + public IDictionary? Networks { get; set; } } } diff --git a/src/Docker.DotNet/Models/NetworkSpec.Generated.cs b/src/Docker.DotNet/Models/NetworkSpec.Generated.cs index 9a19c14d..4606c520 100644 --- a/src/Docker.DotNet/Models/NetworkSpec.Generated.cs +++ b/src/Docker.DotNet/Models/NetworkSpec.Generated.cs @@ -23,7 +23,7 @@ public NetworkSpec(Annotations Annotations) public string? Name { get; set; } [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } [JsonPropertyName("DriverConfiguration")] public SwarmDriver? DriverConfiguration { get; set; } diff --git a/src/Docker.DotNet/Models/NetworkTask.Generated.cs b/src/Docker.DotNet/Models/NetworkTask.Generated.cs index 9c5f0200..aaebb92e 100644 --- a/src/Docker.DotNet/Models/NetworkTask.Generated.cs +++ b/src/Docker.DotNet/Models/NetworkTask.Generated.cs @@ -30,6 +30,6 @@ public class NetworkTask // (network.Task) /// info /// [JsonPropertyName("Info")] - public IDictionary Info { get; set; } = default!; + public IDictionary? Info { get; set; } } } diff --git a/src/Docker.DotNet/Models/NetworkingConfig.Generated.cs b/src/Docker.DotNet/Models/NetworkingConfig.Generated.cs index f39341e8..021abf7e 100644 --- a/src/Docker.DotNet/Models/NetworkingConfig.Generated.cs +++ b/src/Docker.DotNet/Models/NetworkingConfig.Generated.cs @@ -11,6 +11,6 @@ public class NetworkingConfig // (network.NetworkingConfig) /// Endpoint configs for each connecting network /// [JsonPropertyName("EndpointsConfig")] - public IDictionary EndpointsConfig { get; set; } = default!; + public IDictionary? EndpointsConfig { get; set; } } } diff --git a/src/Docker.DotNet/Models/NetworksCreateParameters.Generated.cs b/src/Docker.DotNet/Models/NetworksCreateParameters.Generated.cs index fd2a57c2..9f6db35e 100644 --- a/src/Docker.DotNet/Models/NetworksCreateParameters.Generated.cs +++ b/src/Docker.DotNet/Models/NetworksCreateParameters.Generated.cs @@ -76,12 +76,12 @@ public class NetworksCreateParameters // (network.CreateRequest) /// Options specifies the network-specific options to use for when creating the network. /// [JsonPropertyName("Options")] - public IDictionary Options { get; set; } = default!; + public IDictionary? Options { get; set; } /// /// Labels holds metadata specific to the network being created. /// [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } } } diff --git a/src/Docker.DotNet/Models/NetworksPruneResponse.Generated.cs b/src/Docker.DotNet/Models/NetworksPruneResponse.Generated.cs index 876428d5..75df1351 100644 --- a/src/Docker.DotNet/Models/NetworksPruneResponse.Generated.cs +++ b/src/Docker.DotNet/Models/NetworksPruneResponse.Generated.cs @@ -8,6 +8,6 @@ namespace Docker.DotNet.Models public class NetworksPruneResponse // (network.PruneReport) { [JsonPropertyName("NetworksDeleted")] - public IList NetworksDeleted { get; set; } = default!; + public IList? NetworksDeleted { get; set; } } } diff --git a/src/Docker.DotNet/Models/NodeUpdateParameters.Generated.cs b/src/Docker.DotNet/Models/NodeUpdateParameters.Generated.cs index af3f89ce..3952c6a1 100644 --- a/src/Docker.DotNet/Models/NodeUpdateParameters.Generated.cs +++ b/src/Docker.DotNet/Models/NodeUpdateParameters.Generated.cs @@ -23,7 +23,7 @@ public NodeUpdateParameters(Annotations Annotations) public string? Name { get; set; } [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } [JsonPropertyName("Role")] public string? Role { get; set; } diff --git a/src/Docker.DotNet/Models/PluginArgs.Generated.cs b/src/Docker.DotNet/Models/PluginArgs.Generated.cs index 65bbe4cf..7184bd4f 100644 --- a/src/Docker.DotNet/Models/PluginArgs.Generated.cs +++ b/src/Docker.DotNet/Models/PluginArgs.Generated.cs @@ -29,13 +29,13 @@ public class PluginArgs // (plugin.Args) /// Required: true /// [JsonPropertyName("Settable")] - public IList Settable { get; set; } = default!; + public IList? Settable { get; set; } /// /// value /// Required: true /// [JsonPropertyName("Value")] - public IList Value { get; set; } = default!; + public IList? Value { get; set; } } } diff --git a/src/Docker.DotNet/Models/PluginConfig.Generated.cs b/src/Docker.DotNet/Models/PluginConfig.Generated.cs index 3de03c9c..ab12478a 100644 --- a/src/Docker.DotNet/Models/PluginConfig.Generated.cs +++ b/src/Docker.DotNet/Models/PluginConfig.Generated.cs @@ -37,7 +37,7 @@ public class PluginConfig // (plugin.Config) /// Required: true /// [JsonPropertyName("Entrypoint")] - public IList Entrypoint { get; set; } = default!; + public IList? Entrypoint { get; set; } /// /// env @@ -45,7 +45,7 @@ public class PluginConfig // (plugin.Config) /// Required: true /// [JsonPropertyName("Env")] - public IList Env { get; set; } = default!; + public IList? Env { get; set; } /// /// interface @@ -74,7 +74,7 @@ public class PluginConfig // (plugin.Config) /// Required: true /// [JsonPropertyName("Mounts")] - public IList Mounts { get; set; } = default!; + public IList? Mounts { get; set; } /// /// network diff --git a/src/Docker.DotNet/Models/PluginConfigureParameters.Generated.cs b/src/Docker.DotNet/Models/PluginConfigureParameters.Generated.cs index 4df04726..36b27aec 100644 --- a/src/Docker.DotNet/Models/PluginConfigureParameters.Generated.cs +++ b/src/Docker.DotNet/Models/PluginConfigureParameters.Generated.cs @@ -4,6 +4,6 @@ namespace Docker.DotNet.Models public class PluginConfigureParameters // (main.PluginConfigureParameters) { [JsonPropertyName("Args")] - public IList Args { get; set; } = default!; + public IList? Args { get; set; } } } diff --git a/src/Docker.DotNet/Models/PluginDevice.Generated.cs b/src/Docker.DotNet/Models/PluginDevice.Generated.cs index 8522512f..d0a3122d 100644 --- a/src/Docker.DotNet/Models/PluginDevice.Generated.cs +++ b/src/Docker.DotNet/Models/PluginDevice.Generated.cs @@ -35,6 +35,6 @@ public class PluginDevice // (plugin.Device) /// Required: true /// [JsonPropertyName("Settable")] - public IList Settable { get; set; } = default!; + public IList? Settable { get; set; } } } diff --git a/src/Docker.DotNet/Models/PluginEnv.Generated.cs b/src/Docker.DotNet/Models/PluginEnv.Generated.cs index 5dceda4b..8f03584a 100644 --- a/src/Docker.DotNet/Models/PluginEnv.Generated.cs +++ b/src/Docker.DotNet/Models/PluginEnv.Generated.cs @@ -27,7 +27,7 @@ public class PluginEnv // (plugin.Env) /// Required: true /// [JsonPropertyName("Settable")] - public IList Settable { get; set; } = default!; + public IList? Settable { get; set; } /// /// value diff --git a/src/Docker.DotNet/Models/PluginInstallParameters.Generated.cs b/src/Docker.DotNet/Models/PluginInstallParameters.Generated.cs index 5cfc9a9e..dbb6ab0e 100644 --- a/src/Docker.DotNet/Models/PluginInstallParameters.Generated.cs +++ b/src/Docker.DotNet/Models/PluginInstallParameters.Generated.cs @@ -13,6 +13,6 @@ public class PluginInstallParameters // (main.PluginInstallParameters) public AuthConfig RegistryAuth { get; set; } = default!; [JsonPropertyName("Privileges")] - public IList Privileges { get; set; } = default!; + public IList? Privileges { get; set; } } } diff --git a/src/Docker.DotNet/Models/PluginInterface.Generated.cs b/src/Docker.DotNet/Models/PluginInterface.Generated.cs index b90adab5..9451987d 100644 --- a/src/Docker.DotNet/Models/PluginInterface.Generated.cs +++ b/src/Docker.DotNet/Models/PluginInterface.Generated.cs @@ -30,6 +30,6 @@ public class PluginInterface // (plugin.Interface) /// Required: true /// [JsonPropertyName("Types")] - public IList Types { get; set; } = default!; + public IList? Types { get; set; } } } diff --git a/src/Docker.DotNet/Models/PluginLinuxConfig.Generated.cs b/src/Docker.DotNet/Models/PluginLinuxConfig.Generated.cs index 286e8b7b..efb7db1f 100644 --- a/src/Docker.DotNet/Models/PluginLinuxConfig.Generated.cs +++ b/src/Docker.DotNet/Models/PluginLinuxConfig.Generated.cs @@ -22,13 +22,13 @@ public class PluginLinuxConfig // (plugin.LinuxConfig) /// Required: true /// [JsonPropertyName("Capabilities")] - public IList Capabilities { get; set; } = default!; + public IList? Capabilities { get; set; } /// /// devices /// Required: true /// [JsonPropertyName("Devices")] - public IList Devices { get; set; } = default!; + public IList? Devices { get; set; } } } diff --git a/src/Docker.DotNet/Models/PluginMount.Generated.cs b/src/Docker.DotNet/Models/PluginMount.Generated.cs index 93ad49a7..1498618f 100644 --- a/src/Docker.DotNet/Models/PluginMount.Generated.cs +++ b/src/Docker.DotNet/Models/PluginMount.Generated.cs @@ -38,14 +38,14 @@ public class PluginMount // (plugin.Mount) /// Required: true /// [JsonPropertyName("Options")] - public IList Options { get; set; } = default!; + public IList? Options { get; set; } /// /// settable /// Required: true /// [JsonPropertyName("Settable")] - public IList Settable { get; set; } = default!; + public IList? Settable { get; set; } /// /// source diff --git a/src/Docker.DotNet/Models/PluginPrivilege.Generated.cs b/src/Docker.DotNet/Models/PluginPrivilege.Generated.cs index 17672e74..d58f0ea0 100644 --- a/src/Docker.DotNet/Models/PluginPrivilege.Generated.cs +++ b/src/Docker.DotNet/Models/PluginPrivilege.Generated.cs @@ -14,6 +14,6 @@ public class PluginPrivilege // (plugin.Privilege) public string Description { get; set; } = string.Empty; [JsonPropertyName("Value")] - public IList Value { get; set; } = default!; + public IList? Value { get; set; } } } diff --git a/src/Docker.DotNet/Models/PluginRootFS.Generated.cs b/src/Docker.DotNet/Models/PluginRootFS.Generated.cs index 13e483f2..f649a849 100644 --- a/src/Docker.DotNet/Models/PluginRootFS.Generated.cs +++ b/src/Docker.DotNet/Models/PluginRootFS.Generated.cs @@ -13,7 +13,7 @@ public class PluginRootFS // (plugin.RootFS) /// Example: ["sha256:675532206fbf3030b8458f88d6e26d4eb1577688a25efec97154c94e8b6b4887","sha256:e216a057b1cb1efc11f8a268f37ef62083e70b1b38323ba252e25ac88904a7e8"] /// [JsonPropertyName("diff_ids")] - public IList DiffIds { get; set; } = default!; + public IList? DiffIds { get; set; } /// /// type diff --git a/src/Docker.DotNet/Models/PluginSettings.Generated.cs b/src/Docker.DotNet/Models/PluginSettings.Generated.cs index 4b620005..254e59ca 100644 --- a/src/Docker.DotNet/Models/PluginSettings.Generated.cs +++ b/src/Docker.DotNet/Models/PluginSettings.Generated.cs @@ -13,14 +13,14 @@ public class PluginSettings // (plugin.Settings) /// Required: true /// [JsonPropertyName("Args")] - public IList Args { get; set; } = default!; + public IList? Args { get; set; } /// /// devices /// Required: true /// [JsonPropertyName("Devices")] - public IList Devices { get; set; } = default!; + public IList? Devices { get; set; } /// /// env @@ -28,13 +28,13 @@ public class PluginSettings // (plugin.Settings) /// Required: true /// [JsonPropertyName("Env")] - public IList Env { get; set; } = default!; + public IList? Env { get; set; } /// /// mounts /// Required: true /// [JsonPropertyName("Mounts")] - public IList Mounts { get; set; } = default!; + public IList? Mounts { get; set; } } } diff --git a/src/Docker.DotNet/Models/PluginUpgradeParameters.Generated.cs b/src/Docker.DotNet/Models/PluginUpgradeParameters.Generated.cs index bd300275..5a9c903a 100644 --- a/src/Docker.DotNet/Models/PluginUpgradeParameters.Generated.cs +++ b/src/Docker.DotNet/Models/PluginUpgradeParameters.Generated.cs @@ -10,6 +10,6 @@ public class PluginUpgradeParameters // (main.PluginUpgradeParameters) public AuthConfig RegistryAuth { get; set; } = default!; [JsonPropertyName("Privileges")] - public IList Privileges { get; set; } = default!; + public IList? Privileges { get; set; } } } diff --git a/src/Docker.DotNet/Models/PluginsInfo.Generated.cs b/src/Docker.DotNet/Models/PluginsInfo.Generated.cs index 34a20fa6..63655631 100644 --- a/src/Docker.DotNet/Models/PluginsInfo.Generated.cs +++ b/src/Docker.DotNet/Models/PluginsInfo.Generated.cs @@ -11,24 +11,24 @@ public class PluginsInfo // (system.PluginsInfo) /// List of Volume plugins registered /// [JsonPropertyName("Volume")] - public IList Volume { get; set; } = default!; + public IList? Volume { get; set; } /// /// List of Network plugins registered /// [JsonPropertyName("Network")] - public IList Network { get; set; } = default!; + public IList? Network { get; set; } /// /// List of Authorization plugins registered /// [JsonPropertyName("Authorization")] - public IList Authorization { get; set; } = default!; + public IList? Authorization { get; set; } /// /// List of Log plugins registered /// [JsonPropertyName("Log")] - public IList Log { get; set; } = default!; + public IList? Log { get; set; } } } diff --git a/src/Docker.DotNet/Models/Resources.Generated.cs b/src/Docker.DotNet/Models/Resources.Generated.cs index 00c84b5d..d1d04cc3 100644 --- a/src/Docker.DotNet/Models/Resources.Generated.cs +++ b/src/Docker.DotNet/Models/Resources.Generated.cs @@ -37,19 +37,19 @@ public class Resources // (container.Resources) public ushort BlkioWeight { get; set; } = default!; [JsonPropertyName("BlkioWeightDevice")] - public IList BlkioWeightDevice { get; set; } = default!; + public IList? BlkioWeightDevice { get; set; } [JsonPropertyName("BlkioDeviceReadBps")] - public IList BlkioDeviceReadBps { get; set; } = default!; + public IList? BlkioDeviceReadBps { get; set; } [JsonPropertyName("BlkioDeviceWriteBps")] - public IList BlkioDeviceWriteBps { get; set; } = default!; + public IList? BlkioDeviceWriteBps { get; set; } [JsonPropertyName("BlkioDeviceReadIOps")] - public IList BlkioDeviceReadIOps { get; set; } = default!; + public IList? BlkioDeviceReadIOps { get; set; } [JsonPropertyName("BlkioDeviceWriteIOps")] - public IList BlkioDeviceWriteIOps { get; set; } = default!; + public IList? BlkioDeviceWriteIOps { get; set; } /// /// CPU CFS (Completely Fair Scheduler) period @@ -91,19 +91,19 @@ public class Resources // (container.Resources) /// List of devices to map inside the container /// [JsonPropertyName("Devices")] - public IList Devices { get; set; } = default!; + public IList? Devices { get; set; } /// /// List of rule to be added to the device cgroup /// [JsonPropertyName("DeviceCgroupRules")] - public IList DeviceCgroupRules { get; set; } = default!; + public IList? DeviceCgroupRules { get; set; } /// /// List of device requests for device drivers /// [JsonPropertyName("DeviceRequests")] - public IList DeviceRequests { get; set; } = default!; + public IList? DeviceRequests { get; set; } /// /// Memory soft limit (in bytes) @@ -139,7 +139,7 @@ public class Resources // (container.Resources) /// List of ulimits to be set in the container /// [JsonPropertyName("Ulimits")] - public IList Ulimits { get; set; } = default!; + public IList? Ulimits { get; set; } /// /// Applicable to Windows diff --git a/src/Docker.DotNet/Models/ServiceConfig.Generated.cs b/src/Docker.DotNet/Models/ServiceConfig.Generated.cs index 15d1434d..00c6f78c 100644 --- a/src/Docker.DotNet/Models/ServiceConfig.Generated.cs +++ b/src/Docker.DotNet/Models/ServiceConfig.Generated.cs @@ -7,12 +7,12 @@ namespace Docker.DotNet.Models public class ServiceConfig // (registry.ServiceConfig) { [JsonPropertyName("InsecureRegistryCIDRs")] - public IList InsecureRegistryCIDRs { get; set; } = default!; + public IList? InsecureRegistryCIDRs { get; set; } [JsonPropertyName("IndexConfigs")] - public IDictionary IndexConfigs { get; set; } = default!; + public IDictionary? IndexConfigs { get; set; } [JsonPropertyName("Mirrors")] - public IList Mirrors { get; set; } = default!; + public IList? Mirrors { get; set; } } } diff --git a/src/Docker.DotNet/Models/ServiceCreateResponse.Generated.cs b/src/Docker.DotNet/Models/ServiceCreateResponse.Generated.cs index 8f31d138..ab977e48 100644 --- a/src/Docker.DotNet/Models/ServiceCreateResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ServiceCreateResponse.Generated.cs @@ -24,6 +24,6 @@ public class ServiceCreateResponse // (swarm.ServiceCreateResponse) /// Example: ["unable to pin image doesnotexist:latest to digest: image library/doesnotexist:latest not found"] /// [JsonPropertyName("Warnings")] - public IList Warnings { get; set; } = default!; + public IList? Warnings { get; set; } } } diff --git a/src/Docker.DotNet/Models/ServiceInfo.Generated.cs b/src/Docker.DotNet/Models/ServiceInfo.Generated.cs index 1a28d812..f833b2d2 100644 --- a/src/Docker.DotNet/Models/ServiceInfo.Generated.cs +++ b/src/Docker.DotNet/Models/ServiceInfo.Generated.cs @@ -18,7 +18,7 @@ public class ServiceInfo // (network.ServiceInfo) /// ports /// [JsonPropertyName("Ports")] - public IList Ports { get; set; } = default!; + public IList? Ports { get; set; } /// /// local l b index @@ -30,6 +30,6 @@ public class ServiceInfo // (network.ServiceInfo) /// tasks /// [JsonPropertyName("Tasks")] - public IList Tasks { get; set; } = default!; + public IList? Tasks { get; set; } } } diff --git a/src/Docker.DotNet/Models/ServiceSpec.Generated.cs b/src/Docker.DotNet/Models/ServiceSpec.Generated.cs index e39c4191..3d792b75 100644 --- a/src/Docker.DotNet/Models/ServiceSpec.Generated.cs +++ b/src/Docker.DotNet/Models/ServiceSpec.Generated.cs @@ -23,7 +23,7 @@ public ServiceSpec(Annotations Annotations) public string? Name { get; set; } [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } /// /// TaskTemplate defines how the service should construct new tasks when diff --git a/src/Docker.DotNet/Models/ServiceUpdateResponse.Generated.cs b/src/Docker.DotNet/Models/ServiceUpdateResponse.Generated.cs index d47bda3d..6b4fc3b6 100644 --- a/src/Docker.DotNet/Models/ServiceUpdateResponse.Generated.cs +++ b/src/Docker.DotNet/Models/ServiceUpdateResponse.Generated.cs @@ -13,6 +13,6 @@ public class ServiceUpdateResponse // (swarm.ServiceUpdateResponse) /// Optional warning messages /// [JsonPropertyName("Warnings")] - public IList Warnings { get; set; } = default!; + public IList? Warnings { get; set; } } } diff --git a/src/Docker.DotNet/Models/SignatureIdentity.Generated.cs b/src/Docker.DotNet/Models/SignatureIdentity.Generated.cs index 2a4d2c42..71d4b3c0 100644 --- a/src/Docker.DotNet/Models/SignatureIdentity.Generated.cs +++ b/src/Docker.DotNet/Models/SignatureIdentity.Generated.cs @@ -16,7 +16,7 @@ public class SignatureIdentity // (image.SignatureIdentity) /// Timestamps contains a list of verified signed timestamps for the signature. /// [JsonPropertyName("Timestamps")] - public IList Timestamps { get; set; } = default!; + public IList? Timestamps { get; set; } /// /// KnownSigner is an identifier for a special signer identity that is known to the implementation. @@ -56,6 +56,6 @@ public class SignatureIdentity // (image.SignatureIdentity) /// Warning does not indicate a failed verification but may point to configuration issues. /// [JsonPropertyName("Warnings")] - public IList Warnings { get; set; } = default!; + public IList? Warnings { get; set; } } } diff --git a/src/Docker.DotNet/Models/Spec.Generated.cs b/src/Docker.DotNet/Models/Spec.Generated.cs index 0d60983b..f74ac042 100644 --- a/src/Docker.DotNet/Models/Spec.Generated.cs +++ b/src/Docker.DotNet/Models/Spec.Generated.cs @@ -23,7 +23,7 @@ public Spec(Annotations Annotations) public string? Name { get; set; } [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } [JsonPropertyName("Orchestration")] public OrchestrationConfig? Orchestration { get; set; } diff --git a/src/Docker.DotNet/Models/SwarmConfigSpec.Generated.cs b/src/Docker.DotNet/Models/SwarmConfigSpec.Generated.cs index 38c03e4c..8ccae8db 100644 --- a/src/Docker.DotNet/Models/SwarmConfigSpec.Generated.cs +++ b/src/Docker.DotNet/Models/SwarmConfigSpec.Generated.cs @@ -23,7 +23,7 @@ public SwarmConfigSpec(Annotations Annotations) public string? Name { get; set; } [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } /// /// Data is the data to store as a config. diff --git a/src/Docker.DotNet/Models/SwarmIPAMConfig.Generated.cs b/src/Docker.DotNet/Models/SwarmIPAMConfig.Generated.cs index aac10761..85bb552e 100644 --- a/src/Docker.DotNet/Models/SwarmIPAMConfig.Generated.cs +++ b/src/Docker.DotNet/Models/SwarmIPAMConfig.Generated.cs @@ -7,12 +7,12 @@ namespace Docker.DotNet.Models public class SwarmIPAMConfig // (swarm.IPAMConfig) { [JsonPropertyName("Subnet")] - public string Subnet { get; set; } = string.Empty; + public string? Subnet { get; set; } [JsonPropertyName("Range")] - public string Range { get; set; } = string.Empty; + public string? Range { get; set; } [JsonPropertyName("Gateway")] - public string Gateway { get; set; } = string.Empty; + public string? Gateway { get; set; } } } diff --git a/src/Docker.DotNet/Models/SwarmInitParameters.Generated.cs b/src/Docker.DotNet/Models/SwarmInitParameters.Generated.cs index 3c343583..713790b9 100644 --- a/src/Docker.DotNet/Models/SwarmInitParameters.Generated.cs +++ b/src/Docker.DotNet/Models/SwarmInitParameters.Generated.cs @@ -31,7 +31,7 @@ public class SwarmInitParameters // (swarm.InitRequest) public string Availability { get; set; } = string.Empty; [JsonPropertyName("DefaultAddrPool")] - public IList DefaultAddrPool { get; set; } = default!; + public IList? DefaultAddrPool { get; set; } [JsonPropertyName("SubnetSize")] public uint SubnetSize { get; set; } = default!; diff --git a/src/Docker.DotNet/Models/SwarmInspectResponse.Generated.cs b/src/Docker.DotNet/Models/SwarmInspectResponse.Generated.cs index 2e9dc395..eb0ee4e4 100644 --- a/src/Docker.DotNet/Models/SwarmInspectResponse.Generated.cs +++ b/src/Docker.DotNet/Models/SwarmInspectResponse.Generated.cs @@ -49,7 +49,7 @@ public SwarmInspectResponse(ClusterInfo ClusterInfo) public bool RootRotationInProgress { get; set; } = default!; [JsonPropertyName("DefaultAddrPool")] - public IList DefaultAddrPool { get; set; } = default!; + public IList? DefaultAddrPool { get; set; } [JsonPropertyName("SubnetSize")] public uint SubnetSize { get; set; } = default!; diff --git a/src/Docker.DotNet/Models/SwarmJoinParameters.Generated.cs b/src/Docker.DotNet/Models/SwarmJoinParameters.Generated.cs index 9536027b..4b07a068 100644 --- a/src/Docker.DotNet/Models/SwarmJoinParameters.Generated.cs +++ b/src/Docker.DotNet/Models/SwarmJoinParameters.Generated.cs @@ -16,7 +16,7 @@ public class SwarmJoinParameters // (swarm.JoinRequest) public string DataPathAddr { get; set; } = string.Empty; [JsonPropertyName("RemoteAddrs")] - public IList RemoteAddrs { get; set; } = default!; + public IList? RemoteAddrs { get; set; } /// /// accept by secret diff --git a/src/Docker.DotNet/Models/SwarmSecretSpec.Generated.cs b/src/Docker.DotNet/Models/SwarmSecretSpec.Generated.cs index d7e676fd..c3974a30 100644 --- a/src/Docker.DotNet/Models/SwarmSecretSpec.Generated.cs +++ b/src/Docker.DotNet/Models/SwarmSecretSpec.Generated.cs @@ -23,7 +23,7 @@ public SwarmSecretSpec(Annotations Annotations) public string? Name { get; set; } [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } /// /// Data is the data to store as a secret. It must be empty if a diff --git a/src/Docker.DotNet/Models/SystemInfoResponse.Generated.cs b/src/Docker.DotNet/Models/SystemInfoResponse.Generated.cs index f41d632f..5cfb3786 100644 --- a/src/Docker.DotNet/Models/SystemInfoResponse.Generated.cs +++ b/src/Docker.DotNet/Models/SystemInfoResponse.Generated.cs @@ -29,7 +29,7 @@ public class SystemInfoResponse // (system.Info) public string Driver { get; set; } = string.Empty; [JsonPropertyName("DriverStatus")] - public IList DriverStatus { get; set; } = default!; + public IList? DriverStatus { get; set; } /// /// SystemStatus is only propagated by the Swarm standalone API @@ -119,7 +119,7 @@ public class SystemInfoResponse // (system.Info) public long MemTotal { get; set; } = default!; [JsonPropertyName("GenericResources")] - public IList GenericResources { get; set; } = default!; + public IList? GenericResources { get; set; } [JsonPropertyName("DockerRootDir")] public string DockerRootDir { get; set; } = string.Empty; @@ -137,7 +137,7 @@ public class SystemInfoResponse // (system.Info) public string Name { get; set; } = string.Empty; [JsonPropertyName("Labels")] - public IList Labels { get; set; } = default!; + public IList? Labels { get; set; } [JsonPropertyName("ExperimentalBuild")] public bool ExperimentalBuild { get; set; } = default!; @@ -146,7 +146,7 @@ public class SystemInfoResponse // (system.Info) public string ServerVersion { get; set; } = string.Empty; [JsonPropertyName("Runtimes")] - public IDictionary Runtimes { get; set; } = default!; + public IDictionary? Runtimes { get; set; } [JsonPropertyName("DefaultRuntime")] public string DefaultRuntime { get; set; } = string.Empty; @@ -178,7 +178,7 @@ public class SystemInfoResponse // (system.Info) public Commit InitCommit { get; set; } = default!; [JsonPropertyName("SecurityOptions")] - public IList SecurityOptions { get; set; } = default!; + public IList? SecurityOptions { get; set; } [JsonPropertyName("ProductLicense")] public string? ProductLicense { get; set; } @@ -190,7 +190,7 @@ public class SystemInfoResponse // (system.Info) public FirewallInfo? FirewallBackend { get; set; } [JsonPropertyName("CDISpecDirs")] - public IList CDISpecDirs { get; set; } = default!; + public IList? CDISpecDirs { get; set; } [JsonPropertyName("DiscoveredDevices")] public IList? DiscoveredDevices { get; set; } @@ -208,6 +208,6 @@ public class SystemInfoResponse // (system.Info) /// other purposes, as they do not have a fixed format. /// [JsonPropertyName("Warnings")] - public IList Warnings { get; set; } = default!; + public IList? Warnings { get; set; } } } diff --git a/src/Docker.DotNet/Models/TaskResponse.Generated.cs b/src/Docker.DotNet/Models/TaskResponse.Generated.cs index 720b79e3..3c119498 100644 --- a/src/Docker.DotNet/Models/TaskResponse.Generated.cs +++ b/src/Docker.DotNet/Models/TaskResponse.Generated.cs @@ -42,7 +42,7 @@ public TaskResponse(Meta Meta, Annotations Annotations) public string? Name { get; set; } [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } [JsonPropertyName("Spec")] public TaskSpec? Spec { get; set; } @@ -83,6 +83,6 @@ public TaskResponse(Meta Meta, Annotations Annotations) /// fulfilling what mounts in the spec. /// [JsonPropertyName("Volumes")] - public IList Volumes { get; set; } = default!; + public IList? Volumes { get; set; } } } diff --git a/src/Docker.DotNet/Models/UpdateConfig.Generated.cs b/src/Docker.DotNet/Models/UpdateConfig.Generated.cs index 6412d55e..33bd556a 100644 --- a/src/Docker.DotNet/Models/UpdateConfig.Generated.cs +++ b/src/Docker.DotNet/Models/UpdateConfig.Generated.cs @@ -78,19 +78,19 @@ public UpdateConfig(Resources Resources) public ushort BlkioWeight { get; set; } = default!; [JsonPropertyName("BlkioWeightDevice")] - public IList BlkioWeightDevice { get; set; } = default!; + public IList? BlkioWeightDevice { get; set; } [JsonPropertyName("BlkioDeviceReadBps")] - public IList BlkioDeviceReadBps { get; set; } = default!; + public IList? BlkioDeviceReadBps { get; set; } [JsonPropertyName("BlkioDeviceWriteBps")] - public IList BlkioDeviceWriteBps { get; set; } = default!; + public IList? BlkioDeviceWriteBps { get; set; } [JsonPropertyName("BlkioDeviceReadIOps")] - public IList BlkioDeviceReadIOps { get; set; } = default!; + public IList? BlkioDeviceReadIOps { get; set; } [JsonPropertyName("BlkioDeviceWriteIOps")] - public IList BlkioDeviceWriteIOps { get; set; } = default!; + public IList? BlkioDeviceWriteIOps { get; set; } /// /// CPU CFS (Completely Fair Scheduler) period @@ -132,19 +132,19 @@ public UpdateConfig(Resources Resources) /// List of devices to map inside the container /// [JsonPropertyName("Devices")] - public IList Devices { get; set; } = default!; + public IList? Devices { get; set; } /// /// List of rule to be added to the device cgroup /// [JsonPropertyName("DeviceCgroupRules")] - public IList DeviceCgroupRules { get; set; } = default!; + public IList? DeviceCgroupRules { get; set; } /// /// List of device requests for device drivers /// [JsonPropertyName("DeviceRequests")] - public IList DeviceRequests { get; set; } = default!; + public IList? DeviceRequests { get; set; } /// /// Memory soft limit (in bytes) @@ -180,7 +180,7 @@ public UpdateConfig(Resources Resources) /// List of ulimits to be set in the container /// [JsonPropertyName("Ulimits")] - public IList Ulimits { get; set; } = default!; + public IList? Ulimits { get; set; } /// /// Applicable to Windows diff --git a/src/Docker.DotNet/Models/Volume.Generated.cs b/src/Docker.DotNet/Models/Volume.Generated.cs index 25cc08bd..8dcb5fec 100644 --- a/src/Docker.DotNet/Models/Volume.Generated.cs +++ b/src/Docker.DotNet/Models/Volume.Generated.cs @@ -35,7 +35,7 @@ public class Volume // (volume.Volume) /// Required: true /// [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } /// /// Mount path of the volume on the host. @@ -60,7 +60,7 @@ public class Volume // (volume.Volume) /// Required: true /// [JsonPropertyName("Options")] - public IDictionary Options { get; set; } = default!; + public IDictionary? Options { get; set; } /// /// The level at which the volume exists. Either `global` for cluster-wide, diff --git a/src/Docker.DotNet/Models/VolumeResponse.Generated.cs b/src/Docker.DotNet/Models/VolumeResponse.Generated.cs index 71990c7c..8af85744 100644 --- a/src/Docker.DotNet/Models/VolumeResponse.Generated.cs +++ b/src/Docker.DotNet/Models/VolumeResponse.Generated.cs @@ -13,7 +13,7 @@ public class VolumeResponse // (main.VolumeResponse) public string Driver { get; set; } = string.Empty; [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } [JsonPropertyName("Mountpoint")] public string Mountpoint { get; set; } = string.Empty; @@ -22,7 +22,7 @@ public class VolumeResponse // (main.VolumeResponse) public string Name { get; set; } = string.Empty; [JsonPropertyName("Options")] - public IDictionary Options { get; set; } = default!; + public IDictionary? Options { get; set; } [JsonPropertyName("Scope")] public string Scope { get; set; } = string.Empty; diff --git a/src/Docker.DotNet/Models/VolumesCreateParameters.Generated.cs b/src/Docker.DotNet/Models/VolumesCreateParameters.Generated.cs index 17571a66..b569bc7f 100644 --- a/src/Docker.DotNet/Models/VolumesCreateParameters.Generated.cs +++ b/src/Docker.DotNet/Models/VolumesCreateParameters.Generated.cs @@ -10,9 +10,9 @@ public class VolumesCreateParameters // (main.VolumesCreateParameters) public string Driver { get; set; } = string.Empty; [JsonPropertyName("DriverOpts")] - public IDictionary DriverOpts { get; set; } = default!; + public IDictionary? DriverOpts { get; set; } [JsonPropertyName("Labels")] - public IDictionary Labels { get; set; } = default!; + public IDictionary? Labels { get; set; } } } diff --git a/src/Docker.DotNet/Models/VolumesListResponse.Generated.cs b/src/Docker.DotNet/Models/VolumesListResponse.Generated.cs index c7c94b3f..5a10763a 100644 --- a/src/Docker.DotNet/Models/VolumesListResponse.Generated.cs +++ b/src/Docker.DotNet/Models/VolumesListResponse.Generated.cs @@ -4,9 +4,9 @@ namespace Docker.DotNet.Models public class VolumesListResponse // (main.VolumesListResponse) { [JsonPropertyName("Volumes")] - public IList Volumes { get; set; } = default!; + public IList? Volumes { get; set; } [JsonPropertyName("Warnings")] - public IList Warnings { get; set; } = default!; + public IList? Warnings { get; set; } } } diff --git a/src/Docker.DotNet/Models/VolumesPruneResponse.Generated.cs b/src/Docker.DotNet/Models/VolumesPruneResponse.Generated.cs index a72b1ce8..f01148ec 100644 --- a/src/Docker.DotNet/Models/VolumesPruneResponse.Generated.cs +++ b/src/Docker.DotNet/Models/VolumesPruneResponse.Generated.cs @@ -8,7 +8,7 @@ namespace Docker.DotNet.Models public class VolumesPruneResponse // (volume.PruneReport) { [JsonPropertyName("VolumesDeleted")] - public IList VolumesDeleted { get; set; } = default!; + public IList? VolumesDeleted { get; set; } [JsonPropertyName("SpaceReclaimed")] public ulong SpaceReclaimed { get; set; } = default!; diff --git a/test/Docker.DotNet.Tests.StrictJson/Docker.DotNet.Tests.StrictJson.csproj b/test/Docker.DotNet.Tests.StrictJson/Docker.DotNet.Tests.StrictJson.csproj new file mode 100644 index 00000000..96692a7b --- /dev/null +++ b/test/Docker.DotNet.Tests.StrictJson/Docker.DotNet.Tests.StrictJson.csproj @@ -0,0 +1,38 @@ + + + net8.0;net9.0;net10.0 + linux-arm64 + linux-x64 + osx-arm64 + osx-x64 + win-arm64 + win-x64 + Exe + false + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/Docker.DotNet.Tests.StrictJson/JsonSerializerTests.cs b/test/Docker.DotNet.Tests.StrictJson/JsonSerializerTests.cs new file mode 100644 index 00000000..26ea197b --- /dev/null +++ b/test/Docker.DotNet.Tests.StrictJson/JsonSerializerTests.cs @@ -0,0 +1,41 @@ +namespace Docker.DotNet.Tests.StrictJson; + +public sealed class JsonSerializerTests +{ + [Fact] + public void Deserialize_ShouldRespectNullableAnnotations() + { + // Given + var json = Encoding.UTF8.GetBytes("""{"Name":null}"""); + + // When + var exception = Record.Exception(() => JsonSerializer.Instance.Deserialize(json)); + + // Then + AssertStrictDeserialization(exception); + } + + [Fact] + public void Deserialize_ShouldRespectRequiredConstructorParameters() + { + // Given + var json = Encoding.UTF8.GetBytes("{}"); + + // When + var exception = Record.Exception(() => JsonSerializer.Instance.Deserialize(json)); + + // Then + AssertStrictDeserialization(exception); + } + + private static void AssertStrictDeserialization(Exception exception) + { +#if NET9_0_OR_GREATER + Assert.IsType(exception); +#else + // System.Text.Json 8 does not support strict deserialization, so the + // switches have no effect. + Assert.Null(exception); +#endif + } +} diff --git a/test/Docker.DotNet.Tests/Docker.DotNet.Tests.csproj b/test/Docker.DotNet.Tests/Docker.DotNet.Tests.csproj index 3ff7f766..e35a1559 100644 --- a/test/Docker.DotNet.Tests/Docker.DotNet.Tests.csproj +++ b/test/Docker.DotNet.Tests/Docker.DotNet.Tests.csproj @@ -22,6 +22,11 @@ + + + + + diff --git a/test/Docker.DotNet.Tests/JsonSerializerTests.cs b/test/Docker.DotNet.Tests/JsonSerializerTests.cs new file mode 100644 index 00000000..1e3e6774 --- /dev/null +++ b/test/Docker.DotNet.Tests/JsonSerializerTests.cs @@ -0,0 +1,30 @@ +namespace Docker.DotNet.Tests; + +public sealed class JsonSerializerTests +{ + [Fact] + public void Deserialize_ShouldIgnoreGlobalRespectNullableAnnotationsSwitch() + { + // Given + var json = Encoding.UTF8.GetBytes("""{"Name":null}"""); + + // When + var volume = JsonSerializer.Instance.Deserialize(json); + + // Then + Assert.Null(volume.Name); + } + + [Fact] + public void Deserialize_ShouldIgnoreGlobalRespectRequiredConstructorParametersSwitch() + { + // Given + var json = Encoding.UTF8.GetBytes("{}"); + + // When + var contextMeta = JsonSerializer.Instance.Deserialize(json); + + // Then + Assert.Null(contextMeta.Endpoints); + } +} diff --git a/test/Docker.DotNet.TestsV2/Docker.DotNet.TestsV2.csproj b/test/Docker.DotNet.TestsV2/Docker.DotNet.TestsV2.csproj index 9c423e38..86a0137d 100644 --- a/test/Docker.DotNet.TestsV2/Docker.DotNet.TestsV2.csproj +++ b/test/Docker.DotNet.TestsV2/Docker.DotNet.TestsV2.csproj @@ -22,6 +22,11 @@ + + + + + diff --git a/tools/specgen/specgen.go b/tools/specgen/specgen.go index 9730c8b9..79a4ed79 100644 --- a/tools/specgen/specgen.go +++ b/tools/specgen/specgen.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "encoding" "fmt" "go/ast" "go/parser" @@ -599,6 +600,26 @@ func csType(t reflect.Type, _ bool) CSType { } } +// textMarshalerType is the reflected type of the encoding.TextMarshaler +// interface. +var textMarshalerType = reflect.TypeOf((*encoding.TextMarshaler)(nil)).Elem() + +// isJSONNullable reports whether encoding/json can marshal a value of the +// given type as JSON null. This is the case for nil pointers, interfaces, +// slices and maps. Slice and map types that implement encoding.TextMarshaler +// (e.g. net.IP) are excluded, because encoding/json always marshals them as a +// JSON string, even when they are nil. +func isJSONNullable(t reflect.Type) bool { + switch t.Kind() { + case reflect.Ptr, reflect.Interface: + return true + case reflect.Slice, reflect.Map: + return !t.Implements(textMarshalerType) + default: + return false + } +} + func ultimateType(t reflect.Type) reflect.Type { for { switch t.Kind() { @@ -833,6 +854,7 @@ func reflectTypeMembers(t reflect.Type, m *CSModelType) { } omitEmpty := slices.Contains(jsonTag, "omitempty") + omitZero := slices.Contains(jsonTag, "omitzero") if hasTypeCustomizations { for _, p := range typeCustomizations.Properties { @@ -878,7 +900,7 @@ func reflectTypeMembers(t reflect.Type, m *CSModelType) { } else { a := CSAttribute{Type: CSType{"System.Text.Json.Serialization", "JsonPropertyName"}} a.Arguments = append(a.Arguments, CSArgument{jsonName, CSInboxTypesMap[reflect.String]}) - csProp.IsOpt = omitEmpty || f.Type.Kind() == reflect.Ptr + csProp.IsOpt = omitEmpty || omitZero || isJSONNullable(f.Type) csProp.Attributes = append(csProp.Attributes, a) m.HasJsonSerializableProperties = true