openapi: 3.0.3 info: title: Ainyx Backend API version: 1.0.0 description: | REST API for managing users with name and date of birth. Age is calculated dynamically from dob in responses. servers: - url: http://localhost:3000 description: Local development server paths: /health: get: tags: - Health summary: Health check responses: '200': description: Service is healthy content: application/json: schema: $ref: '#/components/schemas/HealthResponse' example: status: ok /users: post: tags: - Users summary: Create a user requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/CreateUserRequest' example: name: Jane Doe dob: '1995-04-20' responses: '201': description: User created successfully content: application/json: schema: $ref: '#/components/schemas/User' example: id: 1 name: Jane Doe dob: '1995-04-20' age: 31 '400': description: Invalid request body or validation error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' examples: invalidBody: value: error: invalid request body validationError: value: error: "Key: 'createUserRequest.Name' Error: Field validation for 'Name' failed on the 'required' tag" invalidDate: value: error: dob must be in YYYY-MM-DD format '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' get: tags: - Users summary: List users parameters: - in: query name: limit schema: type: integer minimum: 1 maximum: 100 default: 10 description: Maximum number of records to return - in: query name: offset schema: type: integer minimum: 0 default: 0 description: Number of records to skip responses: '200': description: List of users content: application/json: schema: type: array items: $ref: '#/components/schemas/User' example: - id: 1 name: Jane Doe dob: '1995-04-20' age: 31 - id: 2 name: John Smith dob: '2000-08-12' age: 25 '400': description: Invalid query parameters or validation error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' /users/{id}: parameters: - in: path name: id required: true schema: type: integer format: int32 description: User ID get: tags: - Users summary: Get a user by ID responses: '200': description: User found content: application/json: schema: $ref: '#/components/schemas/User' example: id: 1 name: Jane Doe dob: '1995-04-20' age: 31 '400': description: Invalid user id content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' example: error: invalid user id '404': description: User not found content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' example: error: user not found '500': description: Internal server error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' put: tags: - Users summary: Update a user requestBody: required: true content: application/json: schema: $ref: '#/components/schemas/UpdateUserRequest' example: name: Jane Doe dob: '1994-01-15' responses: '200': description: User updated successfully content: application/json: schema: $ref: '#/components/schemas/User' example: id: 1 name: Jane Doe dob: '1994-01-15' age: 32 '400': description: Invalid user id, request body, or validation error content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '404': description: User 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: - Users summary: Delete a user responses: '204': description: User deleted successfully '400': description: Invalid user id content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' '404': description: User 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: HealthResponse: type: object properties: status: type: string example: ok required: - status CreateUserRequest: type: object required: - name - dob properties: name: type: string example: Jane Doe dob: type: string format: date example: '1995-04-20' UpdateUserRequest: type: object required: - name - dob properties: name: type: string example: Jane Doe dob: type: string format: date example: '1994-01-15' User: type: object properties: id: type: integer format: int32 example: 1 name: type: string example: Jane Doe dob: type: string format: date example: '1995-04-20' age: type: integer example: 31 required: - id - name - dob - age ErrorResponse: type: object properties: error: type: string example: internal server error required: - error