swsnu / swppfall2021

Learning Software Engineering By Building Web Services
28 stars 19 forks source link

[HW4] Response of JSON about POST, PUT request of article & comment #112

Open KylusheL opened 3 years ago

KylusheL commented 3 years ago

POST /api/article/: Create an article with the information given by request JSON body and response with 201. Posted article (with it's assigned id) should be included in response's content as JSON format.

PUT /api/article/:article_id/: Update the target article with the information given by request JSON body and response with 200. Updated article (with it's id) should be included in response's content as JSON format.

POST /api/article/:article_id/comment/: Create a comment with the information given by request JSON body and response with 201. Posted comment (with it's assigned id) should be included in response's content as JSON format.

PUT /api/comment/:comment_id/: Update the target comment with the information given by request JSON body and response with 200. Updated comment (with it's id) should be included in response's content as JSON format.

about these 4 requests, I'm not sure about how should I make JSON response. Can I get more detail about what should be included in response's content?

Thank you.

ttoru96 commented 3 years ago

For JSON resposne, you should include the posted/updated article or comment with it's assigned id.

That is, if the request is to either post or update an article, the JSON response should have id, title, content, author as key and corresponding value as value. If the request is to either post or update a comment, the JSON resposne should have id, id of the article, content, and author as key and corresponding value as value.

Thank you.

KylusheL commented 3 years ago

Thank you.

I have one more question. In JSON response, corresponding value of the key 'article', 'author' should be its own id? (article's id, author's id)

ttoru96 commented 3 years ago

If the request is related to comment, value for article key should be id of the article that the comment belongs to, and value for author key should be id of the author who wrote the comment.

If the request is related to article, value for author key should be id of the author who wrote the article.

KylusheL commented 3 years ago

Thanks a lot.