(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 -->
|
<!-- NuGet package metadata -->
|
||||||
<PackageId>MaksIT.Results</PackageId>
|
<PackageId>MaksIT.Results</PackageId>
|
||||||
<Version>1.1.0</Version>
|
<Version>1.1.1</Version>
|
||||||
<Authors>Maksym Sadovnychyy</Authors>
|
<Authors>Maksym Sadovnychyy</Authors>
|
||||||
<Company>MAKS-IT</Company>
|
<Company>MAKS-IT</Company>
|
||||||
<Product>MaksIT.Results</Product>
|
<Product>MaksIT.Results</Product>
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
|
||||||
namespace MaksIT.Results.Mvc;
|
namespace MaksIT.Results.Mvc;
|
||||||
|
|
||||||
public class ObjectResult(object? value) : IActionResult {
|
public class ObjectResult(object? value) : IActionResult {
|
||||||
@ -20,7 +18,13 @@ public class ObjectResult(object? value) : IActionResult {
|
|||||||
response.StatusCode = StatusCode.Value;
|
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";
|
response.ContentType = "application/json";
|
||||||
|
}
|
||||||
|
|
||||||
if (Value is not null) {
|
if (Value is not null) {
|
||||||
await JsonSerializer.SerializeAsync(
|
await JsonSerializer.SerializeAsync(
|
||||||
|
|||||||
@ -1,15 +1,11 @@
|
|||||||
using System;
|
namespace MaksIT.Results.Mvc;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MaksIT.Results.Mvc;
|
|
||||||
|
|
||||||
public class ProblemDetails {
|
public class ProblemDetails {
|
||||||
public int? Status { get; set; }
|
public string? Type { get; set; }
|
||||||
public string? Title { get; set; }
|
public string? Title { get; set; }
|
||||||
|
public int? Status { get; set; }
|
||||||
public string? Detail { get; set; }
|
public string? Detail { get; set; }
|
||||||
public string? Instance { 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