Skip to content

Latest commit

 

History

History
325 lines (253 loc) · 10.7 KB

index.adoc

File metadata and controls

325 lines (253 loc) · 10.7 KB

Personal_blog API Documentation

소개

이 문서는 personal_blog 프로젝트의 API 엔드포인트 목록과 요청, 응답에 따른 결과값을 보여줍니다.

API 목록

  1. /auth/.. : 인증관련 엔드포인트

  2. /articles/.. : 게시물 관련 엔드포인트

  3. /articles/{articleId}/comments/.. : 댓글 관련 엔드포인트

I. 인증

인증 관련 엔드포인트는 사용자의 로그인, 로그아웃, 회원가입을 처리합니다.

1. 로그인

Request
POST /auth/login HTTP/1.1
Content-Type: application/json
Content-Length: 44
Host: localhost:8080

{"loginId":"testUser","password":"password"}
Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 21

{"token":"testToken"}

2. 로그아웃

Request
POST /auth/logout HTTP/1.1
Content-Type: application/json
Authorization: Bearer valid.jwt.token
Host: localhost:8080
Response
HTTP/1.1 204 No Content

3. 회원가입

Request
POST /auth/signup?_csrf=n4hCGZ98q4KnsN1w6On9Cg0c0jGaFT_Q__Vr_KFGXhZ0Em26re11L6lPk7uK1ukT38TJMjR-_1OtJQb9y8NZnsd3bnVFdw_f HTTP/1.1
Content-Type: application/json
Content-Length: 124
Host: localhost:8080

{"loginId":"testUser","password":"password","username":"testUser","createdAt":"2024-08-10T19:38:46.0941894","enabled":false}
Response
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 21

{"token":"testToken"}

II. 게시물

게시물 관련 엔드포인트는 게시물의 생성, 조회, 수정, 삭제를 처리합니다.

1. 게시물 생성

Request
GET /articles HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080
Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 511

[{"articleId":0,"title":"title0","content":"content0","hits":0,"likes":0,"isDeleted":false,"createdAt":"2024-08-12T19:21:16.9133466","updatedAt":"2024-08-12T19:21:16.9133466","userId":null,"loginId":null,"username":null,"contentPaths":[],"commentDtos":[]},{"articleId":1,"title":"title1","content":"content1","hits":0,"likes":0,"isDeleted":false,"createdAt":"2024-08-12T19:21:16.9133466","updatedAt":"2024-08-12T19:21:16.9133466","userId":null,"loginId":null,"username":null,"contentPaths":[],"commentDtos":[]}]

2. 게시물 조회

Request
GET /articles/1 HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080
Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 577

{"articleId":1,"title":"title","content":"content","hits":0,"likes":0,"isDeleted":false,"createdAt":"2024-08-12T19:21:25.5577424","updatedAt":"2024-08-12T19:21:25.5577424","userId":1,"loginId":"loginId","username":"username","contentPaths":[{"contentPathId":1,"path":"/resources/testImages/image1.png","articleId":1},{"contentPathId":2,"path":"/resources/testImages/image2.png","articleId":1}],"commentDtos":[{"commentId":1,"nickname":"nickname","comment":"comment","createdAt":"2024-08-12T19:21:25.5577424","updatedAt":"2024-08-12T19:21:25.5577424","userId":1,"articleId":1}]}

3. 게시물 수정

Request
POST /articles/1/update HTTP/1.1
Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Host: localhost:8080

--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=files; filename=testImage1.png
Content-Type: image/png

�PNG


IHDR   v   V��   ��b'   �sRGB ����   �gAMA  ����a�   	pHYs  ��  ����o�d  ��IDATx^�}LUe�ǿ�r��E�%5H���j�lZX�h��*��-u��\����/Ѭ66��?Z.�b���s$��Ȑ��V
�2�@Aw�T��I�y�s�@�ˡ.x�������y���;�s���v��BMA��:��,�!bI����XRD,)"���K��%EĒ"bI����XRD,)"���K��%EĒ"bI����XRD,)"���K��%EĒ"bI����XRD,)"���K��%EĒ"bI����XRD,)"���K���v^��5���pY6���1����{�������������v�qcޮ�{��/����������ړ��g��7����ص����=n��Ub���L����c;��6-���jܘ�����XRD,)������^����_�ƾ�]��E�^T֜0�W�k޽/YM���<�����[�`S^	N6�m>u���v

