(bugfix): when returning ProblemDetail should be applicaiton/problem+json
This commit is contained in:
parent
f6a7b13326
commit
43abcba816
@ -8,7 +8,7 @@
|
||||
|
||||
<!-- NuGet package metadata -->
|
||||
<PackageId>MaksIT.Results</PackageId>
|
||||
<Version>1.1.0</Version>
|
||||
<Version>1.1.1</Version>
|
||||
<Authors>Maksym Sadovnychyy</Authors>
|
||||
<Company>MAKS-IT</Company>
|
||||
<Product>MaksIT.Results</Product>
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
|
||||
namespace MaksIT.Results.Mvc;
|
||||
|
||||
public class ObjectResult(object? value) : IActionResult {
|
||||
@ -20,7 +18,13 @@ public class ObjectResult(object? value) : IActionResult {
|
||||
response.StatusCode = StatusCode.Value;
|
||||
}
|
||||
|
||||
// Set content type based on value type
|
||||
if (Value is ProblemDetails) {
|
||||
response.ContentType = "application/problem+json";
|
||||
}
|
||||
else {
|
||||
response.ContentType = "application/json";
|
||||
}
|
||||
|
||||
if (Value is not null) {
|
||||
await JsonSerializer.SerializeAsync(
|
||||
|
||||
@ -1,15 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace MaksIT.Results.Mvc;
|
||||
|
||||
namespace MaksIT.Results.Mvc;
|
||||
|
||||
public class ProblemDetails {
|
||||
public int? Status { get; set; }
|
||||
public string? Type { get; set; }
|
||||
public string? Title { get; set; }
|
||||
public int? Status { get; set; }
|
||||
public string? Detail { get; set; }
|
||||
public string? Instance { get; set; }
|
||||
public IDictionary<string, object?> Extensions { get; } = new Dictionary<string, object?>();
|
||||
public IDictionary<string, object?> Extensions { get; set; } = new Dictionary<string, object?>();
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user