From 7961dc3f6e1984d2f4a62c73522407c59148eb6d Mon Sep 17 00:00:00 2001 From: KUNAL KUMAR Date: Wed, 12 Nov 2025 02:19:50 +0530 Subject: [PATCH 1/2] docs: added swagger docs --- README.md | 49 ++++-- cmd/api/events.go | 83 ++++++++- cmd/api/main.go | 16 ++ cmd/api/routes.go | 9 + docs/docs.go | 430 ++++++++++++++++++++++++++++++++++++++++++++++ docs/swagger.json | 409 +++++++++++++++++++++++++++++++++++++++++++ docs/swagger.yaml | 269 +++++++++++++++++++++++++++++ go.mod | 27 ++- go.sum | 97 +++++++++-- 9 files changed, 1359 insertions(+), 30 deletions(-) create mode 100644 docs/docs.go create mode 100644 docs/swagger.json create mode 100644 docs/swagger.yaml diff --git a/README.md b/README.md index c17c54b..6a950aa 100644 --- a/README.md +++ b/README.md @@ -100,18 +100,47 @@ make clean ## Project Structure ``` -. ├── cmd/ -│ ├── api/ # Main API application -│ └── migrate/ # Database migrations +│ ├── api/ # Main API application (Gin server) +│ │ ├── auth.go # Authentication handlers (login, register) +│ │ ├── contex.go # Helper functions to get user from context +│ │ ├── events.go # Event CRUD handlers +│ │ ├── main.go # Entry point for API server +│ │ ├── middleware.go # Authentication & logging middleware +│ │ ├── routes.go # Route definitions +│ │ └── server.go # Server configuration & startup +│ └── migrate/ # Database migrations +│ └── migrations/ +│ ├── 000001_create_user_table.up.sql +│ ├── 000001_create_user_table.down.sql +│ ├── 000002_create_events_table.up.sql +│ ├── 000002_create_events_table.down.sql +│ ├── 000003_create_attendance_table.up.sql +│ ├── 000003_create_attendance_table.down.sql +│ └── main.go +│ ├── internals/ -│ ├── database/ # Database models and queries -│ └── env/ # Environment configuration -├── server/ # Server configurations -├── Makefile # Build automation -├── data.db # SQLite database -├── .air.toml # Air configuration -└── go.mod # Go modules +│ ├── database/ # Database models and queries +│ │ ├── models.go # Model registry +│ │ ├── users.go # User model & queries +│ │ ├── event.go # Event model & queries +│ │ └── attendee.go # Attendance model & queries +│ └── env/ # Environment configuration (env variables) +│ └── env.go +│ +├── server/ # Server-related files (local data, configs) +│ └── data.db # Local SQLite database +│ +├── tmp/ # Temporary build and runtime files +│ ├── main # Compiled binary (generated by Air) +│ └── build-errors.log # Logs from failed builds +│ +├── Makefile # Build & run automation commands +├── go.mod # Go module definition +├── go.sum # Dependency checksums +├── data.db # Development SQLite database +├── .air.toml # Air live-reload configuration +└── README.md # Project documentation ``` ## API Endpoints diff --git a/cmd/api/events.go b/cmd/api/events.go index b59971a..5badfa7 100644 --- a/cmd/api/events.go +++ b/cmd/api/events.go @@ -9,7 +9,18 @@ import ( "github.com/kunalkumar-1/Evently/internals/database" ) -// create event handler +// CreateEvent creates a new event +// @Summary Create a new event +// @Description Create a new event owned by the authenticated user +// @Tags Events +// @Accept json +// @Produce json +// @Param event body database.Event true "Event Data" +// @Success 201 {object} database.Event +// @Failure 400 {object} map[string]string +// @Failure 500 {object} map[string]string +// @Router /events [post] +// @Security BearerAuth func (app *application) createEvent(c *gin.Context) { var event database.Event @@ -39,7 +50,16 @@ func (app *application) createEvent(c *gin.Context) { c.JSON(http.StatusCreated, event) } -// get all events +// GetAllEvent returns all events +// @Summary Get all events +// @Description Retrieve a list of all available events +// @Tags Events +// @Accept json +// @Produce json +// @Success 200 {array} database.Event +// @Failure 500 {object} map[string]string "Failed to retrieve events" +// @Router /events [get] + func (app *application) getAllEvent(c *gin.Context) { events, err := app.models.Events.GetAll() if err != nil { @@ -51,7 +71,17 @@ func (app *application) getAllEvent(c *gin.Context) { c.JSON(http.StatusOK, events) } -// get events +// GetEvent retrieves an event by ID +// @Summary Get event by ID +// @Description Retrieve details of a specific event +// @Tags Events +// @Accept json +// @Produce json +// @Param id path int true "Event ID" +// @Success 200 {object} database.Event +// @Failure 400 {object} map[string]string +// @Failure 404 {object} map[string]string +// @Router /events/{id} [get] func (app *application) getEvent(c *gin.Context) { id, err := strconv.Atoi(c.Param("id")) if err != nil { @@ -78,7 +108,20 @@ func (app *application) getEvent(c *gin.Context) { c.JSON(http.StatusCreated, event) } -// update event +// UpdateEvent updates an existing event +// @Summary Update event +// @Description Update an existing event by ID (only by owner) +// @Tags Events +// @Accept json +// @Produce json +// @Param id path int true "Event ID" +// @Param event body database.Event true "Updated Event Data" +// @Success 200 {object} database.Event +// @Failure 400 {object} map[string]string +// @Failure 403 {object} map[string]string +// @Failure 500 {object} map[string]string +// @Router /events/{id} [put] +// @Security BearerAuth func (app *application) updateEvent(c *gin.Context) { id, err := strconv.Atoi(c.Param("id")) // get event id from url if err != nil { @@ -137,7 +180,17 @@ func (app *application) updateEvent(c *gin.Context) { c.JSON(http.StatusOK, updatedEvent) } -// delete event +// DeleteEvent deletes an event by ID +// @Summary Delete event +// @Description Delete an event by ID (only by owner) +// @Tags Events +// @Param id path int true "Event ID" +// @Success 204 {object} nil +// @Failure 400 {object} map[string]string +// @Failure 403 {object} map[string]string +// @Failure 404 {object} map[string]string +// @Router /events/{id} [delete] +// @Security BearerAuth func (app *application) deleteEvent(c *gin.Context) { id, err := strconv.Atoi(c.Param("id")) if err != nil { @@ -178,6 +231,18 @@ func (app *application) deleteEvent(c *gin.Context) { } +// AddAttendeeToEvent adds a user to an event +// @Summary Add attendee to event +// @Description Adds a user as an attendee to a specific event +// @Tags Attendees +// @Param id path int true "Event ID" +// @Param userId path int true "User ID" +// @Success 201 {object} database.Attendee +// @Failure 400 {object} map[string]string +// @Failure 403 {object} map[string]string +// @Failure 404 {object} map[string]string +// @Router /events/{id}/attendees/{userId} [post] +// @Security BearerAuth func (app *application) addAttendeeToEvent(c *gin.Context) { eventId, err := strconv.Atoi(c.Param("id")) if err != nil { @@ -262,6 +327,14 @@ func (app *application) addAttendeeToEvent(c *gin.Context) { c.JSON(http.StatusCreated, attendee) } +// GetAttendeesForEvent retrieves attendees for a given event +// @Summary Get attendees for event +// @Description Get a list of all attendees for a specific event +// @Tags Attendees +// @Param id path int true "Event ID" +// @Success 200 {array} database.Attendee +// @Failure 400 {object} map[string]string +// @Router /events/{id}/attendees [get] func (app *application) getAttendeesForEvent(c *gin.Context) { id, err := strconv.Atoi(c.Param("id")) if err != nil { diff --git a/cmd/api/main.go b/cmd/api/main.go index 1f60a6f..0d121a4 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -4,12 +4,28 @@ import ( "database/sql" "log" + _ "github.com/kunalkumar-1/Evently/docs" _ "github.com/joho/godotenv/autoload" "github.com/kunalkumar-1/Evently/internals/database" "github.com/kunalkumar-1/Evently/internals/env" _ "github.com/mattn/go-sqlite3" ) +// @title Evently API +// @version 1.0 +// @description Event Management REST API built with Go and Gin. + +// @contact.name API Support +// @contact.url https://github.com/kunalkumar-1/Evently +// @contact.email kunaldevspro@gmail.com + +// @license.name MIT +// @license.url https://opensource.org/licenses/MIT + +// @host localhost:8080 +// @BasePath /api/v1 +// @schemes http + type application struct { port int jwtSecret string diff --git a/cmd/api/routes.go b/cmd/api/routes.go index c334ac6..4070b32 100644 --- a/cmd/api/routes.go +++ b/cmd/api/routes.go @@ -4,6 +4,8 @@ import ( "net/http" "github.com/gin-gonic/gin" + swaggerFiles "github.com/swaggo/files" + ginSwagger "github.com/swaggo/gin-swagger" ) func (app *application) routes() http.Handler { @@ -29,5 +31,12 @@ func (app *application) routes() http.Handler { auth.DELETE("/events/:id/attendees/:userId", app.deleteAttendeeFromEvent) // delete attendee from event } + r.GET("/swagger/*any", func(c *gin.Context){ + if c.Request.RequestURI == "/swagger/" { + c.Redirect(302, "/swagger/index.html") + } + ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.URL("http://localhost:8080/swagger/doc.json"))(c) + }) + return r } diff --git a/docs/docs.go b/docs/docs.go new file mode 100644 index 0000000..7c63f0e --- /dev/null +++ b/docs/docs.go @@ -0,0 +1,430 @@ +// Package docs 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}}", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "API Support", + "url": "https://github.com/kunalkumar-1/Evently", + "email": "support@example.com" + }, + "license": { + "name": "MIT", + "url": "https://opensource.org/licenses/MIT" + }, + "version": "{{.Version}}" + }, + "host": "{{.Host}}", + "basePath": "{{.BasePath}}", + "paths": { + "/events": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Create a new event owned by the authenticated user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Events" + ], + "summary": "Create a new event", + "parameters": [ + { + "description": "Event Data", + "name": "event", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/database.Event" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/database.Event" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/events/{id}": { + "get": { + "description": "Retrieve details of a specific event", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Events" + ], + "summary": "Get event by ID", + "parameters": [ + { + "type": "integer", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/database.Event" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "404": { + "description": "Not Found", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Update an existing event by ID (only by owner)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Events" + ], + "summary": "Update event", + "parameters": [ + { + "type": "integer", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Updated Event Data", + "name": "event", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/database.Event" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/database.Event" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Delete an event by ID (only by owner)", + "tags": [ + "Events" + ], + "summary": "Delete event", + "parameters": [ + { + "type": "integer", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "404": { + "description": "Not Found", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/events/{id}/attendees": { + "get": { + "description": "Get a list of all attendees for a specific event", + "tags": [ + "Attendees" + ], + "summary": "Get attendees for event", + "parameters": [ + { + "type": "integer", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/database.Attendee" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/events/{id}/attendees/{userId}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Adds a user as an attendee to a specific event", + "tags": [ + "Attendees" + ], + "summary": "Add attendee to event", + "parameters": [ + { + "type": "integer", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "User ID", + "name": "userId", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/database.Attendee" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "404": { + "description": "Not Found", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + }, + "definitions": { + "database.Attendee": { + "type": "object", + "properties": { + "eventid": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "userid": { + "type": "integer" + } + } + }, + "database.Event": { + "type": "object", + "required": [ + "date", + "description", + "location", + "name" + ], + "properties": { + "date": { + "type": "string" + }, + "description": { + "type": "string", + "maxLength": 500, + "minLength": 3 + }, + "id": { + "type": "integer" + }, + "location": { + "type": "string", + "minLength": 3 + }, + "name": { + "type": "string", + "maxLength": 50, + "minLength": 3 + }, + "ownerId": { + "type": "integer" + } + } + } + } +}` + +// SwaggerInfo holds exported Swagger Info so clients can modify it +var SwaggerInfo = &swag.Spec{ + Version: "1.0", + Host: "localhost:8080", + BasePath: "/api/v1", + Schemes: []string{"http"}, + Title: "Evently API", + Description: "Event Management REST API built with Go and Gin.", + InfoInstanceName: "swagger", + SwaggerTemplate: docTemplate, + LeftDelim: "{{", + RightDelim: "}}", +} + +func init() { + swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo) +} diff --git a/docs/swagger.json b/docs/swagger.json new file mode 100644 index 0000000..d3d2a23 --- /dev/null +++ b/docs/swagger.json @@ -0,0 +1,409 @@ +{ + "schemes": [ + "http" + ], + "swagger": "2.0", + "info": { + "description": "Event Management REST API built with Go and Gin.", + "title": "Evently API", + "termsOfService": "http://swagger.io/terms/", + "contact": { + "name": "API Support", + "url": "https://github.com/kunalkumar-1/Evently", + "email": "support@example.com" + }, + "license": { + "name": "MIT", + "url": "https://opensource.org/licenses/MIT" + }, + "version": "1.0" + }, + "host": "localhost:8080", + "basePath": "/api/v1", + "paths": { + "/events": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Create a new event owned by the authenticated user", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Events" + ], + "summary": "Create a new event", + "parameters": [ + { + "description": "Event Data", + "name": "event", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/database.Event" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/database.Event" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/events/{id}": { + "get": { + "description": "Retrieve details of a specific event", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Events" + ], + "summary": "Get event by ID", + "parameters": [ + { + "type": "integer", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/database.Event" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "404": { + "description": "Not Found", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "put": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Update an existing event by ID (only by owner)", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "Events" + ], + "summary": "Update event", + "parameters": [ + { + "type": "integer", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Updated Event Data", + "name": "event", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/database.Event" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/database.Event" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "500": { + "description": "Internal Server Error", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + }, + "delete": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Delete an event by ID (only by owner)", + "tags": [ + "Events" + ], + "summary": "Delete event", + "parameters": [ + { + "type": "integer", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "204": { + "description": "No Content" + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "404": { + "description": "Not Found", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/events/{id}/attendees": { + "get": { + "description": "Get a list of all attendees for a specific event", + "tags": [ + "Attendees" + ], + "summary": "Get attendees for event", + "parameters": [ + { + "type": "integer", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/database.Attendee" + } + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + }, + "/events/{id}/attendees/{userId}": { + "post": { + "security": [ + { + "BearerAuth": [] + } + ], + "description": "Adds a user as an attendee to a specific event", + "tags": [ + "Attendees" + ], + "summary": "Add attendee to event", + "parameters": [ + { + "type": "integer", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + }, + { + "type": "integer", + "description": "User ID", + "name": "userId", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/database.Attendee" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "403": { + "description": "Forbidden", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + }, + "404": { + "description": "Not Found", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string" + } + } + } + } + } + } + }, + "definitions": { + "database.Attendee": { + "type": "object", + "properties": { + "eventid": { + "type": "integer" + }, + "id": { + "type": "integer" + }, + "userid": { + "type": "integer" + } + } + }, + "database.Event": { + "type": "object", + "required": [ + "date", + "description", + "location", + "name" + ], + "properties": { + "date": { + "type": "string" + }, + "description": { + "type": "string", + "maxLength": 500, + "minLength": 3 + }, + "id": { + "type": "integer" + }, + "location": { + "type": "string", + "minLength": 3 + }, + "name": { + "type": "string", + "maxLength": 50, + "minLength": 3 + }, + "ownerId": { + "type": "integer" + } + } + } + } +} \ No newline at end of file diff --git a/docs/swagger.yaml b/docs/swagger.yaml new file mode 100644 index 0000000..13e8d67 --- /dev/null +++ b/docs/swagger.yaml @@ -0,0 +1,269 @@ +basePath: /api/v1 +definitions: + database.Attendee: + properties: + eventid: + type: integer + id: + type: integer + userid: + type: integer + type: object + database.Event: + properties: + date: + type: string + description: + maxLength: 500 + minLength: 3 + type: string + id: + type: integer + location: + minLength: 3 + type: string + name: + maxLength: 50 + minLength: 3 + type: string + ownerId: + type: integer + required: + - date + - description + - location + - name + type: object +host: localhost:8080 +info: + contact: + email: support@example.com + name: API Support + url: https://github.com/kunalkumar-1/Evently + description: Event Management REST API built with Go and Gin. + license: + name: MIT + url: https://opensource.org/licenses/MIT + termsOfService: http://swagger.io/terms/ + title: Evently API + version: "1.0" +paths: + /events: + post: + consumes: + - application/json + description: Create a new event owned by the authenticated user + parameters: + - description: Event Data + in: body + name: event + required: true + schema: + $ref: '#/definitions/database.Event' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/database.Event' + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "500": + description: Internal Server Error + schema: + additionalProperties: + type: string + type: object + security: + - BearerAuth: [] + summary: Create a new event + tags: + - Events + /events/{id}: + delete: + description: Delete an event by ID (only by owner) + parameters: + - description: Event ID + in: path + name: id + required: true + type: integer + responses: + "204": + description: No Content + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "403": + description: Forbidden + schema: + additionalProperties: + type: string + type: object + "404": + description: Not Found + schema: + additionalProperties: + type: string + type: object + security: + - BearerAuth: [] + summary: Delete event + tags: + - Events + get: + consumes: + - application/json + description: Retrieve details of a specific event + parameters: + - description: Event ID + in: path + name: id + required: true + type: integer + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/database.Event' + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "404": + description: Not Found + schema: + additionalProperties: + type: string + type: object + summary: Get event by ID + tags: + - Events + put: + consumes: + - application/json + description: Update an existing event by ID (only by owner) + parameters: + - description: Event ID + in: path + name: id + required: true + type: integer + - description: Updated Event Data + in: body + name: event + required: true + schema: + $ref: '#/definitions/database.Event' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/database.Event' + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "403": + description: Forbidden + schema: + additionalProperties: + type: string + type: object + "500": + description: Internal Server Error + schema: + additionalProperties: + type: string + type: object + security: + - BearerAuth: [] + summary: Update event + tags: + - Events + /events/{id}/attendees: + get: + description: Get a list of all attendees for a specific event + parameters: + - description: Event ID + in: path + name: id + required: true + type: integer + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/database.Attendee' + type: array + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + summary: Get attendees for event + tags: + - Attendees + /events/{id}/attendees/{userId}: + post: + description: Adds a user as an attendee to a specific event + parameters: + - description: Event ID + in: path + name: id + required: true + type: integer + - description: User ID + in: path + name: userId + required: true + type: integer + responses: + "201": + description: Created + schema: + $ref: '#/definitions/database.Attendee' + "400": + description: Bad Request + schema: + additionalProperties: + type: string + type: object + "403": + description: Forbidden + schema: + additionalProperties: + type: string + type: object + "404": + description: Not Found + schema: + additionalProperties: + type: string + type: object + security: + - BearerAuth: [] + summary: Add attendee to event + tags: + - Attendees +schemes: +- http +swagger: "2.0" diff --git a/go.mod b/go.mod index a2ab52f..4da016c 100644 --- a/go.mod +++ b/go.mod @@ -4,21 +4,32 @@ go 1.24.5 require ( github.com/golang-migrate/migrate/v4 v4.18.3 - golang.org/x/crypto v0.40.0 + github.com/swaggo/swag v1.16.6 + golang.org/x/crypto v0.44.0 ) require ( + github.com/KyleBanks/depth v1.2.1 // indirect github.com/bytedance/sonic v1.11.6 // indirect github.com/bytedance/sonic/loader v0.1.1 // indirect github.com/cloudwego/base64x v0.1.4 // indirect github.com/cloudwego/iasm v0.2.0 // indirect github.com/gabriel-vasile/mimetype v1.4.3 // indirect github.com/gin-contrib/sse v0.1.0 // indirect + github.com/go-openapi/jsonpointer v0.22.1 // indirect + github.com/go-openapi/jsonreference v0.21.3 // indirect + github.com/go-openapi/spec v0.22.1 // indirect + github.com/go-openapi/swag/conv v0.25.1 // indirect + github.com/go-openapi/swag/jsonname v0.25.1 // indirect + github.com/go-openapi/swag/jsonutils v0.25.1 // indirect + github.com/go-openapi/swag/loading v0.25.1 // indirect + github.com/go-openapi/swag/stringutils v0.25.1 // indirect + github.com/go-openapi/swag/typeutils v0.25.1 // indirect + github.com/go-openapi/swag/yamlutils v0.25.1 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.20.0 // indirect github.com/goccy/go-json v0.10.2 // indirect - github.com/google/go-cmp v0.6.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/cpuid/v2 v2.2.7 // indirect github.com/leodido/go-urn v1.4.0 // indirect @@ -28,10 +39,14 @@ require ( github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/twitchyliquid64/golang-asm v0.15.1 // indirect github.com/ugorji/go/codec v1.2.12 // indirect + go.yaml.in/yaml/v3 v3.0.4 // indirect golang.org/x/arch v0.8.0 // indirect - golang.org/x/net v0.42.0 // indirect - golang.org/x/sys v0.34.0 // indirect - golang.org/x/text v0.27.0 // indirect + golang.org/x/mod v0.30.0 // indirect + golang.org/x/net v0.47.0 // indirect + golang.org/x/sync v0.18.0 // indirect + golang.org/x/sys v0.38.0 // indirect + golang.org/x/text v0.31.0 // indirect + golang.org/x/tools v0.38.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) @@ -43,5 +58,7 @@ require ( github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/joho/godotenv v1.5.1 github.com/mattn/go-sqlite3 v1.14.22 + github.com/swaggo/files v1.0.1 + github.com/swaggo/gin-swagger v1.6.1 go.uber.org/atomic v1.11.0 // indirect ) diff --git a/go.sum b/go.sum index 7d0a5b0..30ea1ae 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc= +github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE= github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0= github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4= github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM= @@ -11,10 +13,37 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0= github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk= +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.10.1 h1:T0ujvqyCSqRopADpgPgiTT63DUQVSfojyME59Ei63pQ= github.com/gin-gonic/gin v1.10.1/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y= +github.com/go-openapi/jsonpointer v0.22.1 h1:sHYI1He3b9NqJ4wXLoJDKmUmHkWy/L7rtEo92JUxBNk= +github.com/go-openapi/jsonpointer v0.22.1/go.mod h1:pQT9OsLkfz1yWoMgYFy4x3U5GY5nUlsOn1qSBH5MkCM= +github.com/go-openapi/jsonreference v0.21.3 h1:96Dn+MRPa0nYAR8DR1E03SblB5FJvh7W6krPI0Z7qMc= +github.com/go-openapi/jsonreference v0.21.3/go.mod h1:RqkUP0MrLf37HqxZxrIAtTWW4ZJIK1VzduhXYBEeGc4= +github.com/go-openapi/spec v0.22.1 h1:beZMa5AVQzRspNjvhe5aG1/XyBSMeX1eEOs7dMoXh/k= +github.com/go-openapi/spec v0.22.1/go.mod h1:c7aeIQT175dVowfp7FeCvXXnjN/MrpaONStibD2WtDA= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag/conv v0.25.1 h1:+9o8YUg6QuqqBM5X6rYL/p1dpWeZRhoIt9x7CCP+he0= +github.com/go-openapi/swag/conv v0.25.1/go.mod h1:Z1mFEGPfyIKPu0806khI3zF+/EUXde+fdeksUl2NiDs= +github.com/go-openapi/swag/jsonname v0.25.1 h1:Sgx+qbwa4ej6AomWC6pEfXrA6uP2RkaNjA9BR8a1RJU= +github.com/go-openapi/swag/jsonname v0.25.1/go.mod h1:71Tekow6UOLBD3wS7XhdT98g5J5GR13NOTQ9/6Q11Zo= +github.com/go-openapi/swag/jsonutils v0.25.1 h1:AihLHaD0brrkJoMqEZOBNzTLnk81Kg9cWr+SPtxtgl8= +github.com/go-openapi/swag/jsonutils v0.25.1/go.mod h1:JpEkAjxQXpiaHmRO04N1zE4qbUEg3b7Udll7AMGTNOo= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.1 h1:DSQGcdB6G0N9c/KhtpYc71PzzGEIc/fZ1no35x4/XBY= +github.com/go-openapi/swag/jsonutils/fixtures_test v0.25.1/go.mod h1:kjmweouyPwRUEYMSrbAidoLMGeJ5p6zdHi9BgZiqmsg= +github.com/go-openapi/swag/loading v0.25.1 h1:6OruqzjWoJyanZOim58iG2vj934TysYVptyaoXS24kw= +github.com/go-openapi/swag/loading v0.25.1/go.mod h1:xoIe2EG32NOYYbqxvXgPzne989bWvSNoWoyQVWEZicc= +github.com/go-openapi/swag/stringutils v0.25.1 h1:Xasqgjvk30eUe8VKdmyzKtjkVjeiXx1Iz0zDfMNpPbw= +github.com/go-openapi/swag/stringutils v0.25.1/go.mod h1:JLdSAq5169HaiDUbTvArA2yQxmgn4D6h4A+4HqVvAYg= +github.com/go-openapi/swag/typeutils v0.25.1 h1:rD/9HsEQieewNt6/k+JBwkxuAHktFtH3I3ysiFZqukA= +github.com/go-openapi/swag/typeutils v0.25.1/go.mod h1:9McMC/oCdS4BKwk2shEB7x17P6HmMmA6dQRtAkSnNb8= +github.com/go-openapi/swag/yamlutils v0.25.1 h1:mry5ez8joJwzvMbaTGLhw8pXUnhDK91oSJLDPF1bmGk= +github.com/go-openapi/swag/yamlutils v0.25.1/go.mod h1:cm9ywbzncy3y6uPm/97ysW8+wZ09qsks+9RS8fLWKqg= +github.com/go-openapi/testify/v2 v2.0.2 h1:X999g3jeLcoY8qctY/c/Z8iBHTbwLz7R2WXd6Ub6wls= +github.com/go-openapi/testify/v2 v2.0.2/go.mod h1:HCPmvFFnheKK2BuwSA0TbbdxJ3I16pjwMkYkP4Ywn54= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= @@ -45,6 +74,10 @@ github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02 github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM= github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +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.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ= github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= @@ -62,6 +95,8 @@ github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6 github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ= +github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc= 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= @@ -72,31 +107,73 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ 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/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE= +github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg= +github.com/swaggo/gin-swagger v1.6.1 h1:Ri06G4gc9N4t4k8hekMigJ9zKTFSlqj/9paAQCQs7cY= +github.com/swaggo/gin-swagger v1.6.1/go.mod h1:LQ+hJStHakCWRiK/YNYtJOu4mR2FP+pxLnILT/qNiTw= +github.com/swaggo/swag v1.16.6 h1:qBNcx53ZaX+M5dxVyTrgQ0PJ/ACK+NzhwcbieTt+9yI= +github.com/swaggo/swag v1.16.6/go.mod h1:ngP2etMK5a0P3QBizic5MEwpRmluJZPHjXcMoj4Xesg= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE= github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE= go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.yaml.in/yaml/v3 v3.0.4 h1:tfq32ie2Jv2UxXFdLJdh3jXuOzWiL1fo0bu/FbuKpbc= +go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg= golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc= golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys= -golang.org/x/crypto v0.40.0 h1:r4x+VvoG5Fm+eJcxMaY8CQM7Lb0l1lsmjGBQ6s8BfKM= -golang.org/x/crypto v0.40.0/go.mod h1:Qr1vMER5WyS2dfPHAlsOj01wgLbsyWtFn/aY+5+ZdxY= -golang.org/x/net v0.42.0 h1:jzkYrhi3YQWD6MLBJcsklgQsoAcw89EcZbJw8Z614hs= -golang.org/x/net v0.42.0/go.mod h1:FF1RA5d3u7nAYA4z2TkclSCKh68eSXtiFwcWQpPXdt8= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU= +golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk= +golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY= +golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I= +golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/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-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.34.0 h1:H5Y5sJ2L2JRdyv7ROF1he/lPdvFsd0mJHFw2ThKHxLA= -golang.org/x/sys v0.34.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= -golang.org/x/text v0.27.0 h1:4fGWRpyh641NLlecmyl4LOe6yDdfaYNrGb2zdfo4JV4= -golang.org/x/text v0.27.0/go.mod h1:1D28KMCvyooCX9hBiosv5Tz/+YLxj0j7XhWjpSUF7CU= +golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc= +golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks= +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.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM= +golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ= +golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/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/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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= From d3eb2196c5f573275dee0769d8d1172796da3a06 Mon Sep 17 00:00:00 2001 From: KUNAL KUMAR Date: Wed, 12 Nov 2025 02:20:56 +0530 Subject: [PATCH 2/2] chore: added the swagger docs' --- cmd/api/main.go | 2 +- cmd/api/routes.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/api/main.go b/cmd/api/main.go index 0d121a4..a05c2bd 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -4,8 +4,8 @@ import ( "database/sql" "log" - _ "github.com/kunalkumar-1/Evently/docs" _ "github.com/joho/godotenv/autoload" + _ "github.com/kunalkumar-1/Evently/docs" "github.com/kunalkumar-1/Evently/internals/database" "github.com/kunalkumar-1/Evently/internals/env" _ "github.com/mattn/go-sqlite3" diff --git a/cmd/api/routes.go b/cmd/api/routes.go index 4070b32..35980fa 100644 --- a/cmd/api/routes.go +++ b/cmd/api/routes.go @@ -31,9 +31,9 @@ func (app *application) routes() http.Handler { auth.DELETE("/events/:id/attendees/:userId", app.deleteAttendeeFromEvent) // delete attendee from event } - r.GET("/swagger/*any", func(c *gin.Context){ + r.GET("/swagger/*any", func(c *gin.Context) { if c.Request.RequestURI == "/swagger/" { - c.Redirect(302, "/swagger/index.html") + c.Redirect(302, "/swagger/index.html") } ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.URL("http://localhost:8080/swagger/doc.json"))(c) })