�]=������g�8=�����˂}Z�1��Ҋ���,��w>�2��R��EJ��7?Łõ��3\�����E�E:V������؎�:����sO܋�sf�1x�/_��c�x�T���3��]��wә�xy��zM��#G�";�%č�55�q���n���#��eF�@k;ү�����{t�5�r�x�ߘ��7^y�/�}@��-�VT՞4����<y��L��8�''��竁��>�/y��������0c�-���4�Ř����oV�vž��<��4�۱�����Z��������֎����u����U"3{����sw�N��^ż��a��4����me�ݺǔ����G��S��k'O>�W_p�#a�(�Z�=��>̇��7�R�A�{-�''y'��λ��0��N��op���wMv,UA��_��Y��ko�$�{���<�K�>lJ���Ѡ��.�v˴#�
X���+TG����#k�|ď���"b]���n���wt��vׯ~�K�O�Z��w���UN��y�=ք��c�k8mjB��UWQu���}���
��:�aEU��u
3硻��M��>�����'����X���VfnF~�~S����u݊���nNT��
i%�-�7���0�>�A�k=r6�6�����N���&^�h"{R�_k"�>I�;:C]Y$�2(�X�������P������ຟ@�V��ް���{0��dS�7js<���%��`{��Q��x���Zt���Nj�i�a\R�����7o������vKQ�6-Ԯ����H�Y1)"���K��%EĒ"bI����XRD,)"���K��%EĒ"bI����XRD,)"���K��%EĒ"bI����XRD,%�?��
~F`�U    IEND�B`�
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=article
Content-Type: application/json

{ "articleId": 1, "title": "title", "content": "content" }
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--
Response
HTTP/1.1 200 OK
Content-Type: text/plain;charset=UTF-8
Content-Length: 7

Updated

4. 게시물 삭제

Request
PUT /articles/1/delete HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080
Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 7

Deleted

5. 게시물 목록 조회

Request
GET /articles HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080
Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 511

[{"articleId":0,"title":"title0","content":"content0","hits":0,"likes":0,"isDeleted":false,"createdAt":"2024-08-12T19:21:16.9133466","updatedAt":"2024-08-12T19:21:16.9133466","userId":null,"loginId":null,"username":null,"contentPaths":[],"commentDtos":[]},{"articleId":1,"title":"title1","content":"content1","hits":0,"likes":0,"isDeleted":false,"createdAt":"2024-08-12T19:21:16.9133466","updatedAt":"2024-08-12T19:21:16.9133466","userId":null,"loginId":null,"username":null,"contentPaths":[],"commentDtos":[]}]

6. 게시물 좋아요

Request
PUT /articles/1/like HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080
Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 6

Likes!

7. 게시물 좋아요 취소

Request
PUT /articles/1/cancel-like HTTP/1.1
Content-Type: application/json
Accept: application/json
Host: localhost:8080
Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 14

Likes canceled

III. 댓글

댓글 관련 엔드포인트는 댓글의 생성, 조회, 수정, 삭제를 처리합니다.

1. 댓글 생성

Request
POST /articles/1/comments HTTP/1.1
Content-Type: application/json
Content-Length: 166
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0VXNlciIsInVzZXJJZCI6IjEiLCJpYXQiOjE3MjMyODAxMDUsImV4cCI6MTcyMzI4MzcwNX0.cR9hGpeXSbPgHhs38Mxg_Oge_pWUKxse7iFboV4Dy2A
Host: localhost:8080

{"commentId":1,"nickname":"닉네임","comment":"댓글","createdAt":"2024-08-10T17:55:05.0416744","updatedAt":"2024-08-10T17:55:05.0496867","userId":1,"articleId":1}
Response
HTTP/1.1 201 Created
Content-Type: application/json
Content-Length: 166

{"commentId":1,"nickname":"닉네임","comment":"댓글","createdAt":"2024-08-10T17:55:05.0416744","updatedAt":"2024-08-10T17:55:05.0496867","userId":1,"articleId":1}

2. 댓글 수정

Request
PUT /articles/1/comments/1 HTTP/1.1
Content-Type: application/json
Content-Length: 186
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0VXNlciIsInVzZXJJZCI6IjEiLCJpYXQiOjE3MjMyODAxMjMsImV4cCI6MTcyMzI4MzcyM30.dXn7-RtE7IzxvwkEWJrZc9P_ev5HURNx1JOb5l0yNMo
Host: localhost:8080

{"commentId":1,"nickname":"수정된 닉네임","comment":"수정된 댓글","createdAt":"2024-08-10T17:55:22.8891762","updatedAt":"2024-08-10T17:55:22.9479674","userId":1,"articleId":1}
Response
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 186

{"commentId":1,"nickname":"수정된 닉네임","comment":"수정된 댓글","createdAt":"2024-08-10T17:55:22.8891762","updatedAt":"2024-08-10T17:55:22.9479674","userId":1,"articleId":1}

3. 댓글 삭제

Request
DELETE /articles/1/comments/1 HTTP/1.1
Content-Type: application/json
Content-Length: 164
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ0ZXN0VXNlciIsInVzZXJJZCI6IjEiLCJpYXQiOjE3MjMyODAyMDUsImV4cCI6MTcyMzI4MzgwNX0.29iwCJ8HhaMAmCf_wXcqDk0h7T6n5PUxJ0HmXsygFeg
Host: localhost:8080

{"commentId":1,"nickname":"닉네임","comment":"댓글","createdAt":"2024-08-10T17:56:45.285226","updatedAt":"2024-08-10T17:56:45.290222","userId":1,"articleId":1}
Response
HTTP/1.1 204 No Content