Skip to content

Commit 42c7276

Browse files
Merge branch 'main' into 525_warn-on-mismatch-between-app-and-schema-versions
2 parents 6643de6 + 6e423ac commit 42c7276

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

dev-proxy-abstractions/ProxyUtils.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ private static string GetCommonPrefix(List<string> paths)
465465
var lastSlashIndex = prefix.LastIndexOf('/');
466466
return lastSlashIndex >= 0 ? prefix[..(lastSlashIndex + 1)] : prefix;
467467
}
468-
468+
469469
public static async Task<(bool IsValid, IEnumerable<string> ValidationErrors)> ValidateJson(string? json, string? schemaUrl, ILogger logger)
470470
{
471471
try
@@ -486,7 +486,7 @@ private static string GetCommonPrefix(List<string> paths)
486486
logger.LogDebug("Downloading schema from {SchemaUrl}", schemaUrl);
487487
using var client = new HttpClient();
488488
var schemaContents = await client.GetStringAsync(schemaUrl);
489-
489+
490490
logger.LogDebug("Parsing schema");
491491
var schema = JSchema.Parse(schemaContents);
492492
logger.LogDebug("Parsing JSON");
@@ -628,5 +628,11 @@ public static int CompareSemVer(string? a, string? b)
628628
// if both versions are prerelease, b is greater
629629
return -1;
630630
}
631+
632+
public static string GetVersionString(string productVersion)
633+
{
634+
return productVersion.Contains("-beta")
635+
? productVersion.Split("-")[0]
636+
: productVersion;
631637
}
632638
}

dev-proxy-plugins/Mocks/CrudApiPlugin.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,10 @@ private void AddCORSHeaders(Request request, List<HttpHeader> headers)
218218

219219
headers.Add(new HttpHeader("access-control-allow-origin", origin));
220220

221-
if (_configuration.EntraAuthConfig is not null)
221+
if (_configuration.EntraAuthConfig is not null ||
222+
_configuration.Actions.Any(a => a.Auth == CrudApiAuthType.Entra))
222223
{
223-
headers.Add(new HttpHeader("access-control-allow-headers", "authorization"));
224+
headers.Add(new HttpHeader("access-control-allow-headers", "authorization, content-type"));
224225
}
225226

226227
var methods = string.Join(", ", _configuration.Actions

dev-proxy-plugins/Mocks/OpenAIMockResponsePlugin.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@ public override async Task RegisterAsync()
3434

3535
private async Task OnRequestAsync(object sender, ProxyRequestArgs e)
3636
{
37+
if (e.ResponseState.HasBeenSet)
38+
{
39+
Logger.LogRequest("Response already set", MessageType.Skipped, new LoggingContext(e.Session));
40+
return;
41+
}
3742
if (UrlsToWatch is null ||
38-
!e.HasRequestUrlMatch(UrlsToWatch))
43+
!e.ShouldExecute(UrlsToWatch))
3944
{
4045
Logger.LogRequest("URL not matched", MessageType.Skipped, new LoggingContext(e.Session));
4146
return;

dev-proxy/CommandHandlers/ConfigNewCommandHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class VisualStudioCodeSnippet
1717

1818
public static class ConfigNewCommandHandler
1919
{
20-
private static readonly string snippetsFileUrl = $"https://aka.ms/devproxy/snippets/v{ProxyUtils.ProductVersion}";
20+
private static readonly string snippetsFileUrl = $"https://aka.ms/devproxy/snippets/v{ProxyUtils.GetVersionString(ProxyUtils.ProductVersion)}";
2121
private static readonly string configFileSnippetName = "ConfigFile";
2222

2323
public static async Task CreateConfigFileAsync(string name, ILogger logger)

0 commit comments

Comments
 (0)