RA.Utilities.Api.Response
· 3 min read
Version 10.2.0
Adds PaymentRequiredResponse for HTTP 402 and raises the RA.Utilities.Core.Constants dependency to 10.1.1, which introduces the matching code, message, and ResponseType member.
✨ New Features
PaymentRequiredResponse: A newResponse<ErrorResult>model for HTTP 402 responses, withResponseCode = 402,ResponseType = ResponseType.PaymentRequired, andResponseMessage = "Payment is required to access this resource.". It ships with three constructors:(ErrorResult? result = null)for the standard envelope,(int responseCode, string responseMessage)for custom values with anullresult, and(ErrorResult result, int? responseCode, string responseMessage = "")for an explicit payload.RA.Utilities.Core.Constants10.1.1:BaseResponseCode.PaymentRequired(402),BaseResponseMessages.PaymentRequired, andResponseType.PaymentRequired(enum value18) are now available. The new member is appended, so existing numeric wire values are unchanged.
📝 Notes
- With default
System.Text.Jsonoptions the new type serializes as"responseType": 18; registerJsonStringEnumConverterto emit"PaymentRequired".
Version 10.1.0
This release aligns the namespace with the package name, redesigns the constructor overloads around static readonly constants, and adopts the enum-based ResponseType serialization from RA.Utilities.Core.Constants v10.0.4.
⚠️ Breaking Changes
- Namespace renamed to
RA.Utilities.Api.Response: All public types moved fromRA.Utilities.Api.ResultstoRA.Utilities.Api.Response, matching the package id and removing the mismatch with the deprecatedRA.Utilities.Api.Resultspackage. Migration: Replaceusing RA.Utilities.Api.Results;withusing RA.Utilities.Api.Response;and update any fully qualified names. See the Migration Guide. - Constructor overloads split: Optional parameters that used
BaseResponseCode/BaseResponseMessagesvalues are replaced by convenience constructors plus all-argument overloads, because those constants are nowstatic readonly(not compile-time constants).BadRequestResponseandConflictResponseexplicit overloads now require both a code and a message;SuccessResponse<T>gained(),(int responseCode), and(string responseMessage)constructors. Migration: Prefer the single-payload convenience constructor; for custom values pass the code and message positionally (responseCode: nullkeeps the standard code on nullable overloads). Note that the all-argument overloads defaultresponseMessageto"", not to the standard message. responseTypeis numeric by default: This package now depends onRA.Utilities.Core.Constantsv10.0.4, whereResponseTypeis a plain enum with no built-in converter. JSON output changes from"responseType": "NotFound"to"responseType": 8. Migration: RegisterJsonStringEnumConverter(ConfigureHttpJsonOptionsfor minimal APIs,AddControllers().AddJsonOptionsfor MVC) to keep string values, or update clients to accept the numeric contract.
✨ New Features
- Convenience constructors:
BadRequestResponse(BadRequestResult),BadRequestResponse(BadRequestResult[]),ConflictResponse(ConflictResult),ErrorResponse(ErrorResult?),ForbiddenResponse(ErrorResult?), andNotFoundResponse(NotFoundResult)apply the standard HTTP code,ResponseType, and message with one argument. - Parameterless and message-only success responses:
SuccessResponse<T>(),SuccessResponse<T>(int responseCode), andSuccessResponse<T>(string responseMessage)return a success envelope withResult = default. - Nullable response codes: The error overloads accept
int? responseCode, falling back to the standard code whennullis supplied.
📝 Improvements
UnprocessableResponsenull handling:UnprocessableResponse(ErrorResult)and its explicit overload substitute a standardErrorResultwhen the payload isnull.- XML documentation: Constructor summaries now describe which values each overload applies.
Version 10.0.0
✨ New Features & Improvements
- Package revived: The response models consolidated into
RA.Utilities.Apiin v10.0.6 are published again as the standaloneRA.Utilities.Api.Responsepackage. TheRA.Utilities.Api.Resultsnamespace and all public types were unchanged. RA.Utilities.Apinow depends on this package, so existing consumers receive the types transitively; projects that only need response models can reference this package directly.