{ "openapi": "3.0.0", "info": { "title": "API de Desenvolvedores e Projetos", "description": "API para gerenciar desenvolvedores e seus projetos", "version": "1.0.0", "contact": { "name": "Samuel Fava", "email": "samuel@exemplo.com" } }, "servers": [ { "url": "http://localhost:3000/api/v1", "description": "Servidor de desenvolvimento" } ], "paths": { "/devs": { "get": { "summary": "Listar todos os desenvolvedores", "tags": ["Desenvolvedores"], "responses": { "200": { "description": "Lista de desenvolvedores", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/Dev" } } } } } } }, "post": { "summary": "Criar novo desenvolvedor", "tags": ["Desenvolvedores"], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateDevInput" } } } }, "responses": { "201": { "description": "Desenvolvedor criado com sucesso", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Dev" } } } }, "400": { "description": "Dados inválidos", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/devs/{id}": { "get": { "summary": "Buscar desenvolvedor por ID", "tags": ["Desenvolvedores"], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Desenvolvedor encontrado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/DevWithProjects" } } } }, "404": { "description": "Desenvolvedor não encontrado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } }, "put": { "summary": "Atualizar desenvolvedor", "tags": ["Desenvolvedores"], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UpdateDevInput" } } } }, "responses": { "200": { "description": "Desenvolvedor atualizado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Dev" } } } } } }, "delete": { "summary": "Deletar desenvolvedor", "tags": ["Desenvolvedores"], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Desenvolvedor deletado", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string" } } } } } }, "400": { "description": "Desenvolvedor possui projetos vinculados", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } } } } }, "/projects": { "get": { "summary": "Listar todos os projetos", "tags": ["Projetos"], "responses": { "200": { "description": "Lista de projetos", "content": { "application/json": { "schema": { "type": "array", "items": { "$ref": "#/components/schemas/ProjectWithDevs" } } } } } } }, "post": { "summary": "Criar novo projeto", "tags": ["Projetos"], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/CreateProjectInput" } } } }, "responses": { "201": { "description": "Projeto criado com sucesso", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProjectWithDevs" } } } } } } }, "/projects/{id}": { "get": { "summary": "Buscar projeto por ID", "tags": ["Projetos"], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Projeto encontrado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProjectWithDevs" } } } } } }, "put": { "summary": "Atualizar projeto", "tags": ["Projetos"], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } } ], "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/UpdateProjectInput" } } } }, "responses": { "200": { "description": "Projeto atualizado", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ProjectWithDevs" } } } } } }, "delete": { "summary": "Deletar projeto", "tags": ["Projetos"], "parameters": [ { "name": "id", "in": "path", "required": true, "schema": { "type": "string" } } ], "responses": { "200": { "description": "Projeto deletado", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string" } } } } } } } } } }, "components": { "schemas": { "Dev": { "type": "object", "properties": { "id": { "type": "string", "example": "64a1b2c3d4e5f6789abc1234" }, "name": { "type": "string", "example": "Samuel Fava" }, "email": { "type": "string", "format": "email", "example": "samuel@exemplo.com" }, "techs": { "type": "array", "items": { "type": "string" }, "example": ["JavaScript", "TypeScript", "Node.js"] }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" } } }, "DevWithProjects": { "allOf": [ { "$ref": "#/components/schemas/Dev" }, { "type": "object", "properties": { "devProjects": { "type": "array", "items": { "$ref": "#/components/schemas/DevProject" } } } } ] }, "Project": { "type": "object", "properties": { "id": { "type": "string", "example": "64a1b2c3d4e5f6789abc5678" }, "name": { "type": "string", "example": "E-commerce React" }, "description": { "type": "string", "example": "Plataforma de vendas online completa" }, "url": { "type": "string", "format": "uri", "example": "https://github.com/empresa/ecommerce" }, "createdAt": { "type": "string", "format": "date-time" }, "updatedAt": { "type": "string", "format": "date-time" } } }, "ProjectWithDevs": { "allOf": [ { "$ref": "#/components/schemas/Project" }, { "type": "object", "properties": { "devProjects": { "type": "array", "items": { "$ref": "#/components/schemas/DevProjectWithDev" } } } } ] }, "DevProject": { "type": "object", "properties": { "id": { "type": "string" }, "devId": { "type": "string" }, "projectId": { "type": "string" } } }, "DevProjectWithDev": { "allOf": [ { "$ref": "#/components/schemas/DevProject" }, { "type": "object", "properties": { "dev": { "$ref": "#/components/schemas/Dev" } } } ] }, "CreateDevInput": { "type": "object", "required": ["name", "email", "techs"], "properties": { "name": { "type": "string", "example": "Samuel Fava" }, "email": { "type": "string", "format": "email", "example": "samuel@exemplo.com" }, "techs": { "type": "array", "items": { "type": "string" }, "minItems": 1, "example": ["JavaScript", "TypeScript"] }, "devProjects": { "type": "array", "items": { "type": "object", "properties": { "projectId": { "type": "string" } } } } } }, "UpdateDevInput": { "type": "object", "properties": { "name": { "type": "string" }, "email": { "type": "string", "format": "email" }, "techs": { "type": "array", "items": { "type": "string" } }, "devProjects": { "type": "array", "items": { "type": "object", "properties": { "projectId": { "type": "string" } } } } } }, "CreateProjectInput": { "type": "object", "required": ["name", "description", "url", "devProjects"], "properties": { "name": { "type": "string", "example": "E-commerce React" }, "description": { "type": "string", "example": "Plataforma de vendas online completa" }, "url": { "type": "string", "format": "uri", "example": "https://github.com/empresa/ecommerce" }, "devProjects": { "type": "array", "items": { "type": "object", "properties": { "devId": { "type": "string" } } }, "minItems": 1 } } }, "UpdateProjectInput": { "type": "object", "properties": { "name": { "type": "string" }, "description": { "type": "string" }, "url": { "type": "string", "format": "uri" }, "devProjects": { "type": "array", "items": { "type": "object", "properties": { "devId": { "type": "string" } } } } } }, "Error": { "type": "object", "properties": { "error": { "type": "string", "example": "Mensagem de erro detalhada" } } } } } }