{ "swagger": "2.0", "info": { "description": "API simples para demonstrar o uso de containers Docker e suas integrações usando Docker Compose.", "title": "API de Comida.", "contact": { "name": "Luis Gabriel da Costa Silva", "email": "lgcs10@aluno.ifal.edu.br" }, "version": "1.0" }, "basePath": "/api", "paths": { "/foods": { "get": { "description": "Retorna a lista de comidas cadastradas.", "produces": [ "application/json" ], "tags": [ "Comida" ], "summary": "Lista Comidas.", "parameters": [ { "type": "integer", "description": "Número da página", "name": "page", "in": "query" }, { "type": "integer", "description": "Número de resultados por página", "name": "perPage", "in": "query" } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/response.SearchResult" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ApiError" } } } }, "post": { "description": "Cadastra uma nova Comida.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Comida" ], "summary": "Adiciona Comida.", "parameters": [ { "description": "Informações da nova Comida", "name": "json", "in": "body", "required": true, "schema": { "$ref": "#/definitions/request.Food" } } ], "responses": { "201": { "description": "Created", "schema": { "$ref": "#/definitions/models.Food" } }, "422": { "description": "Unprocessable Entity", "schema": { "$ref": "#/definitions/response.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ApiError" } } } } }, "/foods/{id}": { "put": { "description": "Atualiza uma Comida existente.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Comida" ], "summary": "Atualiza Comida.", "parameters": [ { "type": "string", "format": "uuid", "description": "ID da Comida", "name": "id", "in": "path", "required": true }, { "description": "Novas Informações da Comida", "name": "json", "in": "body", "required": true, "schema": { "$ref": "#/definitions/request.Food" } } ], "responses": { "200": { "description": "OK", "schema": { "$ref": "#/definitions/models.Food" } }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/response.ApiError" } }, "422": { "description": "Unprocessable Entity", "schema": { "$ref": "#/definitions/response.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ApiError" } } } }, "delete": { "description": "Deleta uma Comida existente.", "produces": [ "application/json" ], "tags": [ "Comida" ], "summary": "Remove Comida.", "parameters": [ { "type": "string", "format": "uuid", "description": "ID da Comida", "name": "id", "in": "path", "required": true } ], "responses": { "204": { "description": "No Content" }, "404": { "description": "Not Found", "schema": { "$ref": "#/definitions/response.ApiError" } }, "422": { "description": "Unprocessable Entity", "schema": { "$ref": "#/definitions/response.ApiError" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/response.ApiError" } } } } } }, "definitions": { "models.Food": { "type": "object", "properties": { "createdAt": { "type": "string", "example": "2024-11-20T02:18:56.744307Z" }, "id": { "type": "string", "example": "4e51bdb9-c75a-4198-8f2d-9695e3ffaa83" }, "name": { "type": "string", "example": "Macarrão à Milanesa" }, "price": { "type": "number", "example": 15.47 }, "updatedAt": { "type": "string", "example": "2024-11-20T02:18:56.744307Z" } } }, "request.Food": { "type": "object", "required": [ "name", "price" ], "properties": { "name": { "type": "string", "example": "Arroz com Passas" }, "price": { "type": "number", "example": 14.75 } } }, "response.ApiError": { "type": "object", "properties": { "error": { "type": "string" } } }, "response.SearchResult": { "type": "object", "properties": { "data": { "type": "array", "items": { "$ref": "#/definitions/models.Food" } }, "page": { "type": "integer", "example": 1 }, "perPage": { "type": "integer", "example": 20 }, "total": { "type": "integer", "example": 15 } } } }, "externalDocs": { "description": "OpenAPI", "url": "https://swagger.io/resources/open-api/" } }