-
-
Notifications
You must be signed in to change notification settings - Fork 773
Implement RFC 7807 to support Problem Details in bad validation requests #578
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2b89e4f
Added support for handling validation-based exceptions according to t…
6889d9a
Merge branch 'master' into master
faniereynders 471764b
added documentation
c39e1ea
Merge branch 'master' of https://github.com/faniereynders/refit
5564f1b
Updated readme
faniereynders eedf095
Update ProblemDetails.cs
faniereynders File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace Refit | ||
| { | ||
| /// <summary> | ||
| /// The object representing the details about a ValidationException caught by a service implementing RFC 7807. | ||
| /// </summary> | ||
| public class ProblemDetails | ||
| { | ||
| /// <summary> | ||
| /// Collection of resulting errors for the request. | ||
| /// </summary> | ||
| public Dictionary<string, string[]> Errors { get; set; } = new Dictionary<string, string[]>(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @paulcbetts any thoughts on using the concrete type here vs an |
||
|
|
||
| /// <summary> | ||
| /// A URI reference that identifies the problem type. | ||
| /// </summary> | ||
| public string Type { get; set; } = "about:blank"; | ||
|
|
||
| /// <summary> | ||
| /// A short, human-readable summary of the problem type. | ||
| /// </summary> | ||
| public string Title { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// The HTTP status code generated by the origin server for this occurrence of the problem. | ||
| /// </summary> | ||
| public int Status { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// A human-readable explanation specific to this occurrence of the problem. | ||
| /// </summary> | ||
| public string Detail { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// A URI reference that identifies the specific occurrence of the problem. | ||
| /// </summary> | ||
| public string Instance { get; set; } | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| using System; | ||
|
|
||
| namespace Refit | ||
| { | ||
| /// <summary> | ||
| /// An ApiException that is raised according to RFC 7807, which contains problem details for validation exceptions. | ||
| /// </summary> | ||
| [Serializable] | ||
| public class ValidationApiException : ApiException | ||
| { | ||
|
|
||
| ValidationApiException(ApiException apiException) : | ||
| base(apiException.RequestMessage, apiException.HttpMethod, apiException.StatusCode, apiException.ReasonPhrase, apiException.Headers, apiException.RefitSettings) | ||
| { | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a new instance of a ValidationException from an existing ApiException. | ||
| /// </summary> | ||
| /// <param name="exception">An instance of an ApiException to use to build a ValidationException.</param> | ||
| /// <returns>ValidationApiException</returns> | ||
| public static ValidationApiException Create(ApiException exception) | ||
| { | ||
| return new ValidationApiException(exception); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// The problem details of the RFC 7807 validation exception. | ||
| /// </summary> | ||
| public new ProblemDetails Content => GetContentAs<ProblemDetails>(); | ||
|
|
||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a doc comment to the type itself