Skip to content

Commit 5bb8c43

Browse files
committed
fix(Services.IO): Fixes the way the WorkflowReader resolves URIs
1 parent d117ee5 commit 5bb8c43

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/ServerlessWorkflow.Sdk/ServerlessWorkflow.Sdk.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<TargetFramework>net6.0</TargetFramework>
55
<Nullable>enable</Nullable>
66
<NeutralLanguage>en</NeutralLanguage>
7-
<AssemblyVersion>0.8.1.5</AssemblyVersion>
8-
<FileVersion>0.8.1.5</FileVersion>
9-
<Version>0.8.1.5</Version>
7+
<AssemblyVersion>0.8.1.6</AssemblyVersion>
8+
<FileVersion>0.8.1.6</FileVersion>
9+
<Version>0.8.1.6</Version>
1010
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
1111
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1212
<PackageLicenseFile>LICENSE</PackageLicenseFile>

src/ServerlessWorkflow.Sdk/Services/IO/WorkflowReader.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,9 @@ protected virtual async Task<DataInputSchemaDefinition> LoadDataInputSchemaAsync
148148
if (uri == null)
149149
throw new ArgumentNullException(nameof(uri));
150150
string? content;
151-
if (!uri.IsAbsoluteUri)
152-
{
153-
154-
}
151+
if (!uri.IsAbsoluteUri
152+
|| (uri.IsFile && Path.IsPathRooted(uri.LocalPath)))
153+
uri = this.ResolveRelativeUri(uri, options);
155154
if (uri.IsFile)
156155
{
157156
string filePath = uri.LocalPath;
@@ -183,6 +182,9 @@ protected virtual async Task<DynamicObject> LoadExternalDefinitionAsync(Uri uri,
183182
if (uri == null)
184183
throw new ArgumentNullException(nameof(uri));
185184
string? content;
185+
if (!uri.IsAbsoluteUri
186+
|| (uri.IsFile && Path.IsPathRooted(uri.LocalPath)))
187+
uri = this.ResolveRelativeUri(uri, options);
186188
if (uri.IsFile)
187189
{
188190
string filePath = uri.LocalPath;
@@ -216,6 +218,9 @@ protected virtual async Task<List<T>> LoadExternalDefinitionCollectionAsync<T>(U
216218
if (uri == null)
217219
throw new ArgumentNullException(nameof(uri));
218220
string? content;
221+
if (!uri.IsAbsoluteUri
222+
|| (uri.IsFile && Path.IsPathRooted(uri.LocalPath)))
223+
uri = this.ResolveRelativeUri(uri, options);
219224
if (uri.IsFile)
220225
{
221226
string filePath = uri.LocalPath;
@@ -253,7 +258,7 @@ protected virtual Uri ResolveRelativeUri(Uri uri, WorkflowReaderOptions options)
253258
throw new NullReferenceException($"The '{nameof(WorkflowReaderOptions.BaseUri)}' property must be set when using the specified {nameof(RelativeUriReferenceResolutionMode)} '{RelativeUriReferenceResolutionMode.ConvertToAbsolute}'");
254259
return new(options.BaseUri, uri.ToString());
255260
case RelativeUriReferenceResolutionMode.ConvertToRelativeFilePath:
256-
return new(Path.Combine(options.BaseDirectory, uri.LocalPath));
261+
return new(Path.Combine(options.BaseDirectory, uri.ToString()));
257262
case RelativeUriReferenceResolutionMode.None:
258263
throw new NotSupportedException($"Relative uris are not supported when using the specified {nameof(RelativeUriReferenceResolutionMode)} '{RelativeUriReferenceResolutionMode.ConvertToAbsolute}'");
259264
default:

0 commit comments

Comments
 (0)