openapi: 3.1.0 info: title: Api version: 0.1.0 description: Pulse social media API servers: - url: /api description: Base API path tags: - name: health description: Health operations - name: users description: User operations - name: posts description: Post operations - name: comments description: Comment operations - name: likes description: Like operations - name: follows description: Follow operations - name: feed description: Feed operations paths: /healthz: get: operationId: healthCheck tags: [health] summary: Health check responses: "200": description: Healthy content: application/json: schema: $ref: "#/components/schemas/HealthStatus" /users: get: operationId: listUsers tags: [users] summary: List all users responses: "200": description: List of users content: application/json: schema: type: array items: $ref: "#/components/schemas/User" post: operationId: createUser tags: [users] summary: Create a new user requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UserInput" responses: "201": description: Created content: application/json: schema: $ref: "#/components/schemas/User" /users/{id}: get: operationId: getUser tags: [users] summary: Get a user profile parameters: - name: id in: path required: true schema: type: integer responses: "200": description: User profile content: application/json: schema: $ref: "#/components/schemas/User" "404": description: Not found patch: operationId: updateUser tags: [users] summary: Update a user profile parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/UserUpdate" responses: "200": description: Updated user content: application/json: schema: $ref: "#/components/schemas/User" /users/{id}/stats: get: operationId: getUserStats tags: [users] summary: Get user stats (followers, following, post count) parameters: - name: id in: path required: true schema: type: integer responses: "200": description: User stats content: application/json: schema: $ref: "#/components/schemas/UserStats" /users/{id}/posts: get: operationId: getUserPosts tags: [users] summary: Get posts by a user parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Posts by user content: application/json: schema: type: array items: $ref: "#/components/schemas/Post" /users/{id}/followers: get: operationId: getFollowers tags: [follows] summary: Get a user's followers parameters: - name: id in: path required: true schema: type: integer responses: "200": description: List of followers content: application/json: schema: type: array items: $ref: "#/components/schemas/User" /users/{id}/following: get: operationId: getFollowing tags: [follows] summary: Get users that a user is following parameters: - name: id in: path required: true schema: type: integer responses: "200": description: List of followed users content: application/json: schema: type: array items: $ref: "#/components/schemas/User" /users/{id}/follow: post: operationId: toggleFollow tags: [follows] summary: Follow or unfollow a user parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/FollowInput" responses: "200": description: Follow status content: application/json: schema: $ref: "#/components/schemas/FollowStatus" /posts: get: operationId: listPosts tags: [posts] summary: List all posts (global feed) responses: "200": description: List of posts content: application/json: schema: type: array items: $ref: "#/components/schemas/Post" post: operationId: createPost tags: [posts] summary: Create a new post requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/PostInput" responses: "201": description: Created post content: application/json: schema: $ref: "#/components/schemas/Post" /posts/trending: get: operationId: getTrendingPosts tags: [posts] summary: Get trending posts (most liked) responses: "200": description: Trending posts content: application/json: schema: type: array items: $ref: "#/components/schemas/Post" /posts/{id}: get: operationId: getPost tags: [posts] summary: Get a single post parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Post content: application/json: schema: $ref: "#/components/schemas/Post" "404": description: Not found delete: operationId: deletePost tags: [posts] summary: Delete a post parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted /posts/{id}/like: post: operationId: toggleLike tags: [likes] summary: Like or unlike a post parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LikeInput" responses: "200": description: Like status content: application/json: schema: $ref: "#/components/schemas/LikeStatus" /posts/{id}/comments: get: operationId: getPostComments tags: [comments] summary: Get comments for a post parameters: - name: id in: path required: true schema: type: integer responses: "200": description: Comments content: application/json: schema: type: array items: $ref: "#/components/schemas/Comment" post: operationId: createComment tags: [comments] summary: Add a comment to a post parameters: - name: id in: path required: true schema: type: integer requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/CommentInput" responses: "201": description: Created comment content: application/json: schema: $ref: "#/components/schemas/Comment" /comments/{id}: delete: operationId: deleteComment tags: [comments] summary: Delete a comment parameters: - name: id in: path required: true schema: type: integer responses: "204": description: Deleted /feed/{userId}: get: operationId: getFeed tags: [feed] summary: Get personalized feed for a user (posts from followed users) parameters: - name: userId in: path required: true schema: type: integer responses: "200": description: Personalized feed content: application/json: schema: type: array items: $ref: "#/components/schemas/Post" /session: get: operationId: getSession tags: [users] summary: Get the current session user responses: "200": description: Session user content: application/json: schema: $ref: "#/components/schemas/SessionUser" post: operationId: loginUser tags: [users] summary: Login as a user (by username) requestBody: required: true content: application/json: schema: $ref: "#/components/schemas/LoginInput" responses: "200": description: Logged in user content: application/json: schema: $ref: "#/components/schemas/User" delete: operationId: logoutUser tags: [users] summary: Logout current user responses: "204": description: Logged out components: schemas: HealthStatus: type: object properties: status: type: string required: - status User: type: object required: [id, username, displayName, createdAt] properties: id: type: integer username: type: string displayName: type: string bio: type: ["string", "null"] avatarUrl: type: ["string", "null"] createdAt: type: string UserInput: type: object required: [username, displayName] properties: username: type: string minLength: 2 displayName: type: string minLength: 1 bio: type: string avatarUrl: type: string UserUpdate: type: object properties: displayName: type: string bio: type: string avatarUrl: type: string UserStats: type: object required: [userId, followerCount, followingCount, postCount] properties: userId: type: integer followerCount: type: integer followingCount: type: integer postCount: type: integer Post: type: object required: [id, content, authorId, authorUsername, authorDisplayName, likeCount, commentCount, createdAt] properties: id: type: integer content: type: string imageUrl: type: ["string", "null"] authorId: type: integer authorUsername: type: string authorDisplayName: type: string authorAvatarUrl: type: ["string", "null"] likeCount: type: integer commentCount: type: integer likedByCurrentUser: type: boolean createdAt: type: string PostInput: type: object required: [content, authorId] properties: content: type: string minLength: 1 imageUrl: type: string authorId: type: integer Comment: type: object required: [id, content, postId, authorId, authorUsername, authorDisplayName, createdAt] properties: id: type: integer content: type: string postId: type: integer authorId: type: integer authorUsername: type: string authorDisplayName: type: string authorAvatarUrl: type: ["string", "null"] createdAt: type: string CommentInput: type: object required: [content, authorId] properties: content: type: string minLength: 1 authorId: type: integer LikeInput: type: object required: [userId] properties: userId: type: integer LikeStatus: type: object required: [liked, likeCount] properties: liked: type: boolean likeCount: type: integer FollowInput: type: object required: [followerId] properties: followerId: type: integer FollowStatus: type: object required: [following] properties: following: type: boolean SessionUser: type: object properties: user: $ref: "#/components/schemas/User" LoginInput: type: object required: [username] properties: username: type: string