Skip to content

Updates API #1095

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions dev-proxy/ApiControllers/ProxyController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public async Task<IActionResult> SetAsync([FromBody] ProxyInfo proxyInfo)
{
if (proxyInfo.ConfigFile != null)
{
return BadRequest("ConfigFile cannot be set");
ModelState.AddModelError("ConfigFile", "ConfigFile cannot be set");
return ValidationProblem(ModelState);
}

if (proxyInfo.Recording.HasValue)
Expand All @@ -41,7 +42,7 @@ public async Task<IActionResult> SetAsync([FromBody] ProxyInfo proxyInfo)
return Ok(ProxyInfo.From(_proxyState));
}

[HttpPost("raiseMockRequest")]
[HttpPost("mockRequest")]
public async Task RaiseMockRequestAsync()
{
await _proxyState.RaiseMockRequestAsync();
Expand All @@ -55,12 +56,18 @@ public void StopProxy()
_proxyState.StopProxy();
}

[HttpPost("createJwtToken")]
[HttpPost("jwtToken")]
public IActionResult CreateJwtToken([FromBody] JwtOptions jwtOptions)
{
if (jwtOptions.SigningKey != null && jwtOptions.SigningKey.Length < 32)
{
return BadRequest("The specified signing key is too short. A signing key must be at least 32 characters.");
var problemDetails = new ProblemDetails
{
Title = "Key too short",
Detail = "The specified signing key is too short. A signing key must be at least 32 characters.",
Status = StatusCodes.Status400BadRequest
};
return BadRequest(problemDetails);
}

var token = JwtTokenGenerator.CreateToken(jwtOptions);
Expand Down