Skip to content

Commit

Permalink
Fixed multitenant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
simpat-jesus committed Nov 17, 2023
1 parent 50fe24f commit f615c6e
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public async Task<bool> PerformTest()
_resources[path.Key] = new Resource
{
Name = GetResoucePath(path.Key, path.Value),
BasePath = doc.Servers.First().Url,
BasePath = ReplaceVariablesInServer(doc.Servers.First()),
Path = path.Value,
Schema = GetSchemaNameFromPath(path.Key),
Definition = doc.Components
Expand Down Expand Up @@ -168,5 +168,22 @@ private static string GetSchemaNameFromPath(string path)
? GetSchemaNameParts(schemaNameParts)
: string.Empty);
}

private static string ReplaceVariablesInServer(OpenApiServer server)
{
var variablesToReplace = server.Variables.Select(x => new
{
Name = x.Key,
DefaultValue = x.Value.Default.Replace("/", string.Empty)
});
var serverUrl = server.Url;

foreach (var variable in variablesToReplace)
{
serverUrl = serverUrl.Replace($"{{{variable.Name}}}", variable.DefaultValue);
}

return serverUrl;
}
}
}

0 comments on commit f615c6e

Please sign in to comment.