--- openapi: 3.0.1 info: title: API V1 version: v1 paths: "/posts/{post_id}/comments": parameters: - name: post_id in: path description: post id required: true schema: type: integer get: summary: Lists all comments for a post tags: - Comments security: - bearer_auth: [] parameters: - name: parent_id in: query required: false description: Parent comment ID schema: type: integer responses: '200': description: comments found content: application/json: schema: type: object properties: comments: type: array items: type: object properties: id: type: integer content: type: string author: type: object properties: id: type: integer email: type: string pagination: type: object properties: count: type: integer page: type: integer items: type: integer pages: type: integer example: comments: - id: 1 content: Lorem ipsum dolor sit amet, consectetur adipiscing elit. author: id: 1 email: lorem@example.com - id: 2 content: Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. author: id: 2 email: ipsum@example.com pagination: count: 50 page: 1 items: 10 pages: 5 post: summary: Creates a comment tags: - Comments security: - bearer_auth: [] parameters: [] responses: '201': description: comment created '422': description: invalid request requestBody: content: application/json: schema: type: object properties: comment: type: object properties: content: type: string example: New comment content parent_id: type: integer required: false example: 1 nullable: true required: - content "/comments/{id}": parameters: - name: id in: path description: comment id required: true schema: type: integer get: summary: Retrieves a comment tags: - Comments security: - bearer_auth: [] responses: '200': description: comment found content: application/json: schema: type: object properties: id: type: integer example: 1 content: type: string example: Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nariatur. author: type: object properties: id: type: integer example: 1 email: type: string example: lorem@example.com '404': description: comment not found put: summary: Updates a comment tags: - Comments security: - bearer_auth: [] parameters: [] responses: '200': description: comment updated '422': description: invalid request requestBody: content: application/json: schema: type: object properties: comment: type: object properties: content: type: string example: Updated comment content required: - content delete: summary: Deletes a comment tags: - Comments security: - bearer_auth: [] responses: '204': description: comment deleted "/feed": get: summary: Retrieves user feed tags: - Feed security: - bearer_auth: [] responses: '200': description: feed retrieved content: application/json: schema: type: object properties: feed: type: array items: type: object properties: id: type: integer content: type: string author: type: object properties: id: type: integer username: type: string created_at: type: string format: date-time example: feed: - id: 1 content: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dol. author: id: 1 first_name: Lorem last_name: Ipsum username: lorem_ipsum second_name: Dolor comments_count: 5 - id: 2 content: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. author: id: 2 first_name: Duis last_name: Aute username: duis_aute second_name: Irure comments_count: 3 pagination: count: 100 page: 1 items: 20 pages: 5 '401': description: unauthorized "/posts": get: summary: Lists all posts tags: - Posts security: - bearer_auth: [] responses: '200': description: posts found content: application/json: schema: type: object properties: posts: type: array items: type: object properties: id: type: integer content: type: string author: type: object properties: id: type: integer first_name: type: string last_name: type: string username: type: string second_name: type: string comments_count: type: integer pagination: type: object properties: count: type: integer page: type: integer items: type: integer pages: type: integer example: posts: - id: 1 content: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dol. author: id: 1 first_name: Lorem last_name: Ipsum username: lorem_ipsum second_name: Dolor comments_count: 5 - id: 2 content: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. author: id: 2 first_name: Duis last_name: Aute username: duis_aute second_name: Irure comments_count: 3 pagination: count: 100 page: 1 items: 20 pages: 5 post: summary: Creates a post tags: - Posts security: - bearer_auth: [] parameters: [] responses: '201': description: post created requestBody: content: application/json: schema: type: object properties: content: type: string example: New post content required: - content "/posts/{id}": parameters: - name: id in: path description: post id required: true schema: type: integer get: summary: Retrieves a post tags: - Posts security: - bearer_auth: [] responses: '200': description: post found content: application/json: schema: type: object properties: id: type: integer content: type: string author: type: object properties: id: type: integer first_name: type: string last_name: type: string username: type: string second_name: type: string comments: type: array items: type: object properties: id: type: integer content: type: string created_at: type: string updated_at: type: string author: type: object properties: id: type: integer username: type: string example: posts: - id: 1 content: Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et lua. author: id: 1 first_name: Lorem last_name: Ipsum username: lorem_ipsum second_name: Dolor comments_count: 5 - id: 2 content: Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. author: id: 2 first_name: Duis last_name: Aute username: duis_aute second_name: Irure comments_count: 3 pagination: count: 100 page: 1 items: 20 pages: 5 '404': description: post not found put: summary: Updates a post tags: - Posts security: - bearer_auth: [] parameters: [] responses: '200': description: post updated '422': description: invalid request requestBody: content: application/json: schema: type: object properties: content: type: string example: Lorem ipsum dolor sit amet, consectetur adipiscing elit. delete: summary: Deletes a post tags: - Posts security: - bearer_auth: [] responses: '204': description: post deleted "/signup": post: summary: Creates a new profile and user tags: - Authentication parameters: [] responses: '201': description: profile created content: application/json: schema: type: object properties: message: type: string example: Signed up successfully. profile: type: object properties: id: type: integer example: 1 email: type: string example: test@example.com user: type: object properties: id: type: integer example: 1 username: type: string example: testuser first_name: type: string example: Test last_name: type: string example: User '422': description: invalid request content: application/json: schema: type: object properties: errors: type: array items: type: string example: Username can't be blank requestBody: content: application/json: schema: type: object properties: profile: type: object properties: email: type: string example: user@example.com password: type: string example: password123 password_confirmation: type: string example: password123 required: - email - password - password_confirmation user: type: object properties: username: type: string example: username first_name: type: string example: John last_name: type: string example: Doe required: - username - first_name - last_name required: - profile - user "/login": post: summary: Creates a session (logs in) tags: - Authentication parameters: [] responses: '200': description: session created content: application/json: schema: type: object properties: message: type: string example: Logged in successfully. token: type: string example: eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIxMjMifQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c required: - message - token '401': description: unauthorized content: application/json: schema: type: object properties: error: type: string example: Invalid Email or password. required: - error requestBody: content: application/json: schema: type: object properties: profile: type: object properties: email: type: string example: user@example.com password: type: string example: password123 required: - email - password required: - profile "/logout": delete: summary: Destroys a session (logs out) tags: - Authentication security: - bearer_auth: [] responses: '200': description: logged out successfully content: application/json: schema: type: object properties: status: type: integer example: 200 message: type: string example: Logged out successfully. required: - status - message '401': description: unauthorized content: application/json: schema: type: object properties: status: type: integer example: 401 message: type: string example: Couldn't find an active session. required: - status - message "/subscriptions": post: summary: Follow a user tags: - Subscriptions security: - bearer_auth: [] parameters: [] responses: '201': description: User followed successfully '422': description: Unable to follow user '404': description: User not found requestBody: content: application/json: schema: type: object properties: id: type: integer example: 22 required: - id "/subscriptions/{id}": delete: summary: Unfollow a user tags: - Subscriptions security: - bearer_auth: [] parameters: - name: id in: path required: true schema: type: integer responses: '200': description: User unfollowed successfully '422': description: Unable to unfollow user '404': description: User not found "/users": get: summary: Lists all users tags: - Users security: - bearer_auth: [] responses: '200': description: users found content: application/json: schema: type: object properties: users: type: array items: type: object properties: id: type: integer first_name: type: string last_name: type: string username: type: string second_name: type: string pagination: type: object properties: count: type: integer page: type: integer items: type: integer pages: type: integer example: users: - id: 1 first_name: Lorem last_name: Ipsum username: lorem_ipsum second_name: Dolor - id: 2 first_name: Sit last_name: Amet username: sit_amet second_name: Consectetur pagination: count: 100 page: 1 items: 20 pages: 5 "/users/{id}": parameters: - name: id in: path description: user id required: true schema: type: integer get: summary: Retrieves a user tags: - Users security: - bearer_auth: [] responses: '200': description: user found content: application/json: schema: type: object properties: id: type: integer example: 1 username: type: string example: lorem_ipsum first_name: type: string example: Lorem second_name: type: string example: Dolor last_name: type: string example: Ipsum posts: type: array items: type: object properties: id: type: integer example: 1 content: type: string example: Lorem ipsum dolor sit amet, consectetur adipiscing elit. comments_count: type: integer example: 5 '404': description: user not found components: schemas: comment: type: object properties: id: type: integer content: type: string author: "$ref": "#/components/schemas/user" created_at: type: string format: date-time updated_at: type: string format: date-time parent_id: type: integer nullable: true required: - id - content - author - created_at - updated_at user: type: object properties: id: type: integer username: type: string required: - id - username pagination: type: object properties: count: type: integer page: type: integer items: type: integer pages: type: integer required: - count - page - items - pages error: type: object properties: error: type: string required: - error errors: type: object properties: errors: type: object additionalProperties: type: array items: type: string required: - errors securitySchemes: bearer_auth: type: http scheme: bearer servers: - url: http://localhost:3000