diff --git a/controller/FoodConsumptionController.go b/controller/FoodConsumptionController.go index 5bcf7b4..4acb4c7 100644 --- a/controller/FoodConsumptionController.go +++ b/controller/FoodConsumptionController.go @@ -20,6 +20,14 @@ func NewFoodConsumptionController(foodConsumptionService *service.FoodConsumptio return &FoodConsumptionController{foodConsumptionService: foodConsumptionService, firebaseApp: fa} } +// FindAllConsumptionForMeal godoc +// @Summary Get all consumption for the meal +// @Description find all the consumption for the meal by mealId +// @Tags food-consumption +// @Produce json +// @Param mealId path string true "Meal ID" +// @Success 200 {object} dto.BaseResponse[[]dto.FoodConsumptionDto] +// @Router /{mealId}/consumption/ [get] func (s *FoodConsumptionController) FindAllConsumptionForMeal(c *gin.Context) { _, err := s.validateTokenAndGetUserId(c.GetHeader("Authorization")) if err != nil { @@ -41,6 +49,16 @@ func (s *FoodConsumptionController) FindAllConsumptionForMeal(c *gin.Context) { }) } +// AddFoodConsumption godoc +// @Summary Add consumption for the meal +// @Description add consumption for the meal by mealId +// @Tags food-consumption +// @Accept json +// @Produce json +// @Param mealId path string true "Meal ID" +// @Param foodConsumptionDto body dto.FoodConsumptionDto true "Food Consumption" +// @Success 200 {object} dto.BaseResponse[dto.FoodConsumptionDto] +// @Router /{mealId}/consumption/ [post] func (s *FoodConsumptionController) AddFoodConsumption(c *gin.Context) { mealId, err := uuid.Parse(c.Param("mealId")) if err != nil { @@ -69,6 +87,16 @@ func (s *FoodConsumptionController) AddFoodConsumption(c *gin.Context) { }) } +// UpdateFoodConsumption godoc +// @Summary Update consumption for the meal +// @Description update consumption for the meal by mealId +// @Tags food-consumption +// @Accept json +// @Produce json +// @Param mealId path string true "Meal ID" +// @Param foodConsumptionDto body dto.FoodConsumptionDto true "Food Consumption" +// @Success 200 {object} dto.BaseResponse[dto.FoodConsumptionDto] +// @Router /{mealId}/consumption/ [patch] func (s *FoodConsumptionController) UpdateFoodConsumption(c *gin.Context) { mealId, err := uuid.Parse(c.Param("mealId")) if err != nil { @@ -93,6 +121,16 @@ func (s *FoodConsumptionController) UpdateFoodConsumption(c *gin.Context) { }) } +// DeleteFoodConsumption godoc +// @Summary Delete consumption for the meal +// @Description delete consumption for the meal by mealId +// @Tags food-consumption +// @Accept json +// @Produce json +// @Param mealId path string true "Meal ID" +// @Param foodConsumptionId path string true "Food consumption ID" +// @Success 200 {object} dto.BaseResponse[bool] +// @Router /{mealId}/consumption/ [delete] func (s *FoodConsumptionController) DeleteFoodConsumption(c *gin.Context) { mealId, err := uuid.Parse(c.Param("mealId")) foodConsumptionId, err := uuid.Parse(c.Param("foodConsumptionId")) @@ -111,7 +149,7 @@ func (s *FoodConsumptionController) DeleteFoodConsumption(c *gin.Context) { s.abortWithMessage(c, err.Error()) return } - c.JSON(200, dto.BaseResponse[any]{ + c.JSON(200, dto.BaseResponse[bool]{ Body: err != nil, }) } diff --git a/controller/MealController.go b/controller/MealController.go index 543f34d..cbf5a6e 100644 --- a/controller/MealController.go +++ b/controller/MealController.go @@ -21,6 +21,15 @@ func NewMealController(mealService *service.MealService, fa *firebase.App) *Meal return &MealController{mealService: mealService, firebaseApp: fa} } +// FindAllMeals godoc +// @Summary Get all meals +// @Description get all the meals which satisfies the query parameters (startRange, endRange) or all meals if no query parameters are provided +// @Tags meal +// @Produce json +// @Param startRange query string false "Start date of the range" +// @Param endRange query string false "End date of the range" +// @Success 200 {object} dto.BaseResponse[[]dto.MealDto] +// @Router / [get] func (s *MealController) FindAllMeals(c *gin.Context) { var mealDtos = make([]dto.MealDto, 0) startRangeParam := c.Query("startRange") @@ -60,6 +69,14 @@ func (s *MealController) FindAllMeals(c *gin.Context) { c.JSON(200, response) } +// FindMealById godoc +// @Summary Get meal +// @Description get the meal with the provided id +// @Tags meal +// @Produce json +// @Param mealId path string true "Meal ID" +// @Success 200 {object} dto.BaseResponse[dto.MealDto] +// @Router /{mealId}/ [get] func (s *MealController) FindMealById(c *gin.Context) { id, _ := uuid.Parse(c.Param("mealId")) userId, err := s.validateTokenAndGetUserId(c.GetHeader("Authorization")) @@ -78,6 +95,15 @@ func (s *MealController) FindMealById(c *gin.Context) { c.JSON(200, response) } +// CreateMeal godoc +// @Summary Create meal +// @Description create a new meal +// @Tags meal +// @Accept json +// @Produce json +// @Param mealDto body dto.MealDto true "Meal to create" +// @Success 200 {object} dto.BaseResponse[dto.MealDto] +// @Router / [post] func (s *MealController) CreateMeal(c *gin.Context) { var mealDto dto.MealDto err := c.BindJSON(&mealDto) @@ -102,6 +128,16 @@ func (s *MealController) CreateMeal(c *gin.Context) { c.JSON(200, response) } +// UpdateMeal godoc +// @Summary Update meal +// @Description update the meal with the provided id +// @Tags meal +// @Accept json +// @Produce json +// @Param mealId path string true "Meal ID" +// @Param mealDto body dto.MealDto true "Meal to create" +// @Success 200 {object} dto.BaseResponse[dto.MealDto] +// @Router /{mealId}/ [patch] func (s *MealController) UpdateMeal(c *gin.Context) { var mealDto dto.MealDto id, _ := uuid.Parse(c.Param("mealId")) @@ -123,6 +159,15 @@ func (s *MealController) UpdateMeal(c *gin.Context) { c.JSON(200, response) } +// DeleteMeal godoc +// @Summary Delete meal +// @Description delete the meal with the provided id +// @Tags meal +// @Accept json +// @Produce json +// @Param mealId path string true "Meal ID" +// @Success 200 {object} dto.BaseResponse[bool] +// @Router /{mealId}/ [delete] func (s *MealController) DeleteMeal(c *gin.Context) { id, _ := uuid.Parse(c.Param("mealId")) userId, err := s.validateTokenAndGetUserId(c.GetHeader("Authorization")) @@ -141,6 +186,15 @@ func (s *MealController) DeleteMeal(c *gin.Context) { c.JSON(200, response) } +// GetMealStatistics godoc +// @Summary Get meal statistics +// @Description get the meal statistics for the provided date range (default is the past week) +// @Tags meal +// @Produce json +// @Param startRange query string false "Start date of the range" +// @Param endRange query string false "End date of the range" +// @Success 200 {object} dto.BaseResponse[dto.MealStatisticsDto] +// @Router /statistics/ [get] func (s *MealController) GetMealStatistics(c *gin.Context) { var mealStatisticsDto dto.MealStatisticsDto startRangeParam := c.Query("startRange") diff --git a/docs/docs.go b/docs/docs.go new file mode 100644 index 0000000..f28ea3a --- /dev/null +++ b/docs/docs.go @@ -0,0 +1,587 @@ +// Code generated by swaggo/swag. DO NOT EDIT +package docs + +import "github.com/swaggo/swag" + +const docTemplate = `{ + "schemes": {{ marshal .Schemes }}, + "swagger": "2.0", + "info": { + "description": "{{escape .Description}}", + "title": "{{.Title}}", + "contact": { + "name": "Nicola Iacovelli", + "email": "nicolaiacovelli98@gmail.com" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/": { + "get": { + "description": "get all the meals which satisfies the query parameters (startRange, endRange) or all meals if no query parameters are provided", + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Get all meals", + "parameters": [ + { + "type": "string", + "description": "Start date of the range", + "name": "startRange", + "in": "query" + }, + { + "type": "string", + "description": "End date of the range", + "name": "endRange", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-array_dto_MealDto" + } + } + } + }, + "post": { + "description": "create a new meal", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Create meal", + "parameters": [ + { + "description": "Meal to create", + "name": "mealDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.MealDto" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_MealDto" + } + } + } + } + }, + "/statistics/": { + "get": { + "description": "get the meal statistics for the provided date range (default is the past week)", + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Get meal statistics", + "parameters": [ + { + "type": "string", + "description": "Start date of the range", + "name": "startRange", + "in": "query" + }, + { + "type": "string", + "description": "End date of the range", + "name": "endRange", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_MealStatisticsDto" + } + } + } + } + }, + "/{mealId}/": { + "get": { + "description": "get the meal with the provided id", + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Get meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_MealDto" + } + } + } + }, + "delete": { + "description": "delete the meal with the provided id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Delete meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-bool" + } + } + } + }, + "patch": { + "description": "update the meal with the provided id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Update meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + }, + { + "description": "Meal to create", + "name": "mealDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.MealDto" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_MealDto" + } + } + } + } + }, + "/{mealId}/consumption/": { + "get": { + "description": "find all the consumption for the meal by mealId", + "produces": [ + "application/json" + ], + "tags": [ + "food-consumption" + ], + "summary": "Get all consumption for the meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-array_dto_FoodConsumptionDto" + } + } + } + }, + "post": { + "description": "add consumption for the meal by mealId", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "food-consumption" + ], + "summary": "Add consumption for the meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + }, + { + "description": "Food Consumption", + "name": "foodConsumptionDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.FoodConsumptionDto" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_FoodConsumptionDto" + } + } + } + }, + "delete": { + "description": "delete consumption for the meal by mealId", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "food-consumption" + ], + "summary": "Delete consumption for the meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Food consumption ID", + "name": "foodConsumptionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-bool" + } + } + } + }, + "patch": { + "description": "update consumption for the meal by mealId", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "food-consumption" + ], + "summary": "Update consumption for the meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + }, + { + "description": "Food Consumption", + "name": "foodConsumptionDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.FoodConsumptionDto" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_FoodConsumptionDto" + } + } + } + } + } + }, + "definitions": { + "dto.AvgKcalPerMealTypeDto": { + "type": "object", + "properties": { + "avgKcal": { + "type": "number" + }, + "mealType": { + "type": "string" + } + } + }, + "dto.BaseResponse-array_dto_FoodConsumptionDto": { + "type": "object", + "properties": { + "body": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.FoodConsumptionDto" + } + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.BaseResponse-array_dto_MealDto": { + "type": "object", + "properties": { + "body": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.MealDto" + } + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.BaseResponse-bool": { + "type": "object", + "properties": { + "body": { + "type": "boolean" + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.BaseResponse-dto_FoodConsumptionDto": { + "type": "object", + "properties": { + "body": { + "$ref": "#/definitions/dto.FoodConsumptionDto" + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.BaseResponse-dto_MealDto": { + "type": "object", + "properties": { + "body": { + "$ref": "#/definitions/dto.MealDto" + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.BaseResponse-dto_MealStatisticsDto": { + "type": "object", + "properties": { + "body": { + "$ref": "#/definitions/dto.MealStatisticsDto" + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.FoodConsumptionDto": { + "type": "object", + "properties": { + "cost": { + "type": "number" + }, + "foodId": { + "type": "string" + }, + "foodName": { + "type": "string" + }, + "id": { + "type": "string" + }, + "kcal": { + "type": "number" + }, + "mealId": { + "type": "string" + }, + "quantityUsed": { + "type": "number" + }, + "quantityUsedStd": { + "type": "number" + }, + "transactionId": { + "type": "string" + }, + "unit": { + "type": "string" + } + } + }, + "dto.MealDto": { + "type": "object", + "properties": { + "cost": { + "type": "number" + }, + "date": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "kcal": { + "type": "number" + }, + "mealType": { + "$ref": "#/definitions/model.MealType" + }, + "name": { + "type": "string" + }, + "userId": { + "type": "string" + } + } + }, + "dto.MealStatisticsDto": { + "type": "object", + "properties": { + "averageWeekCalories": { + "type": "number" + }, + "averageWeekCaloriesPerMealType": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.AvgKcalPerMealTypeDto" + } + }, + "averageWeekFoodCost": { + "type": "number" + }, + "mostConsumedFood": { + "$ref": "#/definitions/dto.MostConsumedFoodDto" + }, + "sumWeekFoodCost": { + "type": "number" + } + } + }, + "dto.MostConsumedFoodDto": { + "type": "object", + "properties": { + "foodId": { + "type": "string" + }, + "foodName": { + "type": "string" + }, + "quantityUsed": { + "type": "number" + }, + "quantityUsedStd": { + "type": "number" + }, + "unit": { + "type": "string" + } + } + }, + "model.MealType": { + "type": "string", + "enum": [ + "breakfast", + "lunch", + "dinner", + "others" + ], + "x-enum-varnames": [ + "Breakfast", + "Lunch", + "Dinner", + "Others" + ] + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "localhost:8080", + BasePath: "/api/meal", + Schemes: []string{}, + Title: "Food track be API", + Description: "This is a sample server celler server.", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 0000000..0f77694 --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,565 @@ +{ + "swagger": "2.0", + "info": { + "description": "This is a sample server celler server.", + "title": "Food track be API", + "contact": { + "name": "Nicola Iacovelli", + "email": "nicolaiacovelli98@gmail.com" + }, + "version": "1.0" + }, + "host": "localhost:8080", + "basePath": "/api/meal", + "paths": { + "/": { + "get": { + "description": "get all the meals which satisfies the query parameters (startRange, endRange) or all meals if no query parameters are provided", + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Get all meals", + "parameters": [ + { + "type": "string", + "description": "Start date of the range", + "name": "startRange", + "in": "query" + }, + { + "type": "string", + "description": "End date of the range", + "name": "endRange", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-array_dto_MealDto" + } + } + } + }, + "post": { + "description": "create a new meal", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Create meal", + "parameters": [ + { + "description": "Meal to create", + "name": "mealDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.MealDto" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_MealDto" + } + } + } + } + }, + "/statistics/": { + "get": { + "description": "get the meal statistics for the provided date range (default is the past week)", + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Get meal statistics", + "parameters": [ + { + "type": "string", + "description": "Start date of the range", + "name": "startRange", + "in": "query" + }, + { + "type": "string", + "description": "End date of the range", + "name": "endRange", + "in": "query" + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_MealStatisticsDto" + } + } + } + } + }, + "/{mealId}/": { + "get": { + "description": "get the meal with the provided id", + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Get meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_MealDto" + } + } + } + }, + "delete": { + "description": "delete the meal with the provided id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Delete meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-bool" + } + } + } + }, + "patch": { + "description": "update the meal with the provided id", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "meal" + ], + "summary": "Update meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + }, + { + "description": "Meal to create", + "name": "mealDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.MealDto" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_MealDto" + } + } + } + } + }, + "/{mealId}/consumption/": { + "get": { + "description": "find all the consumption for the meal by mealId", + "produces": [ + "application/json" + ], + "tags": [ + "food-consumption" + ], + "summary": "Get all consumption for the meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-array_dto_FoodConsumptionDto" + } + } + } + }, + "post": { + "description": "add consumption for the meal by mealId", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "food-consumption" + ], + "summary": "Add consumption for the meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + }, + { + "description": "Food Consumption", + "name": "foodConsumptionDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.FoodConsumptionDto" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_FoodConsumptionDto" + } + } + } + }, + "delete": { + "description": "delete consumption for the meal by mealId", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "food-consumption" + ], + "summary": "Delete consumption for the meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + }, + { + "type": "string", + "description": "Food consumption ID", + "name": "foodConsumptionId", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-bool" + } + } + } + }, + "patch": { + "description": "update consumption for the meal by mealId", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "food-consumption" + ], + "summary": "Update consumption for the meal", + "parameters": [ + { + "type": "string", + "description": "Meal ID", + "name": "mealId", + "in": "path", + "required": true + }, + { + "description": "Food Consumption", + "name": "foodConsumptionDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.FoodConsumptionDto" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.BaseResponse-dto_FoodConsumptionDto" + } + } + } + } + } + }, + "definitions": { + "dto.AvgKcalPerMealTypeDto": { + "type": "object", + "properties": { + "avgKcal": { + "type": "number" + }, + "mealType": { + "type": "string" + } + } + }, + "dto.BaseResponse-array_dto_FoodConsumptionDto": { + "type": "object", + "properties": { + "body": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.FoodConsumptionDto" + } + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.BaseResponse-array_dto_MealDto": { + "type": "object", + "properties": { + "body": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.MealDto" + } + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.BaseResponse-bool": { + "type": "object", + "properties": { + "body": { + "type": "boolean" + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.BaseResponse-dto_FoodConsumptionDto": { + "type": "object", + "properties": { + "body": { + "$ref": "#/definitions/dto.FoodConsumptionDto" + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.BaseResponse-dto_MealDto": { + "type": "object", + "properties": { + "body": { + "$ref": "#/definitions/dto.MealDto" + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.BaseResponse-dto_MealStatisticsDto": { + "type": "object", + "properties": { + "body": { + "$ref": "#/definitions/dto.MealStatisticsDto" + }, + "errorMessage": { + "type": "string" + } + } + }, + "dto.FoodConsumptionDto": { + "type": "object", + "properties": { + "cost": { + "type": "number" + }, + "foodId": { + "type": "string" + }, + "foodName": { + "type": "string" + }, + "id": { + "type": "string" + }, + "kcal": { + "type": "number" + }, + "mealId": { + "type": "string" + }, + "quantityUsed": { + "type": "number" + }, + "quantityUsedStd": { + "type": "number" + }, + "transactionId": { + "type": "string" + }, + "unit": { + "type": "string" + } + } + }, + "dto.MealDto": { + "type": "object", + "properties": { + "cost": { + "type": "number" + }, + "date": { + "type": "string" + }, + "description": { + "type": "string" + }, + "id": { + "type": "string" + }, + "kcal": { + "type": "number" + }, + "mealType": { + "$ref": "#/definitions/model.MealType" + }, + "name": { + "type": "string" + }, + "userId": { + "type": "string" + } + } + }, + "dto.MealStatisticsDto": { + "type": "object", + "properties": { + "averageWeekCalories": { + "type": "number" + }, + "averageWeekCaloriesPerMealType": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.AvgKcalPerMealTypeDto" + } + }, + "averageWeekFoodCost": { + "type": "number" + }, + "mostConsumedFood": { + "$ref": "#/definitions/dto.MostConsumedFoodDto" + }, + "sumWeekFoodCost": { + "type": "number" + } + } + }, + "dto.MostConsumedFoodDto": { + "type": "object", + "properties": { + "foodId": { + "type": "string" + }, + "foodName": { + "type": "string" + }, + "quantityUsed": { + "type": "number" + }, + "quantityUsedStd": { + "type": "number" + }, + "unit": { + "type": "string" + } + } + }, + "model.MealType": { + "type": "string", + "enum": [ + "breakfast", + "lunch", + "dinner", + "others" + ], + "x-enum-varnames": [ + "Breakfast", + "Lunch", + "Dinner", + "Others" + ] + } + } +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 0000000..2c84f20 --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,375 @@ +basePath: /api/meal +definitions: + dto.AvgKcalPerMealTypeDto: + properties: + avgKcal: + type: number + mealType: + type: string + type: object + dto.BaseResponse-array_dto_FoodConsumptionDto: + properties: + body: + items: + $ref: '#/definitions/dto.FoodConsumptionDto' + type: array + errorMessage: + type: string + type: object + dto.BaseResponse-array_dto_MealDto: + properties: + body: + items: + $ref: '#/definitions/dto.MealDto' + type: array + errorMessage: + type: string + type: object + dto.BaseResponse-bool: + properties: + body: + type: boolean + errorMessage: + type: string + type: object + dto.BaseResponse-dto_FoodConsumptionDto: + properties: + body: + $ref: '#/definitions/dto.FoodConsumptionDto' + errorMessage: + type: string + type: object + dto.BaseResponse-dto_MealDto: + properties: + body: + $ref: '#/definitions/dto.MealDto' + errorMessage: + type: string + type: object + dto.BaseResponse-dto_MealStatisticsDto: + properties: + body: + $ref: '#/definitions/dto.MealStatisticsDto' + errorMessage: + type: string + type: object + dto.FoodConsumptionDto: + properties: + cost: + type: number + foodId: + type: string + foodName: + type: string + id: + type: string + kcal: + type: number + mealId: + type: string + quantityUsed: + type: number + quantityUsedStd: + type: number + transactionId: + type: string + unit: + type: string + type: object + dto.MealDto: + properties: + cost: + type: number + date: + type: string + description: + type: string + id: + type: string + kcal: + type: number + mealType: + $ref: '#/definitions/model.MealType' + name: + type: string + userId: + type: string + type: object + dto.MealStatisticsDto: + properties: + averageWeekCalories: + type: number + averageWeekCaloriesPerMealType: + items: + $ref: '#/definitions/dto.AvgKcalPerMealTypeDto' + type: array + averageWeekFoodCost: + type: number + mostConsumedFood: + $ref: '#/definitions/dto.MostConsumedFoodDto' + sumWeekFoodCost: + type: number + type: object + dto.MostConsumedFoodDto: + properties: + foodId: + type: string + foodName: + type: string + quantityUsed: + type: number + quantityUsedStd: + type: number + unit: + type: string + type: object + model.MealType: + enum: + - breakfast + - lunch + - dinner + - others + type: string + x-enum-varnames: + - Breakfast + - Lunch + - Dinner + - Others +host: localhost:8080 +info: + contact: + email: nicolaiacovelli98@gmail.com + name: Nicola Iacovelli + description: This is a sample server celler server. + title: Food track be API + version: "1.0" +paths: + /: + get: + description: get all the meals which satisfies the query parameters (startRange, + endRange) or all meals if no query parameters are provided + parameters: + - description: Start date of the range + in: query + name: startRange + type: string + - description: End date of the range + in: query + name: endRange + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.BaseResponse-array_dto_MealDto' + summary: Get all meals + tags: + - meal + post: + consumes: + - application/json + description: create a new meal + parameters: + - description: Meal to create + in: body + name: mealDto + required: true + schema: + $ref: '#/definitions/dto.MealDto' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.BaseResponse-dto_MealDto' + summary: Create meal + tags: + - meal + /{mealId}/: + delete: + consumes: + - application/json + description: delete the meal with the provided id + parameters: + - description: Meal ID + in: path + name: mealId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.BaseResponse-bool' + summary: Delete meal + tags: + - meal + get: + description: get the meal with the provided id + parameters: + - description: Meal ID + in: path + name: mealId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.BaseResponse-dto_MealDto' + summary: Get meal + tags: + - meal + patch: + consumes: + - application/json + description: update the meal with the provided id + parameters: + - description: Meal ID + in: path + name: mealId + required: true + type: string + - description: Meal to create + in: body + name: mealDto + required: true + schema: + $ref: '#/definitions/dto.MealDto' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.BaseResponse-dto_MealDto' + summary: Update meal + tags: + - meal + /{mealId}/consumption/: + delete: + consumes: + - application/json + description: delete consumption for the meal by mealId + parameters: + - description: Meal ID + in: path + name: mealId + required: true + type: string + - description: Food consumption ID + in: path + name: foodConsumptionId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.BaseResponse-bool' + summary: Delete consumption for the meal + tags: + - food-consumption + get: + description: find all the consumption for the meal by mealId + parameters: + - description: Meal ID + in: path + name: mealId + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.BaseResponse-array_dto_FoodConsumptionDto' + summary: Get all consumption for the meal + tags: + - food-consumption + patch: + consumes: + - application/json + description: update consumption for the meal by mealId + parameters: + - description: Meal ID + in: path + name: mealId + required: true + type: string + - description: Food Consumption + in: body + name: foodConsumptionDto + required: true + schema: + $ref: '#/definitions/dto.FoodConsumptionDto' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.BaseResponse-dto_FoodConsumptionDto' + summary: Update consumption for the meal + tags: + - food-consumption + post: + consumes: + - application/json + description: add consumption for the meal by mealId + parameters: + - description: Meal ID + in: path + name: mealId + required: true + type: string + - description: Food Consumption + in: body + name: foodConsumptionDto + required: true + schema: + $ref: '#/definitions/dto.FoodConsumptionDto' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.BaseResponse-dto_FoodConsumptionDto' + summary: Add consumption for the meal + tags: + - food-consumption + /statistics/: + get: + description: get the meal statistics for the provided date range (default is + the past week) + parameters: + - description: Start date of the range + in: query + name: startRange + type: string + - description: End date of the range + in: query + name: endRange + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.BaseResponse-dto_MealStatisticsDto' + summary: Get meal statistics + tags: + - meal +swagger: "2.0" diff --git a/go.mod b/go.mod index a244602..7a1bf0d 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,9 @@ require ( github.com/google/uuid v1.3.0 github.com/mashingan/smapping v0.1.19 github.com/sony/gobreaker v0.5.0 + github.com/swaggo/files v1.0.0 + github.com/swaggo/gin-swagger v1.5.3 + github.com/swaggo/swag v1.8.10 github.com/uptrace/bun v1.1.8 github.com/uptrace/bun/dialect/pgdialect v1.1.8 github.com/uptrace/bun/driver/pgdriver v1.1.8 @@ -20,8 +23,17 @@ require ( cloud.google.com/go/firestore v1.6.1 // indirect cloud.google.com/go/iam v0.3.0 // indirect cloud.google.com/go/storage v1.26.0 // indirect + github.com/KyleBanks/depth v1.2.1 // indirect github.com/MicahParks/keyfunc v1.5.1 // indirect + github.com/PuerkitoBio/purell v1.2.0 // indirect + github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/spec v0.20.8 // indirect + github.com/go-openapi/swag v0.22.3 // indirect github.com/go-playground/locales v0.14.0 // indirect github.com/go-playground/universal-translator v0.18.0 // indirect github.com/go-playground/validator/v10 v10.11.1 // indirect @@ -33,22 +45,29 @@ require ( github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect github.com/googleapis/gax-go/v2 v2.4.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect + github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/leodido/go-urn v1.2.1 // indirect + github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-isatty v0.0.16 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/pelletier/go-toml/v2 v2.0.5 // indirect + github.com/russross/blackfriday/v2 v2.1.0 // indirect + github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect github.com/ugorji/go/codec v1.2.7 // indirect + github.com/urfave/cli/v2 v2.24.4 // indirect github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect + github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect go.opencensus.io v0.23.0 // indirect golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be // indirect - golang.org/x/net v0.0.0-20220927171203-f486391704dc // indirect + golang.org/x/net v0.7.0 // indirect golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1 // indirect - golang.org/x/sys v0.0.0-20220927170352-d9d178bc13c6 // indirect - golang.org/x/text v0.3.7 // indirect + golang.org/x/sys v0.5.0 // indirect + golang.org/x/text v0.7.0 // indirect + golang.org/x/tools v0.6.0 // indirect golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f // indirect google.golang.org/api v0.96.0 // indirect google.golang.org/appengine v1.6.7 // indirect @@ -57,5 +76,6 @@ require ( google.golang.org/grpc v1.48.0 // indirect google.golang.org/protobuf v1.28.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect mellium.im/sasl v0.3.1 // indirect ) diff --git a/go.sum b/go.sum index a619edc..3b2c164 100644 --- a/go.sum +++ b/go.sum @@ -66,9 +66,18 @@ firebase.google.com/go/v4 v4.10.0 h1:dgK/8uwfJbzc5LZK/GyRRfIkZEDObN9q0kgEXsjlXN4 firebase.google.com/go/v4 v4.10.0/go.mod h1:m0gLwPY9fxKggizzglgCNWOGnFnVPifLpqZzo5u3e/A= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= +github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/MicahParks/keyfunc v1.5.1 h1:RlyyYgKQI/adkIw1yXYtPvTAOb7hBhSX42aH23d8N0Q= github.com/MicahParks/keyfunc v1.5.1/go.mod h1:IdnCilugA0O/99dW+/MkvlyrsX8+L8+x95xuVNtM5jw= github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/purell v1.2.0 h1:/Jdm5QfyM8zdlqT6WVZU4cfP23sot6CEHA4CS49Ezig= +github.com/PuerkitoBio/purell v1.2.0/go.mod h1:OhLRTaaIzhvIyofkJfB24gokC7tM42Px5UhoT32THBk= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/agiledragon/gomonkey/v2 v2.3.1/go.mod h1:ap1AmDzcVOAz1YpeJ3TCzIgstoaWLA6jbbgxfB4w2iY= github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -86,6 +95,10 @@ github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWH github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -100,9 +113,12 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g= github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs= +github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4= +github.com/gin-contrib/gzip v0.0.6/go.mod h1:QOJlmV2xmayAjkNS2Y8NQsMneuRShOU/kjovCXNuzzk= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= github.com/gin-gonic/gin v1.8.1 h1:4+fr/el88TOO3ewCmQr8cx/CtZ/umlIRIs5M4NTNjf8= @@ -110,6 +126,25 @@ github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= +github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= +github.com/go-openapi/spec v0.20.8 h1:ubHmXNY3FCIOinT8RNrrPfGc9t7I1qhPtdOGoG2AxRU= +github.com/go-openapi/spec v0.20.8/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= +github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= @@ -211,6 +246,7 @@ github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99 github.com/googleapis/gax-go/v2 v2.4.0 h1:dS9eYAjhrE2RjmzYw2XAPvcXfmcQLtFEQWn0CR82awk= github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -218,10 +254,13 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1: github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= @@ -233,6 +272,12 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mashingan/smapping v0.1.19 h1:SsEtuPn2UcM1croIupPtGLgWgpYRuS0rSQMvKD9g2BQ= github.com/mashingan/smapping v0.1.19/go.mod h1:FjfiwFxGOuNxL/OT1WcrNAwTPx0YJeg5JiXwBB1nyig= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= @@ -243,6 +288,12 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/otiai10/copy v1.7.0/go.mod h1:rmRl6QPdJj6EiUqXQ/4Nn2lLXoNQjFCQbbNrxgc/t3U= +github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= +github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= +github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= +github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo= github.com/pelletier/go-toml/v2 v2.0.5 h1:ipoSadvV8oGUjnUbMub59IDPPwfxF694nG/jwbMiyQg= github.com/pelletier/go-toml/v2 v2.0.5/go.mod h1:OMHamSCAODeSsVrwwvcJOaoN0LIUIaFVNZzmWyNfXas= @@ -255,11 +306,20 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= +github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= github.com/sony/gobreaker v0.5.0 h1:dRCvqm0P490vZPmy7ppEk2qCnCieBooFJ+YoXGYB+yg= github.com/sony/gobreaker v0.5.0/go.mod h1:ZKptC7FHNvhBz7dN2LGjPVBz2sZJmc0/PkyDJOjmxWY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= @@ -268,6 +328,15 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/swaggo/files v0.0.0-20220728132757-551d4a08d97a/go.mod h1:lKJPbtWzJ9JhsTN1k1gZgleJWY/cqq0psdoMmaThG3w= +github.com/swaggo/files v1.0.0 h1:1gGXVIeUFCS/dta17rnP0iOpr6CXFwKD7EO5ID233e4= +github.com/swaggo/files v1.0.0/go.mod h1:N59U6URJLyU1PQgFqPM7wXLMhJx7QAolnvfQkqO13kc= +github.com/swaggo/gin-swagger v1.5.3 h1:8mWmHLolIbrhJJTflsaFoZzRBYVmEE7JZGIq08EiC0Q= +github.com/swaggo/gin-swagger v1.5.3/go.mod h1:3XJKSfHjDMB5dBo/0rrTXidPmgLeqsX89Yp4uA50HpI= +github.com/swaggo/swag v1.8.1/go.mod h1:ugemnJsPZm/kRwFUnzBlbHRd0JY9zE1M4F+uy2pAaPQ= +github.com/swaggo/swag v1.8.10 h1:eExW4bFa52WOjqRzRD58bgWsWfdFJso50lpbeTcmTfo= +github.com/swaggo/swag v1.8.10/go.mod h1:ezQVUUhly8dludpVk+/PuwJWvLLanB13ygV5Pr9enSk= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs= github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= @@ -279,15 +348,23 @@ github.com/uptrace/bun/dialect/pgdialect v1.1.8 h1:wayJhjYDPGv8tgOBLolbBtSFQ0Tih github.com/uptrace/bun/dialect/pgdialect v1.1.8/go.mod h1:nNbU8PHTjTUM+CRtGmqyBb9zcuRAB8I680/qoFSmBUk= github.com/uptrace/bun/driver/pgdriver v1.1.8 h1:gyL22axRQfjJS2Umq0erzJnp0bLOdUE8/USKZHPQB8o= github.com/uptrace/bun/driver/pgdriver v1.1.8/go.mod h1:4tHK0h7a/UoldBoe9J3GU4tEYjr3mkd62U3Kq3PVk3E= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= +github.com/urfave/cli/v2 v2.24.4 h1:0gyJJEBYtCV87zI/x2nZCPyDxD51K6xM8SkwjHFCNEU= +github.com/urfave/cli/v2 v2.24.4/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.0/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -303,6 +380,7 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be h1:fmw3UbQh+nxngCAHrDCCztao/kbYFnWjoqop8dHx05A= golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= @@ -341,6 +419,9 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -375,7 +456,9 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= @@ -385,9 +468,12 @@ golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220708220712-1185a9018129/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.0.0-20220927171203-f486391704dc h1:FxpXZdoBqT8RjqTy6i1E8nXHhW21wK7ptQ/EPIGxzPQ= -golang.org/x/net v0.0.0-20220927171203-f486391704dc/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -424,6 +510,7 @@ golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -460,6 +547,7 @@ golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -468,6 +556,7 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -483,12 +572,16 @@ golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220927170352-d9d178bc13c6 h1:cy1ko5847T/lJ45eyg/7uLprIE/amW5IXxGtEnQdYMI= -golang.org/x/sys v0.0.0-20220927170352-d9d178bc13c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -497,8 +590,11 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -508,6 +604,7 @@ golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= @@ -553,6 +650,11 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.7/go.mod h1:LGqMHiF4EqQNHR1JncWGqT5BVaXmza+X+BDGol+dOxo= +golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0 h1:BOw41kyTf3PuCW1pVQf8+Cyg8pMlkYB1oo9iJ6D/lKM= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -749,6 +851,7 @@ google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175 google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= @@ -757,6 +860,7 @@ gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/main.go b/main.go index 62377ff..ac55c80 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,8 @@ import ( "food-track-be/repository" "food-track-be/service" "github.com/gin-contrib/cors" + swaggerFiles "github.com/swaggo/files" + ginSwagger "github.com/swaggo/gin-swagger" "github.com/uptrace/bun" "github.com/uptrace/bun/dialect/pgdialect" "github.com/uptrace/bun/driver/pgdriver" @@ -18,8 +20,22 @@ import ( "time" "github.com/gin-gonic/gin" + + _ "food-track-be/docs" ) +// @title Food track be API +// @version 1.0 +// @description This is a sample server celler server. + +// @contact.name Nicola Iacovelli +// @contact.email nicolaiacovelli98@gmail.com + +// @host localhost:8080 +// @BasePath /api/meal + +// @externalDocs.description OpenAPI +// @externalDocs.url https://swagger.io/resources/open-api/ func main() { dbHost := os.Getenv("DB_HOST") @@ -73,17 +89,22 @@ func main() { //corsConfig.AllowHeaders = append(corsConfig.AllowHeaders, "iv-user") r.Use(cors.New(corsConfig)) - r.GET("/api/meal/", mc.FindAllMeals) - r.GET("/api/meal/:mealId/", mc.FindMealById) - r.POST("/api/meal/", mc.CreateMeal) - r.PATCH("/api/meal/:mealId/", mc.UpdateMeal) - r.DELETE("/api/meal/:mealId/", mc.DeleteMeal) - r.GET("/api/meal/statistics/", mc.GetMealStatistics) - - r.GET("/api/meal/:mealId/consumption/", fcc.FindAllConsumptionForMeal) - r.POST("/api/meal/:mealId/consumption/", fcc.AddFoodConsumption) - r.PATCH("/api/meal/:mealId/consumption/:consumptionId/", fcc.UpdateFoodConsumption) - r.DELETE("/api/meal/:mealId/consumption/:foodConsumptionId/", fcc.DeleteFoodConsumption) + mealApi := r.Group("/api/meal") + { + mealApi.GET("/", mc.FindAllMeals) + mealApi.GET(":mealId/", mc.FindMealById) + mealApi.POST("/", mc.CreateMeal) + mealApi.PATCH(":mealId/", mc.UpdateMeal) + mealApi.DELETE(":mealId/", mc.DeleteMeal) + mealApi.GET("/statistics/", mc.GetMealStatistics) + + mealApi.GET(":mealId/consumption/", fcc.FindAllConsumptionForMeal) + mealApi.POST(":mealId/consumption/", fcc.AddFoodConsumption) + mealApi.PATCH(":mealId/consumption/:consumptionId/", fcc.UpdateFoodConsumption) + mealApi.DELETE(":mealId/consumption/:foodConsumptionId/", fcc.DeleteFoodConsumption) + } + + r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) r.GET("/ping", func(c *gin.Context) { c.JSON(http.StatusOK, gin.H{