swsnu / swppfall2019

31 stars 23 forks source link

[HW3] Comment 관련 질문 있습니다. #133

Open ulgal opened 4 years ago

ulgal commented 4 years ago

response에 comment(assigned id | it's id)가 들어있어야 한다는게 { "id": comment_id, "content": "blabla" } 이런식으로 response가 나오면 되는건가요? 아니면 { "id": comment_id, "article": article_id, "content": "blabla", "author": author_id } 이런식으로 comment model에 있는 다른 애들도 다 포함되어야 하나요?

ktaebum commented 4 years ago

네 그부분은 밑에 적으신 것처럼 id + (GET을 했을 때 가져오는 정보)인

{
"id": comment_id,
"article": article_id,
"content": "blabla",
"author": author_id
}

로 해주시면 됩니다 (해당 model의 field들을 기준)

POST and PUT requests should contain data using the JSON format in the body of the request. For each model, the JSON format should look like:

User : {username: string, password: string}
Article : {title: string, content: string}
Comment : {content: string}

이 부분 때문에 헷갈릴 수 있다고 생각하는데 저기서 저 field만 요구되는 이유는 Article을 만들거나 바꿀 때, 혹은 comment를 만들거나 바꿀 때 딱 필요한 정보가 저만큼이기 때문입니다. article id는 parameter로 넘어올 것이구요 api/article/:id (comment 에서도 어떤 article의 comment인지 알 수 있으니 마찬가지겠죠?) user 정보는 request 안에 포함이 되어 있기 때문에 POST PUT에 대해서는 저 정보만 있으면 되고

Posted comment (with it's assigned id) should be included in response's content as JSON format. 의 의미는 response content에 업데이트 / 추가 내역을 반영을 해서 실제로 잘 반영이 되었는지 확인해보라는 의미에서 적었습니다

혼란을 드려 죄송합니다 😂

ulgal commented 4 years ago

감사합니다. 추가적으로 궁금한게 있는데 sign in 상태에서 sign up하는 경우가 일반적으론 허용되지 않는 것 같은데 스펙 상 별다른 언급이 없어 이런 테스트 케이스는 들어오지 않는다고 생각하면 되나요?

ktaebum commented 4 years ago

네 sign in 상태에서 sign up 하는 경우는 생각하지 않으셔도 되구요 (스펙 상에서도 sign up에 대해서는Create a user with the information given by request JSON body and response with 201 내용만 있구요) 하지만 sign in이 안 되어있는 상태에서 sign out을 하는 경우는 고려하셔야 합니다

ulgal commented 4 years ago

감사합니다!

ktaebum commented 4 years ago

아 물론 username이나 password가 빠져서 sign up이 안 되는 기본적인 경우는 고려 하셔야 하구요

적고 지우긴 했는데 사실 다른 분들도 이 부분을 조금 궁금해 하실수도 있는데

이런 것에 대한 확인은 (username이 비어있는지, password가 특수문자, 길이 등 제한조건을 만족하는지) frontend에서 할 수 있기 때문에 (form validation, 과제 1에서도 했었죠) sign up에서는 크게 고려하지 않으셔도 됩니다.

lightb0x commented 4 years ago

이 답변을 보고 질문이 생겼습니다.

네 그부분은 밑에 적으신 것처럼 id + (GET을 했을 때 가져오는 정보)인

{
"id": comment_id,
"article": article_id,
"content": "blabla",
"author": author_id
}

로 해주시면 됩니다 (해당 model의 field들을 기준)

라고 써주셨는데, id가 출력에 포함되어야 하는건가요?

{
"article": article_id
"content": "blah_blah"
"author": author_id
}

이렇게 id 가 생략되면 안되는건가요?