{ "swagger": "2.0", "info": { "description": "Example of a user API with Swagger.", "title": "API", "contact": {}, "version": "1.0" }, "host": "localhost:8080", "basePath": "/", "paths": { "/api/v1/auth/sign-in": { "post": { "description": "Signin a user", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Credential" ], "summary": "Signin a user", "parameters": [ { "description": "Email and password", "name": "input", "in": "body", "required": true, "schema": { "$ref": "#/definitions/model.LoginInput" } } ], "responses": { "200": { "description": "User connected", "schema": { "$ref": "#/definitions/model.PublicUser" } }, "400": { "description": "Validation error", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "401": { "description": "Unauthorized (bad credentials)", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "500": { "description": "Internal error", "schema": { "$ref": "#/definitions/model.ErrorResponse" } } } } }, "/api/v1/auth/sign-up": { "post": { "description": "Register a new user", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Credential" ], "summary": "Register a new user", "parameters": [ { "description": "Username, Email and Password", "name": "user", "in": "body", "required": true, "schema": { "$ref": "#/definitions/model.RegisterInput" } } ], "responses": { "200": { "description": "User created successfully", "schema": { "$ref": "#/definitions/model.PublicUser" } }, "400": { "description": "Invalid input data", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "409": { "description": "Email or username already in use", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "500": { "description": "Internal Server error", "schema": { "$ref": "#/definitions/model.ErrorResponse" } } } } }, "/api/v1/horses": { "post": { "description": "add a h test", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Horses" ], "summary": "add a horse test", "parameters": [ { "description": "Horse data", "name": "addhorse", "in": "body", "required": true, "schema": { "$ref": "#/definitions/model.HorseInput" } } ], "responses": { "201": { "description": "Horse created", "schema": { "$ref": "#/definitions/model.HorsesResponse" } }, "400": { "description": "Invalid input", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "401": { "description": "Horse already exists", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "409": { "description": "Horse already exists", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "500": { "description": "Server error", "schema": { "$ref": "#/definitions/model.ErrorResponse" } } } } }, "/api/v1/horses/{id}": { "get": { "description": "Retrieve a horse for a specific user", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Horses" ], "summary": "Get a horse", "parameters": [ { "type": "integer", "description": "Horse Id", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "Horse retrieved", "schema": { "$ref": "#/definitions/model.HorseCreateResponse" } }, "400": { "description": "Invalid ID format or validation error", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "404": { "description": "Horse not found", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "500": { "description": "Internal Server Error", "schema": { "$ref": "#/definitions/model.ErrorResponse" } } } }, "put": { "description": "Update a horse by ID", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Horses" ], "summary": "Update a horse", "parameters": [ { "type": "integer", "description": "Horse ID", "name": "id", "in": "path", "required": true }, { "description": "Name, Age and Race", "name": "addhorse", "in": "body", "required": true, "schema": { "$ref": "#/definitions/model.HorseUpdateInput" } } ], "responses": { "200": { "description": "Horse updated", "schema": { "$ref": "#/definitions/model.HorseUpdateResponse" } }, "400": { "description": "Invalid input", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "401": { "description": "Unauthorized", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "403": { "description": "Forbidden", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "404": { "description": "Horse not found", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "500": { "description": "Internal Error", "schema": { "$ref": "#/definitions/model.ErrorResponse" } } } }, "delete": { "description": "Delete horse", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Horses" ], "summary": "delete a horse", "parameters": [ { "type": "integer", "description": "Horse ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "Horse deleted successfully", "schema": { "type": "object", "additionalProperties": true } }, "400": { "description": "Invalid horse ID format", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "404": { "description": "Horse not found", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/model.ErrorResponse" } } } } }, "/api/v1/horses/{id}/weights": { "get": { "description": "Retrieve weights of a horse. Use query parameters to filter: limit, sort (asc|desc), and compare=true to include last weight difference.", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Weights" ], "summary": "Get horse weights", "parameters": [ { "type": "integer", "description": "Horse ID", "name": "id", "in": "path", "required": true }, { "type": "integer", "description": "Limit number of weights returned (e.g., 1, 6, etc.)", "name": "limit", "in": "query" }, { "type": "string", "description": "Sort order (asc or desc). Default is asc.", "name": "sort", "in": "query" }, { "type": "boolean", "description": "Include comparison fields for last weight (only works with limit=1)", "name": "compare", "in": "query" } ], "responses": { "200": { "description": "Horse weights data", "schema": { "$ref": "#/definitions/model.Weights" } }, "400": { "description": "Validation error", "schema": { "type": "object", "additionalProperties": { "type": "string" } } }, "500": { "description": "Internal server error", "schema": { "type": "object", "additionalProperties": { "type": "string" } } } } }, "post": { "description": "Add a weight horse", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Weights" ], "summary": "A dd a weight horse", "parameters": [ { "description": "Weight, fk_horse_id", "name": "addWeight", "in": "body", "required": true, "schema": { "$ref": "#/definitions/model.WeightInput" } } ], "responses": { "201": { "description": "Weight added", "schema": { "$ref": "#/definitions/model.WeightCreateResponse" } }, "400": { "description": "Bad request", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/model.ErrorResponse" } } } } }, "/api/v1/users/{id}/horses": { "get": { "description": "Retrieve a list of horses for a specific user", "consumes": [ "application/json" ], "produces": [ "application/json" ], "tags": [ "Horses" ], "summary": "Get horses by user ID", "parameters": [ { "type": "integer", "description": "User ID", "name": "id", "in": "path", "required": true } ], "responses": { "200": { "description": "List of horses for the given user", "schema": { "$ref": "#/definitions/model.HorsesResponse" } }, "400": { "description": "Invalid user ID format or validation issue", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "401": { "description": "User not found (if needed)", "schema": { "$ref": "#/definitions/model.ErrorResponse" } }, "500": { "description": "Internal server error", "schema": { "$ref": "#/definitions/model.ErrorResponse" } } } } }, "/ping": { "get": { "description": "Respond with \"pong\"", "produces": [ "application/json" ], "tags": [ "example" ], "summary": "Ping", "responses": { "200": { "description": "pong", "schema": { "type": "string" } } } } } }, "definitions": { "model.ErrorDetail": { "type": "object", "properties": { "field": { "type": "string" }, "issue": { "type": "string" } } }, "model.ErrorResponse": { "type": "object", "properties": { "code": { "type": "integer" }, "details": { "type": "array", "items": { "$ref": "#/definitions/model.ErrorDetail" } }, "links": {}, "message": { "type": "string" }, "meta": { "type": "object", "additionalProperties": { "type": "string" } }, "status": { "type": "string" } } }, "model.HorseCreateResponse": { "type": "object", "properties": { "_links": { "$ref": "#/definitions/model.Links" }, "horse": { "$ref": "#/definitions/model.Horses" }, "meta": { "$ref": "#/definitions/model.MetaSimple" } } }, "model.HorseInput": { "type": "object", "required": [ "age", "name", "race" ], "properties": { "age": { "type": "integer" }, "fk_user_id": { "type": "integer" }, "name": { "type": "string" }, "race": { "type": "string" } } }, "model.HorseUpdate": { "type": "object", "required": [ "age", "name", "race" ], "properties": { "age": { "type": "integer" }, "name": { "type": "string" }, "race": { "type": "string" }, "updatedAt": { "type": "string" } } }, "model.HorseUpdateInput": { "type": "object", "required": [ "age", "name", "race" ], "properties": { "age": { "type": "integer" }, "name": { "type": "string" }, "race": { "type": "string" } } }, "model.HorseUpdateResponse": { "type": "object", "properties": { "_links": { "$ref": "#/definitions/model.Links" }, "horse": { "$ref": "#/definitions/model.HorseUpdate" }, "meta": { "$ref": "#/definitions/model.Meta" } } }, "model.Horses": { "type": "object", "required": [ "age", "fk_user_id", "name", "race" ], "properties": { "_links": { "$ref": "#/definitions/model.Links" }, "age": { "type": "integer" }, "createdAt": { "type": "string" }, "fk_user_id": { "type": "integer" }, "id": { "type": "integer" }, "name": { "type": "string" }, "race": { "type": "string" }, "updatedAt": { "type": "string" } } }, "model.HorsesResponse": { "type": "object", "properties": { "_links": { "$ref": "#/definitions/model.Links" }, "horse": { "$ref": "#/definitions/model.Horses" }, "meta": { "$ref": "#/definitions/model.Meta" } } }, "model.Link": { "type": "object", "properties": { "href": { "type": "string" }, "method": { "type": "string" } } }, "model.Links": { "type": "object", "properties": { "create": { "$ref": "#/definitions/model.Link" }, "delete": { "$ref": "#/definitions/model.Link" }, "self": { "$ref": "#/definitions/model.Link" }, "update": { "$ref": "#/definitions/model.Link" }, "weights": { "$ref": "#/definitions/model.Link" } } }, "model.LoginInput": { "type": "object", "required": [ "email", "password" ], "properties": { "email": { "type": "string" }, "password": { "type": "string" } } }, "model.Meta": { "type": "object", "properties": { "count": { "type": "integer" }, "welcomeMessage": { "type": "string" } } }, "model.MetaSimple": { "type": "object", "properties": { "message": { "type": "string" } } }, "model.PublicUser": { "type": "object", "properties": { "createdAt": { "type": "string" }, "email": { "type": "string" }, "id": { "type": "integer" }, "username": { "type": "string" } } }, "model.RegisterInput": { "type": "object", "required": [ "email", "password", "username" ], "properties": { "email": { "type": "string" }, "password": { "type": "string" }, "username": { "type": "string" } } }, "model.WeightCreateResponse": { "type": "object", "properties": { "_links": { "$ref": "#/definitions/model.Links" }, "meta": { "$ref": "#/definitions/model.MetaSimple" }, "weight": { "$ref": "#/definitions/model.WeightData" } } }, "model.WeightData": { "type": "object", "properties": { "created_at": { "type": "string" }, "fk_horse_id": { "type": "integer" }, "weight": { "type": "integer" } } }, "model.WeightInput": { "type": "object", "required": [ "weight" ], "properties": { "CreatedAt": { "type": "string" }, "weight": { "type": "integer" } } }, "model.Weights": { "type": "object", "properties": { "CreatedAt": { "type": "string" }, "UpdateddAt": { "type": "string" }, "diiferenceWeight": { "type": "integer" }, "fk_horse_id": { "type": "integer" }, "id": { "type": "integer" }, "lastWeight": { "type": "integer" }, "last_date": { "type": "string" }, "weight": { "type": "integer" } } } } }