Problem
While defining a custom response structure (ApiResponse) is standard, enterprise API environments benefit from standard format descriptions such as RFC 7807 (Problem Details for HTTP APIs). The application doesn't currently support standard Problem Detail structures, making it harder to integrate with standard API gateways or tools that expect standard error schemas.
Proposed Solution
Add support for RFC 7807 standard representation. In Spring Boot 3+, Spring has built-in support for ProblemDetail via the org.springframework.http.ProblemDetail class. Configure the application's GlobalExceptionHandler to optionally map exceptions to standard ProblemDetail structures. Standardize the ApiResponse schema fields to match or easily map from standard problem details (type, title, status, detail, instance).
User Stories
- As an API client using automated monitoring tools, I want the API to return RFC 7807-compliant
application/problem+json error responses so that my client tooling can read error semantics natively.
Acceptance Criteria
Tasks
Problem
While defining a custom response structure (
ApiResponse) is standard, enterprise API environments benefit from standard format descriptions such as RFC 7807 (Problem Details for HTTP APIs). The application doesn't currently support standard Problem Detail structures, making it harder to integrate with standard API gateways or tools that expect standard error schemas.Proposed Solution
Add support for RFC 7807 standard representation. In Spring Boot 3+, Spring has built-in support for
ProblemDetailvia theorg.springframework.http.ProblemDetailclass. Configure the application'sGlobalExceptionHandlerto optionally map exceptions to standardProblemDetailstructures. Standardize theApiResponseschema fields to match or easily map from standard problem details (type,title,status,detail,instance).User Stories
application/problem+jsonerror responses so that my client tooling can read error semantics natively.Acceptance Criteria
ProblemDetailformats.spring.mvc.problemdetails.enabled=trueinapplication.propertiesprofiles.ApiResponseincludes fields matching RFC 7807 attributes:type(URI mapping to documentation)title(Short description of exception)detail(Specific message)instance(Request path)application/problem+jsoncontent-type whenever the client explicitly requests it in theAcceptheader.Tasks
spring.mvc.problemdetails.enabledin profiles.ApiResponseto match the key fields ofProblemDetail.GlobalExceptionHandlerhandlers to construct and returnProblemDetail(or a subclass) when appropriate.