From 1ff9314ffa26bb7b9bcb9d863b6c79918e24b5ea Mon Sep 17 00:00:00 2001 From: peterxcli Date: Tue, 23 Jan 2024 17:00:18 +0800 Subject: [PATCH] docs: update to latest swagger config --- docs/docs.go | 275 +++++++++++++++++++--------------------------- docs/swagger.json | 275 +++++++++++++++++++--------------------------- docs/swagger.yaml | 203 ++++++++++++++-------------------- 3 files changed, 304 insertions(+), 449 deletions(-) diff --git a/docs/docs.go b/docs/docs.go index 804f16e..05b7094 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -56,14 +56,16 @@ const docTemplate = `{ } } } - }, - "post": { + } + }, + "/events/{id}": { + "put": { "security": [ { "ApiKeyAuth": [] } ], - "description": "Subscribes a user to an event with the provided details", + "description": "Updates an event by ID with new details", "consumes": [ "application/json" ], @@ -73,11 +75,18 @@ const docTemplate = `{ "tags": [ "Event" ], - "summary": "Subscribe to an event", + "summary": "Update an event", "parameters": [ { - "description": "Event Subscription Request", - "name": "request", + "type": "string", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Event Update Information", + "name": "event", "in": "body", "required": true, "schema": { @@ -87,7 +96,7 @@ const docTemplate = `{ ], "responses": { "200": { - "description": "Successfully subscribed to the event", + "description": "Event successfully updated", "schema": { "$ref": "#/definitions/bikefest_pkg_model.EventResponse" } @@ -107,14 +116,9 @@ const docTemplate = `{ } } }, - "/events/user": { + "/line-login/auth": { "get": { - "security": [ - { - "ApiKeyAuth // include this line if the endpoint is protected by an API key or other security mechanism": [] - } - ], - "description": "Retrieves a list of events associated with a user", + "description": "Redirects the user to LINE's OAuth service for authentication.", "consumes": [ "application/json" ], @@ -122,33 +126,36 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Event" + "OAuth" + ], + "summary": "Initiate LINE OAuth login", + "parameters": [ + { + "type": "string", + "description": "Redirect path after login", + "name": "redirect_path", + "in": "query" + } ], - "summary": "Get User Events", "responses": { - "200": { - "description": "List of events associated with the user", + "301": { + "description": "Redirect to the target URL", "schema": { - "$ref": "#/definitions/bikefest_pkg_model.EventListResponse" + "type": "string" } }, - "500": { - "description": "Internal Server Error", + "400": { + "description": "Bad Request", "schema": { - "$ref": "#/definitions/bikefest_pkg_model.Response" + "type": "string" } } } } }, - "/events/{event_id}": { - "delete": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Deletes a specific event by its ID for a given user", + "/line-login/callback": { + "get": { + "description": "Handles the callback from LINE's OAuth service and redirects the user to the frontend with the tokens in the query and cookies.", "consumes": [ "application/json" ], @@ -156,30 +163,59 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Event" + "OAuth" ], - "summary": "Delete event", + "summary": "Handle LINE OAuth callback", "parameters": [ { "type": "string", - "description": "User ID", - "name": "user_id", - "in": "header", + "description": "Authorization code", + "name": "code", + "in": "query", "required": true }, { "type": "string", - "description": "Event ID", - "name": "event_id", - "in": "path", + "description": "State", + "name": "state", + "in": "query", "required": true } ], + "responses": { + "301": { + "description": "Redirect to the frontend", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "string" + } + } + } + } + }, + "/users": { + "get": { + "description": "Retrieves a list of users", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Get Users", "responses": { "200": { - "description": "Event successfully deleted", + "description": "List of users successfully retrieved", "schema": { - "$ref": "#/definitions/bikefest_pkg_model.Response" + "$ref": "#/definitions/bikefest_pkg_model.UserListResponse" } }, "500": { @@ -191,9 +227,14 @@ const docTemplate = `{ } } }, - "/events/{id}": { + "/users/events": { "get": { - "description": "Retrieves an event using its unique ID", + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Retrieves a list of events associated with a user", "consumes": [ "application/json" ], @@ -201,23 +242,14 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Event" - ], - "summary": "Get event by ID", - "parameters": [ - { - "type": "string", - "description": "Event ID", - "name": "id", - "in": "path", - "required": true - } + "User" ], + "summary": "Get User Events", "responses": { "200": { - "description": "Event successfully retrieved", + "description": "List of events associated with the user", "schema": { - "$ref": "#/definitions/bikefest_pkg_model.EventResponse" + "$ref": "#/definitions/bikefest_pkg_model.EventListResponse" } }, "500": { @@ -228,13 +260,13 @@ const docTemplate = `{ } } }, - "put": { + "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "Updates an event by ID with new details", + "description": "Subscribes a user to an event with the provided details", "consumes": [ "application/json" ], @@ -242,20 +274,13 @@ const docTemplate = `{ "application/json" ], "tags": [ - "Event" + "User" ], - "summary": "Update an event", + "summary": "Subscribe to an event", "parameters": [ { - "type": "string", - "description": "Event ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Event Update Information", - "name": "event", + "description": "Event Subscription Request", + "name": "request", "in": "body", "required": true, "schema": { @@ -265,7 +290,7 @@ const docTemplate = `{ ], "responses": { "200": { - "description": "Event successfully updated", + "description": "Successfully subscribed to the event", "schema": { "$ref": "#/definitions/bikefest_pkg_model.EventResponse" } @@ -285,46 +310,14 @@ const docTemplate = `{ } } }, - "/line-login/auth": { - "get": { - "description": "Redirects the user to LINE's OAuth service for authentication.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OAuth" - ], - "summary": "Initiate LINE OAuth login", - "parameters": [ + "/users/events/{event_id}": { + "delete": { + "security": [ { - "type": "string", - "description": "Redirect path after login", - "name": "redirect_path", - "in": "query" + "ApiKeyAuth": [] } ], - "responses": { - "301": { - "description": "Redirect to the target URL", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "type": "string" - } - } - } - } - }, - "/line-login/callback": { - "get": { - "description": "Handles the callback from LINE's OAuth service and redirects the user to the frontend with the tokens in the query and cookies.", + "description": "Deletes a specific event by its ID for a given user", "consumes": [ "application/json" ], @@ -332,59 +325,23 @@ const docTemplate = `{ "application/json" ], "tags": [ - "OAuth" + "User" ], - "summary": "Handle LINE OAuth callback", + "summary": "Delete event", "parameters": [ { "type": "string", - "description": "Authorization code", - "name": "code", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "State", - "name": "state", - "in": "query", + "description": "Event ID", + "name": "event_id", + "in": "path", "required": true } ], - "responses": { - "301": { - "description": "Redirect to the frontend", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "type": "string" - } - } - } - } - }, - "/users": { - "get": { - "description": "Retrieves a list of users", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "Get Users", "responses": { "200": { - "description": "List of users successfully retrieved", + "description": "Event successfully deleted", "schema": { - "$ref": "#/definitions/bikefest_pkg_model.UserListResponse" + "$ref": "#/definitions/bikefest_pkg_model.Response" } }, "500": { @@ -637,21 +594,18 @@ const docTemplate = `{ "definitions": { "bikefest_pkg_model.CreateEventRequest": { "type": "object", - "required": [ - "event_id" - ], "properties": { "event_detail": { "type": "string" }, - "event_id": { - "type": "string" - }, "event_time_end": { "type": "string" }, "event_time_start": { "type": "string" + }, + "id": { + "type": "string" } } }, @@ -668,9 +622,6 @@ const docTemplate = `{ }, "bikefest_pkg_model.Event": { "type": "object", - "required": [ - "event_id" - ], "properties": { "createdAt": { "type": "string" @@ -682,10 +633,6 @@ const docTemplate = `{ "description": "the ` + "`" + `EventDetail` + "`" + ` field store the event detail in json format, this would be parsed when send to line message API", "type": "string" }, - "event_id": { - "description": "the event id is defne at the frontend", - "type": "string" - }, "event_time_end": { "type": "string" }, @@ -693,13 +640,11 @@ const docTemplate = `{ "type": "string" }, "id": { + "description": "the event id is defne at the frontend, if frontend don't have event id, the event id would be calculated by the hash of event detail and event time", "type": "string" }, "updatedAt": { "type": "string" - }, - "user_id": { - "type": "string" } } }, diff --git a/docs/swagger.json b/docs/swagger.json index e31b89b..211cc65 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -45,14 +45,16 @@ } } } - }, - "post": { + } + }, + "/events/{id}": { + "put": { "security": [ { "ApiKeyAuth": [] } ], - "description": "Subscribes a user to an event with the provided details", + "description": "Updates an event by ID with new details", "consumes": [ "application/json" ], @@ -62,11 +64,18 @@ "tags": [ "Event" ], - "summary": "Subscribe to an event", + "summary": "Update an event", "parameters": [ { - "description": "Event Subscription Request", - "name": "request", + "type": "string", + "description": "Event ID", + "name": "id", + "in": "path", + "required": true + }, + { + "description": "Event Update Information", + "name": "event", "in": "body", "required": true, "schema": { @@ -76,7 +85,7 @@ ], "responses": { "200": { - "description": "Successfully subscribed to the event", + "description": "Event successfully updated", "schema": { "$ref": "#/definitions/bikefest_pkg_model.EventResponse" } @@ -96,14 +105,9 @@ } } }, - "/events/user": { + "/line-login/auth": { "get": { - "security": [ - { - "ApiKeyAuth // include this line if the endpoint is protected by an API key or other security mechanism": [] - } - ], - "description": "Retrieves a list of events associated with a user", + "description": "Redirects the user to LINE's OAuth service for authentication.", "consumes": [ "application/json" ], @@ -111,33 +115,36 @@ "application/json" ], "tags": [ - "Event" + "OAuth" + ], + "summary": "Initiate LINE OAuth login", + "parameters": [ + { + "type": "string", + "description": "Redirect path after login", + "name": "redirect_path", + "in": "query" + } ], - "summary": "Get User Events", "responses": { - "200": { - "description": "List of events associated with the user", + "301": { + "description": "Redirect to the target URL", "schema": { - "$ref": "#/definitions/bikefest_pkg_model.EventListResponse" + "type": "string" } }, - "500": { - "description": "Internal Server Error", + "400": { + "description": "Bad Request", "schema": { - "$ref": "#/definitions/bikefest_pkg_model.Response" + "type": "string" } } } } }, - "/events/{event_id}": { - "delete": { - "security": [ - { - "ApiKeyAuth": [] - } - ], - "description": "Deletes a specific event by its ID for a given user", + "/line-login/callback": { + "get": { + "description": "Handles the callback from LINE's OAuth service and redirects the user to the frontend with the tokens in the query and cookies.", "consumes": [ "application/json" ], @@ -145,30 +152,59 @@ "application/json" ], "tags": [ - "Event" + "OAuth" ], - "summary": "Delete event", + "summary": "Handle LINE OAuth callback", "parameters": [ { "type": "string", - "description": "User ID", - "name": "user_id", - "in": "header", + "description": "Authorization code", + "name": "code", + "in": "query", "required": true }, { "type": "string", - "description": "Event ID", - "name": "event_id", - "in": "path", + "description": "State", + "name": "state", + "in": "query", "required": true } ], + "responses": { + "301": { + "description": "Redirect to the frontend", + "schema": { + "type": "string" + } + }, + "400": { + "description": "Bad Request", + "schema": { + "type": "string" + } + } + } + } + }, + "/users": { + "get": { + "description": "Retrieves a list of users", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "User" + ], + "summary": "Get Users", "responses": { "200": { - "description": "Event successfully deleted", + "description": "List of users successfully retrieved", "schema": { - "$ref": "#/definitions/bikefest_pkg_model.Response" + "$ref": "#/definitions/bikefest_pkg_model.UserListResponse" } }, "500": { @@ -180,9 +216,14 @@ } } }, - "/events/{id}": { + "/users/events": { "get": { - "description": "Retrieves an event using its unique ID", + "security": [ + { + "ApiKeyAuth": [] + } + ], + "description": "Retrieves a list of events associated with a user", "consumes": [ "application/json" ], @@ -190,23 +231,14 @@ "application/json" ], "tags": [ - "Event" - ], - "summary": "Get event by ID", - "parameters": [ - { - "type": "string", - "description": "Event ID", - "name": "id", - "in": "path", - "required": true - } + "User" ], + "summary": "Get User Events", "responses": { "200": { - "description": "Event successfully retrieved", + "description": "List of events associated with the user", "schema": { - "$ref": "#/definitions/bikefest_pkg_model.EventResponse" + "$ref": "#/definitions/bikefest_pkg_model.EventListResponse" } }, "500": { @@ -217,13 +249,13 @@ } } }, - "put": { + "post": { "security": [ { "ApiKeyAuth": [] } ], - "description": "Updates an event by ID with new details", + "description": "Subscribes a user to an event with the provided details", "consumes": [ "application/json" ], @@ -231,20 +263,13 @@ "application/json" ], "tags": [ - "Event" + "User" ], - "summary": "Update an event", + "summary": "Subscribe to an event", "parameters": [ { - "type": "string", - "description": "Event ID", - "name": "id", - "in": "path", - "required": true - }, - { - "description": "Event Update Information", - "name": "event", + "description": "Event Subscription Request", + "name": "request", "in": "body", "required": true, "schema": { @@ -254,7 +279,7 @@ ], "responses": { "200": { - "description": "Event successfully updated", + "description": "Successfully subscribed to the event", "schema": { "$ref": "#/definitions/bikefest_pkg_model.EventResponse" } @@ -274,46 +299,14 @@ } } }, - "/line-login/auth": { - "get": { - "description": "Redirects the user to LINE's OAuth service for authentication.", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "OAuth" - ], - "summary": "Initiate LINE OAuth login", - "parameters": [ + "/users/events/{event_id}": { + "delete": { + "security": [ { - "type": "string", - "description": "Redirect path after login", - "name": "redirect_path", - "in": "query" + "ApiKeyAuth": [] } ], - "responses": { - "301": { - "description": "Redirect to the target URL", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "type": "string" - } - } - } - } - }, - "/line-login/callback": { - "get": { - "description": "Handles the callback from LINE's OAuth service and redirects the user to the frontend with the tokens in the query and cookies.", + "description": "Deletes a specific event by its ID for a given user", "consumes": [ "application/json" ], @@ -321,59 +314,23 @@ "application/json" ], "tags": [ - "OAuth" + "User" ], - "summary": "Handle LINE OAuth callback", + "summary": "Delete event", "parameters": [ { "type": "string", - "description": "Authorization code", - "name": "code", - "in": "query", - "required": true - }, - { - "type": "string", - "description": "State", - "name": "state", - "in": "query", + "description": "Event ID", + "name": "event_id", + "in": "path", "required": true } ], - "responses": { - "301": { - "description": "Redirect to the frontend", - "schema": { - "type": "string" - } - }, - "400": { - "description": "Bad Request", - "schema": { - "type": "string" - } - } - } - } - }, - "/users": { - "get": { - "description": "Retrieves a list of users", - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "tags": [ - "User" - ], - "summary": "Get Users", "responses": { "200": { - "description": "List of users successfully retrieved", + "description": "Event successfully deleted", "schema": { - "$ref": "#/definitions/bikefest_pkg_model.UserListResponse" + "$ref": "#/definitions/bikefest_pkg_model.Response" } }, "500": { @@ -626,21 +583,18 @@ "definitions": { "bikefest_pkg_model.CreateEventRequest": { "type": "object", - "required": [ - "event_id" - ], "properties": { "event_detail": { "type": "string" }, - "event_id": { - "type": "string" - }, "event_time_end": { "type": "string" }, "event_time_start": { "type": "string" + }, + "id": { + "type": "string" } } }, @@ -657,9 +611,6 @@ }, "bikefest_pkg_model.Event": { "type": "object", - "required": [ - "event_id" - ], "properties": { "createdAt": { "type": "string" @@ -671,10 +622,6 @@ "description": "the `EventDetail` field store the event detail in json format, this would be parsed when send to line message API", "type": "string" }, - "event_id": { - "description": "the event id is defne at the frontend", - "type": "string" - }, "event_time_end": { "type": "string" }, @@ -682,13 +629,11 @@ "type": "string" }, "id": { + "description": "the event id is defne at the frontend, if frontend don't have event id, the event id would be calculated by the hash of event detail and event time", "type": "string" }, "updatedAt": { "type": "string" - }, - "user_id": { - "type": "string" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index a8d5cb9..86410b7 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -3,14 +3,12 @@ definitions: properties: event_detail: type: string - event_id: - type: string event_time_end: type: string event_time_start: type: string - required: - - event_id + id: + type: string type: object bikefest_pkg_model.CreateFakeUserRequest: properties: @@ -29,21 +27,17 @@ definitions: description: the `EventDetail` field store the event detail in json format, this would be parsed when send to line message API type: string - event_id: - description: the event id is defne at the frontend - type: string event_time_end: type: string event_time_start: type: string id: + description: the event id is defne at the frontend, if frontend don't have + event id, the event id would be calculated by the hash of event detail and + event time type: string updatedAt: type: string - user_id: - type: string - required: - - event_id type: object bikefest_pkg_model.EventListResponse: properties: @@ -155,94 +149,7 @@ paths: summary: Get all events tags: - Event - post: - consumes: - - application/json - description: Subscribes a user to an event with the provided details - parameters: - - description: Event Subscription Request - in: body - name: request - required: true - schema: - $ref: '#/definitions/bikefest_pkg_model.CreateEventRequest' - produces: - - application/json - responses: - "200": - description: Successfully subscribed to the event - schema: - $ref: '#/definitions/bikefest_pkg_model.EventResponse' - "400": - description: Bad Request - Invalid input - schema: - $ref: '#/definitions/bikefest_pkg_model.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/bikefest_pkg_model.Response' - security: - - ApiKeyAuth: [] - summary: Subscribe to an event - tags: - - Event - /events/{event_id}: - delete: - consumes: - - application/json - description: Deletes a specific event by its ID for a given user - parameters: - - description: User ID - in: header - name: user_id - required: true - type: string - - description: Event ID - in: path - name: event_id - required: true - type: string - produces: - - application/json - responses: - "200": - description: Event successfully deleted - schema: - $ref: '#/definitions/bikefest_pkg_model.Response' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/bikefest_pkg_model.Response' - security: - - ApiKeyAuth: [] - summary: Delete event - tags: - - Event /events/{id}: - get: - consumes: - - application/json - description: Retrieves an event using its unique ID - parameters: - - description: Event ID - in: path - name: id - required: true - type: string - produces: - - application/json - responses: - "200": - description: Event successfully retrieved - schema: - $ref: '#/definitions/bikefest_pkg_model.EventResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/bikefest_pkg_model.Response' - summary: Get event by ID - tags: - - Event put: consumes: - application/json @@ -279,27 +186,6 @@ paths: summary: Update an event tags: - Event - /events/user: - get: - consumes: - - application/json - description: Retrieves a list of events associated with a user - produces: - - application/json - responses: - "200": - description: List of events associated with the user - schema: - $ref: '#/definitions/bikefest_pkg_model.EventListResponse' - "500": - description: Internal Server Error - schema: - $ref: '#/definitions/bikefest_pkg_model.Response' - security: - - ApiKeyAuth // include this line if the endpoint is protected by an API key or other security mechanism: [] - summary: Get User Events - tags: - - Event /line-login/auth: get: consumes: @@ -399,6 +285,85 @@ paths: summary: Get user by ID tags: - User + /users/events: + get: + consumes: + - application/json + description: Retrieves a list of events associated with a user + produces: + - application/json + responses: + "200": + description: List of events associated with the user + schema: + $ref: '#/definitions/bikefest_pkg_model.EventListResponse' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/bikefest_pkg_model.Response' + security: + - ApiKeyAuth: [] + summary: Get User Events + tags: + - User + post: + consumes: + - application/json + description: Subscribes a user to an event with the provided details + parameters: + - description: Event Subscription Request + in: body + name: request + required: true + schema: + $ref: '#/definitions/bikefest_pkg_model.CreateEventRequest' + produces: + - application/json + responses: + "200": + description: Successfully subscribed to the event + schema: + $ref: '#/definitions/bikefest_pkg_model.EventResponse' + "400": + description: Bad Request - Invalid input + schema: + $ref: '#/definitions/bikefest_pkg_model.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/bikefest_pkg_model.Response' + security: + - ApiKeyAuth: [] + summary: Subscribe to an event + tags: + - User + /users/events/{event_id}: + delete: + consumes: + - application/json + description: Deletes a specific event by its ID for a given user + parameters: + - description: Event ID + in: path + name: event_id + required: true + type: string + produces: + - application/json + responses: + "200": + description: Event successfully deleted + schema: + $ref: '#/definitions/bikefest_pkg_model.Response' + "500": + description: Internal Server Error + schema: + $ref: '#/definitions/bikefest_pkg_model.Response' + security: + - ApiKeyAuth: [] + summary: Delete event + tags: + - User /users/login/{user_id}: get: consumes: