HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
🧚
[1기]최종 프로젝트 데브코스
/
[팀3] 아이육
[팀3] 아이육
/
🎁
API 응답 포맷
🎁

API 응답 포맷

최종 편집일
Dec 4, 2021 07:06 AM
날짜
Nov 28, 2021 04:13 PM
상태
설계
담당자
현호 유
응답 성공 공통 포멧페이지네이션 응답에러 응답 바디 공통 포맷

응답 성공 공통 포멧

{ "data":{ ... }, "serverDateTime":"2021-11-05T16:55:37.436056" }
 

페이지네이션 응답

"pageable": { "sort": { "empty": true, "unsorted": true, "sorted": false }, "offset": 20, "pageNumber": 2, "pageSize": 10, "paged": true, "unpaged": false }, "totalElements": 33, -> o "totalPages": 4, "last": false, "size": 10, -> o "number": 2, "sort": { "empty": true, "unsorted": true, "sorted": false }, "numberOfElements": 10, "first": false, "empty": false },
  • totalElements
  • last
 
"totalElements": 33 "last": false "size": 10

에러 응답 바디 공통 포맷

{ "message": " Invalid Input Value", // "errors":[], 비어있을 경우 null 이 아닌 빈 배열을 응답한다. "errors": [ { "field": "name.last", "value": "", "reason": "must not be empty" }, { "field": "name.first", "value": "", "reason": "must not be empty" } ], "code": "C001" }
  • https://cheese10yun.github.io/spring-guide-exception/
{ "status":"NOT_FOUND", "message":"No handler found for DELETE /spring-security-rest/api/xx", "errors":[ "No handler found for DELETE /spring-security-rest/api/xx" ] }
  • https://www.baeldung.com/global-error-handler-in-a-spring-rest-api