Add RespondsWithProblemDetails#128
Merged
dennisdoomen merged 1 commit intoMay 30, 2026
Merged
Conversation
| mock.AllMocksInvoked.Should().BeTrue(); | ||
| } | ||
| } | ||
| #nullable restore |
Coverage Report for CI Build 26683760573Coverage increased (+0.6%) to 85.906%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Adds an RFC 7807 application/problem+json responder to RequestMockBuilder that emits the ProblemDetails shape via the existing JSON serialization path, defaulting title from the status reason phrase and status from the status code. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0afbaa2 to
c2bad1e
Compare
This was referenced Jun 1, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #122
Summary
Adds a first-class responder that returns an RFC 7807
application/problem+jsonpayload, the standard error format for ASP.NET Core and many modern APIs. This lets users write concise negative-path tests without hand-building the JSON.The
ProblemDetailsshape is emitted directly through the existing JSON serialization path (reusing the configurableJsonSerializerOptions), so noMicrosoft.AspNetCore.*dependency is introduced. The responseContent-Typeis set toapplication/problem+json. When not supplied,titledefaults to the status code's reason phrase andstatusis derived from the status code.type,detail, andinstanceare only emitted when provided, and anyextensionsare serialized as additional top-level members.New API
Usage:
Tests
Added a
WhenRespondingWithProblemDetailsspec group covering theapplication/problem+jsoncontent-type, the status/title defaults, suppliedtitle/detail/type/instance, serialized extension members, and interaction withTimes(n). Full suite is green on bothnet8.0andnet472.Notes
AcceptApiChanges.ps1; the regenerated*.verified.txtfiles are included.