Skip to content

Commit d5196bd

Browse files
committed
fix(Sdk): Hide OneOf properties from users, and instead add properties for its the type alternatives it encapsulates
Signed-off-by: Charles d'Avernas <[email protected]>
1 parent 6eab8a1 commit d5196bd

File tree

6 files changed

+50
-10
lines changed

6 files changed

+50
-10
lines changed

src/ServerlessWorkflow.Sdk.Builders/ScriptProcessDefinitionBuilder.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ public override ScriptProcessDefinition Build()
133133
Arguments = this.Arguments,
134134
Environment = this.Environment
135135
};
136-
if(this.Source != null) process.Source = this.Source;
137-
else if(this.SourceUri != null) process.Source = new() { Endpoint = this.SourceUri };
136+
if (this.Source != null) process.Source = this.Source;
137+
else if (this.SourceUri != null) process.Source = new() { EndpointUri = this.SourceUri };
138138
return process;
139139
}
140140

src/ServerlessWorkflow.Sdk.Builders/ServerlessWorkflow.Sdk.Builders.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<VersionPrefix>1.0.0</VersionPrefix>
8-
<VersionSuffix>alpha2.10</VersionSuffix>
8+
<VersionSuffix>alpha2.11</VersionSuffix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/ServerlessWorkflow.Sdk.IO/ServerlessWorkflow.Sdk.IO.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<VersionPrefix>1.0.0</VersionPrefix>
8-
<VersionSuffix>alpha2.10</VersionSuffix>
8+
<VersionSuffix>alpha2.11</VersionSuffix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

src/ServerlessWorkflow.Sdk/Models/Calls/HttpCallDefinition.cs

+23-3
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,31 @@ public record HttpCallDefinition
2929
public required virtual string Method { get; set; }
3030

3131
/// <summary>
32-
/// Gets/sets the definition of the endpoint to request
32+
/// Gets/sets the endpoint at which to get the defined resource
33+
/// </summary>
34+
[IgnoreDataMember, JsonIgnore, YamlIgnore]
35+
public virtual EndpointDefinition Endpoint
36+
{
37+
get => this.EndpointValue.T1Value ?? new() { Uri = this.EndpointUri };
38+
set => this.EndpointValue = value;
39+
}
40+
41+
/// <summary>
42+
/// Gets/sets the endpoint at which to get the defined resource
43+
/// </summary>
44+
[IgnoreDataMember, JsonIgnore, YamlIgnore]
45+
public virtual Uri EndpointUri
46+
{
47+
get => this.EndpointValue.T1Value?.Uri ?? this.EndpointValue.T2Value!;
48+
set => this.EndpointValue = value;
49+
}
50+
51+
/// <summary>
52+
/// Gets/sets the endpoint at which to get the defined resource
3353
/// </summary>
3454
[Required]
35-
[DataMember(Name = "endpoint", Order = 2), JsonPropertyName("endpoint"), JsonPropertyOrder(2), YamlMember(Alias = "endpoint", Order = 2)]
36-
public required virtual OneOf<EndpointDefinition, Uri> Endpoint { get; set; }
55+
[DataMember(Name = "endpoint", Order = 2), JsonInclude, JsonPropertyName("endpoint"), JsonPropertyOrder(2), YamlMember(Alias = "endpoint", Order = 2)]
56+
protected virtual OneOf<EndpointDefinition, Uri> EndpointValue { get; set; } = null!;
3757

3858
/// <summary>
3959
/// Gets/sets a name/value mapping of the headers, if any, of the HTTP request to perform

src/ServerlessWorkflow.Sdk/Models/ExternalResourceDefinition.cs

+22-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,31 @@ public record ExternalResourceDefinition
2626
[DataMember(Name = "name", Order = 1), JsonPropertyName("name"), JsonPropertyOrder(1), YamlMember(Alias = "name", Order = 1)]
2727
public virtual string? Name { get; set; }
2828

29+
/// <summary>
30+
/// Gets/sets the endpoint at which to get the defined resource
31+
/// </summary>
32+
[IgnoreDataMember, JsonIgnore, YamlIgnore]
33+
public virtual EndpointDefinition Endpoint
34+
{
35+
get => this.EndpointValue.T1Value ?? new() { Uri = this.EndpointUri };
36+
set => this.EndpointValue = value;
37+
}
38+
39+
/// <summary>
40+
/// Gets/sets the endpoint at which to get the defined resource
41+
/// </summary>
42+
[IgnoreDataMember, JsonIgnore, YamlIgnore]
43+
public virtual Uri EndpointUri
44+
{
45+
get => this.EndpointValue.T1Value?.Uri ?? this.EndpointValue.T2Value!;
46+
set => this.EndpointValue = value;
47+
}
48+
2949
/// <summary>
3050
/// Gets/sets the endpoint at which to get the defined resource
3151
/// </summary>
3252
[Required]
33-
[DataMember(Name = "endpoint", Order = 2), JsonPropertyName("endpoint"), JsonPropertyOrder(2), YamlMember(Alias = "endpoint", Order = 2)]
34-
public virtual OneOf<EndpointDefinition, Uri> Endpoint { get; set; } = null!;
53+
[DataMember(Name = "endpoint", Order = 2), JsonInclude, JsonPropertyName("endpoint"), JsonPropertyOrder(2), YamlMember(Alias = "endpoint", Order = 2)]
54+
protected virtual OneOf<EndpointDefinition, Uri> EndpointValue { get; set; } = null!;
3555

3656
}

src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<VersionPrefix>1.0.0</VersionPrefix>
8-
<VersionSuffix>alpha2.10</VersionSuffix>
8+
<VersionSuffix>alpha2.11</VersionSuffix>
99
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1010
<FileVersion>$(VersionPrefix)</FileVersion>
1111
<NeutralLanguage>en</NeutralLanguage>

0 commit comments

Comments
 (0)