From 037acbe1286bae40727a8e7c504ab023acf30d82 Mon Sep 17 00:00:00 2001 From: ericprd Date: Mon, 24 Feb 2025 20:27:07 +0800 Subject: [PATCH] fix: path url and add docs --- internal/api/http/subscribe_plan/get_all.go | 2 +- openapi.yml | 144 ++++++++++++++++++++ 2 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 openapi.yml diff --git a/internal/api/http/subscribe_plan/get_all.go b/internal/api/http/subscribe_plan/get_all.go index 39625d3..c42b4ad 100644 --- a/internal/api/http/subscribe_plan/get_all.go +++ b/internal/api/http/subscribe_plan/get_all.go @@ -12,7 +12,7 @@ func GetAllPlan( router chi.Router, subsPlanSvc subscribeplansvc.SubsPlanIntf, ) { - router.Get("/get-plans", func(w http.ResponseWriter, r *http.Request) { + router.Get("/subscribe-plan/get-all", func(w http.ResponseWriter, r *http.Request) { ctx := r.Context() subsPlan, err := subsPlanSvc.GetAllPlan() if err != nil { diff --git a/openapi.yml b/openapi.yml new file mode 100644 index 0000000..3f89196 --- /dev/null +++ b/openapi.yml @@ -0,0 +1,144 @@ +openapi: 3.0.0 +info: + title: Staff and User API + version: 1.0.0 + description: API for handling staff and user login, registration, and subscription plan creation. + +paths: + /api/staff/login: + post: + summary: Login for staff + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + email: + type: string + format: email + password: + type: string + required: + - email + - password + responses: + "200": + description: Successful login + "400": + description: Bad request + + /api/staff/register: + post: + summary: Register a new staff member + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + email: + type: string + format: email + password: + type: string + required: + - email + - password + responses: + "201": + description: Staff member created + "400": + description: Bad request + "409": + description: Conflict (email already registered) + + /api/user/login: + post: + summary: Login for user + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + email: + type: string + format: email + password: + type: string + required: + - email + - password + responses: + "200": + description: Successful login + "400": + description: Bad request + + /api/user/register: + post: + summary: Register a new user + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + email: + type: string + format: email + password: + type: string + subscribe_plan_id: + type: string + phone: + type: string + format: phone + required: + - email + - password + - subscribe_plan_id + - phone + responses: + "201": + description: User created + "400": + description: Bad request + "409": + description: Conflict (email already registered) + + /subscribe-plan/create: + post: + summary: Create a new subscription plan + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + code: + type: string + required: + - code + responses: + "201": + description: Subscription plan created + "400": + description: Bad request + "409": + description: Conflict (plan code already exists) + + /subscribe-plan/get-all: + post: + summary: Get all subscription plan + responses: + "201": + description: Subscription plan created + "400": + description: Bad request