Skip to content

Latest commit

 

History

History
74 lines (67 loc) · 3.78 KB

File metadata and controls

74 lines (67 loc) · 3.78 KB

Atc.Rest.Helpers


ProblemDetailsHelper

Helper methods for working with Microsoft.AspNetCore.Mvc.ProblemDetails responses.

Remarks: This class provides utilities for detecting, parsing, and extracting information from ProblemDetails JSON. ProblemDetails is a standardized format (RFC 7807) for returning error information from HTTP APIs.

public static class ProblemDetailsHelper

Static Methods

IsFormatJsonAndProblemDetailsModel

bool IsFormatJsonAndProblemDetailsModel(string value)

Summary: Determines whether the specified string is a JSON-formatted ProblemDetails model containing at least one of the expected top-level properties (status, title, detail) — the comparison is case-insensitive on property names so it tolerates both PascalCase and camelCase serialization styles.

Parameters:
     value  -  The string to check.

Returns: if the value is valid JSON whose root object exposes any of the ProblemDetails properties; otherwise, .

TrySerializeToProblemDetails

bool TrySerializeToProblemDetails(string value, out ProblemDetails problemDetails)

Summary: Attempts to deserialize a JSON string to a Microsoft.AspNetCore.Mvc.ProblemDetails object.

Parameters:
     value  -  The JSON string to deserialize.
     problemDetails  -  When this method returns, contains the deserialized ProblemDetails if successful; otherwise, null.

Returns: True if deserialization succeeded; otherwise, false.

TrySerializeToProblemDetailsAndGetDetails

bool TrySerializeToProblemDetailsAndGetDetails(string value, out string detailValue)

Summary: Attempts to deserialize a JSON string to ProblemDetails and extract the detail message.

Parameters:
     value  -  The JSON string to deserialize.
     detailValue  -  When this method returns, contains the detail message if successful; otherwise, null.

Returns: True if deserialization succeeded; otherwise, false.

TrySerializeToProblemDetailsAndGetStatusCode

bool TrySerializeToProblemDetailsAndGetStatusCode(string value, out HttpStatusCode? statusCodeValue)

Summary: Attempts to deserialize a JSON string to ProblemDetails and extract the HTTP status code.

Parameters:
     value  -  The JSON string to deserialize.
     statusCodeValue  -  When this method returns, contains the HTTP status code if successful; otherwise, null.

Returns: True if deserialization succeeded and status code was extracted; otherwise, false.

TrySerializeToProblemDetailsAndGetTitle

bool TrySerializeToProblemDetailsAndGetTitle(string value, out string titleValue)

Summary: Attempts to deserialize a JSON string to ProblemDetails and extract the title.

Parameters:
     value  -  The JSON string to deserialize.
     titleValue  -  When this method returns, contains the title if successful; otherwise, null.

Returns: True if deserialization succeeded; otherwise, false.


Generated by MarkdownCodeDoc version 1.2