swagger.tsā¢11.9 kB
import { ProjectStatus, TaskStatus } from '../models/types';
export const swaggerDocument = {
openapi: '3.0.0',
info: {
title: 'Project Tracker API',
version: '1.0.0',
description: 'API for managing projects and tasks with MCP integration',
},
tags: [
{
name: 'Projects',
description: 'Operations related to project management',
},
{
name: 'Tasks',
description: 'Operations related to task management',
},
],
components: {
schemas: {
Project: {
type: 'object',
properties: {
id: { type: 'string' },
name: { type: 'string' },
description: { type: 'string', nullable: true },
startDate: { type: 'string', format: 'date-time' },
endDate: { type: 'string', format: 'date-time' },
status: { type: 'string', enum: Object.values(ProjectStatus) },
createdAt: { type: 'string', format: 'date-time' },
updatedAt: { type: 'string', format: 'date-time' },
},
required: ['name', 'startDate', 'endDate', 'status'],
},
Task: {
type: 'object',
properties: {
id: { type: 'string' },
title: { type: 'string' },
assignedTo: { type: 'string' },
status: { type: 'string', enum: Object.values(TaskStatus) },
dueDate: { type: 'string', format: 'date-time' },
projectId: { type: 'string' },
createdAt: { type: 'string', format: 'date-time' },
updatedAt: { type: 'string', format: 'date-time' },
},
required: ['title', 'assignedTo', 'status', 'dueDate', 'projectId'],
},
Error: {
type: 'object',
properties: {
message: { type: 'string' },
code: { type: 'string' },
statusCode: { type: 'number' },
},
required: ['message', 'statusCode'],
},
},
},
paths: {
'/api/projects': {
get: {
tags: ['Projects'],
summary: 'Get all projects',
parameters: [
{
name: 'status',
in: 'query',
schema: { type: 'string', enum: Object.values(ProjectStatus) },
},
{
name: 'startDate',
in: 'query',
schema: { type: 'string', format: 'date-time' },
},
{
name: 'endDate',
in: 'query',
schema: { type: 'string', format: 'date-time' },
},
],
responses: {
200: {
description: 'List of projects',
content: {
'application/json': {
schema: {
type: 'array',
items: { $ref: '#/components/schemas/Project' },
},
},
},
},
},
},
post: {
tags: ['Projects'],
summary: 'Create a new project',
requestBody: {
required: true,
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Project' },
},
},
},
responses: {
201: {
description: 'Project created',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Project' },
},
},
},
400: {
description: 'Validation error',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
},
},
},
'/api/projects/{id}': {
get: {
tags: ['Projects'],
summary: 'Get a project by ID',
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string' },
},
],
responses: {
200: {
description: 'Project found',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Project' },
},
},
},
404: {
description: 'Project not found',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
},
},
put: {
tags: ['Projects'],
summary: 'Update a project',
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string' },
},
],
requestBody: {
required: true,
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Project' },
},
},
},
responses: {
200: {
description: 'Project updated',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Project' },
},
},
},
400: {
description: 'Validation error',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
404: {
description: 'Project not found',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
},
},
delete: {
tags: ['Projects'],
summary: 'Delete a project',
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string' },
},
],
responses: {
200: {
description: 'Project deleted',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Project' },
},
},
},
404: {
description: 'Project not found',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
},
},
},
'/api/tasks': {
get: {
tags: ['Tasks'],
summary: 'Get all tasks',
parameters: [
{
name: 'status',
in: 'query',
schema: { type: 'string', enum: Object.values(TaskStatus) },
},
{
name: 'assignedTo',
in: 'query',
schema: { type: 'string' },
},
{
name: 'dueDate',
in: 'query',
schema: { type: 'string', format: 'date-time' },
},
],
responses: {
200: {
description: 'List of tasks',
content: {
'application/json': {
schema: {
type: 'array',
items: { $ref: '#/components/schemas/Task' },
},
},
},
},
},
},
post: {
tags: ['Tasks'],
summary: 'Create a new task',
requestBody: {
required: true,
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Task' },
},
},
},
responses: {
201: {
description: 'Task created',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Task' },
},
},
},
400: {
description: 'Validation error',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
404: {
description: 'Project not found',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
},
},
},
'/api/tasks/{id}': {
get: {
tags: ['Tasks'],
summary: 'Get a task by ID',
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string' },
},
],
responses: {
200: {
description: 'Task found',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Task' },
},
},
},
404: {
description: 'Task not found',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
},
},
put: {
tags: ['Tasks'],
summary: 'Update a task',
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string' },
},
],
requestBody: {
required: true,
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Task' },
},
},
},
responses: {
200: {
description: 'Task updated',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Task' },
},
},
},
400: {
description: 'Validation error',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
404: {
description: 'Task not found',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
},
},
delete: {
tags: ['Tasks'],
summary: 'Delete a task',
parameters: [
{
name: 'id',
in: 'path',
required: true,
schema: { type: 'string' },
},
],
responses: {
200: {
description: 'Task deleted',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Task' },
},
},
},
404: {
description: 'Task not found',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
},
},
},
'/api/tasks/project/{projectId}': {
get: {
tags: ['Tasks'],
summary: 'Get tasks for a specific project',
parameters: [
{
name: 'projectId',
in: 'path',
required: true,
schema: { type: 'string' },
},
],
responses: {
200: {
description: 'List of tasks for the project',
content: {
'application/json': {
schema: {
type: 'array',
items: { $ref: '#/components/schemas/Task' },
},
},
},
},
404: {
description: 'Project not found',
content: {
'application/json': {
schema: { $ref: '#/components/schemas/Error' },
},
},
},
},
},
},
},
};