openapi: 3.0.3 info: title: "Simple Social Media Application API" description: "Backend API for the Simple Social Media Application" version: "1.0.0" contact: name: "API Support" email: "api.support@contoso.com" servers: - url: http://localhost:8000/api tags: - name: "Posts" - name: "Comments" - name: "Likes" paths: /posts: get: tags: ["Posts"] summary: List all posts description: "Retrieve a list of all posts in the social media application." operationId: getPosts responses: "200": description: "Successfully retrieved the list of posts." content: application/json: schema: type: array items: $ref: "#/components/schemas/Post" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" post: tags: ["Posts"] summary: Create a new post description: "Create a new post in the social media application." operationId: createPost requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreatePostRequest" responses: "201": description: "Successfully created a new post." content: application/json: schema: $ref: "#/components/schemas/Post" "400": description: "Bad request" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /posts/{postId}: get: tags: ["Posts"] summary: Retrieve a specific post by ID description: "Retrieve a specific post by its ID." operationId: getPost parameters: - name: postId in: path required: true schema: type: integer description: "ID of the post to retrieve" responses: "200": description: "Successfully retrieved the post." content: application/json: schema: $ref: "#/components/schemas/Post" "404": description: "Post not found" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" patch: tags: ["Posts"] summary: Update a specific post by ID description: "Update a specific post." operationId: updatePost parameters: - name: postId in: path required: true schema: type: integer description: "ID of the post to update" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdatePostRequest" responses: "200": description: "Successfully updated the post." content: application/json: schema: $ref: "#/components/schemas/Post" "400": description: "Bad request" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: "Post not found" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" delete: tags: ["Posts"] summary: Delete a specific post by ID description: "Delete a specific post." operationId: deletePost parameters: - name: postId in: path required: true schema: type: integer description: "ID of the post to delete" responses: "204": description: "Successfully deleted the post." "404": description: "Post not found" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /posts/{postId}/comments: get: tags: ["Comments"] summary: Retrieve a list of comments for a specific post description: "Retrieve a list of comments for a specific post." operationId: getComments parameters: - name: postId in: path required: true schema: type: integer description: "ID of the post to retrieve comments for" responses: "200": description: "Successfully retrieved the list of comments." content: application/json: schema: type: array items: $ref: "#/components/schemas/Comment" "404": description: "Post not found" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" post: tags: ["Comments"] summary: Create a comment on a specific post description: "Create a comment on a specific post." operationId: createComment parameters: - name: postId in: path required: true schema: type: integer description: "ID of the post to create a comment on" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CreateCommentRequest" responses: "201": description: "Successfully created a comment." content: application/json: schema: $ref: "#/components/schemas/Comment" "400": description: 잘못된 요청 content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: 포스트를 찾을 수 없음 content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /posts/{postId}/comments/{commentId}: get: tags: ["Comments"] summary: Retrieve a specific comment by ID description: "Retrieve a specific comment by its ID." operationId: getComment parameters: - name: postId in: path required: true schema: type: integer description: "ID of the post the comment belongs to" - name: commentId in: path required: true schema: type: integer description: "ID of the comment to retrieve" responses: "200": description: "Successfully retrieved the comment." content: application/json: schema: $ref: "#/components/schemas/Comment" "404": description: 댓글 또는 포스트를 찾을 수 없음 content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" patch: tags: ["Comments"] summary: Update a specific comment by ID description: "Update a specific comment." operationId: updateComment parameters: - name: postId in: path required: true schema: type: integer description: ID of the post the comment belongs to - name: commentId in: path required: true schema: type: integer description: ID of the comment to update requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UpdateCommentRequest" responses: "200": description: 댓글 수정 성공 content: application/json: schema: $ref: "#/components/schemas/Comment" "400": description: "Bad request" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: "Comment or post not found" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" delete: tags: ["Comments"] summary: Delete a specific comment by ID description: "Delete a specific comment." operationId: deleteComment parameters: - name: postId in: path required: true schema: type: integer description: "ID of the post the comment belongs to" - name: commentId in: path required: true schema: type: integer description: "ID of the comment to delete" responses: "204": description: "Successfully deleted the comment." "404": description: "Comment or post not found" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" /posts/{postId}/likes: post: tags: ["Likes"] summary: Like a specific post description: "Like a specific post." operationId: likePost parameters: - name: postId in: path required: true schema: type: integer description: "ID of the post to like" requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LikeRequest" responses: "201": description: "Successfully liked the post." "400": description: "Bad request" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: "Post not found" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" delete: tags: ["Likes"] summary: Unlike a specific post description: "Unlike a specific post." operationId: unlikePost parameters: - name: postId in: path required: true schema: type: integer description: "ID of the post to unlike" responses: "204": description: "Successfully unliked the post." "400": description: "Bad request" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "404": description: "Post not found" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" "500": description: "Internal server error" content: application/json: schema: $ref: "#/components/schemas/ErrorResponse" components: schemas: Post: type: object properties: id: type: integer example: 1 username: type: string example: "alice" content: type: string example: "Hello, this is my first post!" createdAt: type: string format: date-time example: "2025-01-01T12:34:56Z" updatedAt: type: string format: date-time example: "2025-01-01T12:40:00Z" likeCount: type: integer example: 3 commentCount: type: integer example: 10 required: - id - username - content - createdAt - updatedAt - likeCount - commentCount CreatePostRequest: type: object required: - username - content properties: username: type: string example: "alice" content: type: string example: "Hello, this is my first post!" UpdatePostRequest: type: object properties: content: type: string example: "Updated content of the post" required: - content Comment: type: object properties: id: type: integer example: 100 postId: type: integer example: 1 username: type: string example: "bob" content: type: string example: "Nice post!" createdAt: type: string format: date-time example: "2025-01-01T13:00:00Z" updatedAt: type: string format: date-time example: "2025-01-01T13:10:00Z" required: - id - postId - username - content - createdAt - updatedAt CreateCommentRequest: type: object required: - username - content properties: username: type: string example: "bob" content: type: string example: "Nice post!" UpdateCommentRequest: type: object properties: content: type: string example: "Updated comment." required: - content LikeRequest: type: object required: - username properties: username: type: string example: "charlie" ErrorResponse: type: object properties: message: type: string example: "Bad Request, Not Found or Internal Server Error" required: - message