{ "openapi": "3.0.0", "info": { "title": "API de productos", "description": "API de gestion de productos", "version": "0.1.0" }, "servers": [ { "url": "http://localhost:3500/api" } ], "paths": { "/getToken": { "get": { "tags": [ "Login" ], "summary": "Devuelve un token de autorización", "responses": { "200": { "description": "Devuelve un token JWT para autenticarse", "content": { "application/json": { "schema": { "type": "object", "properties": { "token": { "type": "string" } }, "example": { "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJtc2ciOiJ0b2tlbiBkZSBhdXRlbnRpY2FjaW9uIiwiaWF0IjoxNzExNTQ3NzcwLCJleHAiOjE3MTE2MzQxNzB9.Hv-CIlUl7pOTZ-siJ2YewRTtNvo7pr1slN_5RSTjvtY" } } } } }, "500": { "description": "Ha habido un error en el servidor", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } } } } }, "/productos": { "get": { "tags": [ "Producto" ], "security": [ { "ApiKeyAuth": [] } ], "summary": "Devuelve una lista con todos los productos", "responses": { "200": { "description": "Listado de productos", "content": { "application/json": { "schema": { "type": "object", "properties": { "productos": { "type": "array", "items": { "$ref": "#/components/schemas/Productos" } } } } } } }, "401": { "description": "Token incorrecto", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } }, "example": { "msg": "TOKEN NO ENCONTRADO" } } } } }, "500": { "description": "Ha habido un error en el servidor", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } } } } }, "/producto/{id}": { "get": { "tags": [ "Producto" ], "security": [ { "ApiKeyAuth": [] } ], "summary": "Devuelve un producto", "parameters": [ { "in": "path", "name": "id", "schema": { "type": "integer" }, "required": true, "description": "ID del producto" } ], "responses": { "200": { "description": "Producto con su ID", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Productos" } } } }, "401": { "description": "Token incorrecto", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } }, "example": { "msg": "TOKEN NO ENCONTRADO" } } } } }, "500": { "description": "Ha habido un error en el servidor", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } } } } }, "/createProducto": { "post": { "tags": [ "Producto" ], "security": [ { "ApiKeyAuth": [] } ], "summary": "Crea un producto", "requestBody": { "descripcion": "Definición del objeto a crear", "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "titulo": { "type": "string" }, "descripcion": { "type": "string" }, "estado": { "type": "integer" } } } } } }, "responses": { "201": { "description": "Producto con su ID", "content": { "application/json": { "schema": { "type": "object", "properties": { "producto": { "$ref": "#/components/schemas/Productos" }, "msg": { "type": "string" } } } } } }, "200": { "description": "Producto con su ID", "content": { "application/json": { "schema": { "type": "object", "properties": { "producto": { "$ref": "#/components/schemas/Productos" }, "msg": { "type": "string" } } } } } }, "400": { "description": "No se informa del Título del producto", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "401": { "description": "Token incorrecto", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } }, "example": { "msg": "TOKEN NO ENCONTRADO" } } } } }, "500": { "description": "Ha habido un error en el servidor", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } } } } }, "/updateProducto/{id}": { "put": { "tags": [ "Producto" ], "security": [ { "ApiKeyAuth": [] } ], "summary": "Modifica un producto", "parameters": [ { "in": "path", "name": "id", "schema": { "type": "integer" }, "required": true, "description": "ID del producto" } ], "requestBody": { "descripcion": "Definición del objeto a modificar", "required": true, "content": { "application/json": { "schema": { "type": "object", "properties": { "titulo": { "type": "string" }, "descripcion": { "type": "string" }, "estado": { "type": "integer" } } } } } }, "responses": { "200": { "description": "Producto con su ID", "content": { "application/json": { "schema": { "type": "object", "properties": { "producto": { "$ref": "#/components/schemas/Productos" }, "msg": { "type": "string" } } } } } }, "400": { "description": "No se encontró el ID", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "401": { "description": "Token incorrecto", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } }, "example": { "msg": "TOKEN NO ENCONTRADO" } } } } }, "500": { "description": "Ha habido un error en el servidor", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } } } } }, "/deleteProducto/{id}": { "delete": { "tags": [ "Producto" ], "security": [ { "ApiKeyAuth": [] } ], "summary": "Elimina un producto", "parameters": [ { "in": "path", "name": "id", "schema": { "type": "integer" }, "required": true, "description": "ID del producto" } ], "responses": { "200": { "description": "Se ha eliminado un producto", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } }, "401": { "description": "Token incorrecto", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } }, "example": { "msg": "TOKEN NO ENCONTRADO" } } } } }, "500": { "description": "Ha habido un error en el servidor", "content": { "application/json": { "schema": { "type": "object", "properties": { "msg": { "type": "string" } } } } } } } } } }, "components": { "schemas": { "Productos": { "type": "object", "properties": { "id": { "type": "integer" }, "titulo": { "type": "string" }, "descripcion": { "type": "string" }, "estado": { "type": "integer" }, "createdAt": { "type": "string", "format": "date" }, "updatedAt": { "type": "string", "format": "date" } } } }, "securitySchemes": { "ApiKeyAuth": { "type": "apiKey", "in": "header", "name": "token" } } }, "tags": [ { "name": "Login", "description": "Paths en relación a la autentificación del usuario" }, { "name": "Producto", "description": "Paths en relación al manejo de los Productos" } ] }