Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gear be/fdr 52 be docs gateway checkin #9

Merged
merged 4 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,4 @@ model:
go get github.com/isd-sgcu/rpkm67-model@latest

swagger:
swag init -d ./internal/file -g ../../cmd/main.go -o ./docs -md ./docs/markdown --parseDependency --parseInternal
swag init -d ./internal/checkin -g ../../cmd/main.go -o ./docs -md ./docs/markdown --parseDependency --parseInternal
8 changes: 7 additions & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ import (
"google.golang.org/grpc/credentials/insecure"
)

// @title RPKM67 API
// @version 1.0
// @description the RPKM67 API server.

// @host localhost:3001
// @BasePath /api/v1
func main() {
conf, err := config.LoadConfig()
if err != nil {
Expand Down Expand Up @@ -66,7 +72,7 @@ func main() {
r.V1Patch("/user/profile/:id", userHdr.UpdateProfile)
r.V1Put("/user/picture/:id", userHdr.UpdatePicture)

r.V1Post("/checkin/create", checkinHdr.Create)
r.V1Post("/checkin", checkinHdr.Create)
r.V1Get("/checkin/:userId", checkinHdr.FindByUserID)
r.V1Get("/checkin/email/:email", checkinHdr.FindByEmail)

Expand Down
227 changes: 227 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
// 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}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/checkin": {
"post": {
"description": "Create a check-in using email, event and user_id",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"checkin"
],
"summary": "Create a check-in",
"parameters": [
{
"description": "Create CheckIn Request",
"name": "create",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.CreateCheckInRequest"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/dto.CreateCheckInResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/apperror.AppError"
}
}
}
}
},
"/checkin/email/{email}": {
"get": {
"description": "Find check-ins by email",
"consumes": [
"text/plain"
],
"produces": [
"application/json"
],
"tags": [
"checkin"
],
"summary": "Find check-ins by email",
"parameters": [
{
"type": "string",
"description": "Email",
"name": "email",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.FindByEmailCheckInResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/apperror.AppError"
}
}
}
}
},
"/checkin/{userId}": {
"get": {
"description": "Find check-ins by user_id",
"consumes": [
"text/plain"
],
"produces": [
"application/json"
],
"tags": [
"checkin"
],
"summary": "Find check-ins by user_id",
"parameters": [
{
"type": "string",
"description": "User ID",
"name": "userId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.FindByUserIdCheckInResponse"
}
},
"400": {
"description": "Bad Request",
"schema": {
"$ref": "#/definitions/apperror.AppError"
}
}
}
}
}
},
"definitions": {
"apperror.AppError": {
"type": "object",
"properties": {
"httpCode": {
"type": "integer"
},
"id": {
"type": "string"
}
}
},
"dto.CheckIn": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"event": {
"type": "string"
},
"id": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"dto.CreateCheckInRequest": {
"type": "object",
"properties": {
"email": {
"type": "string"
},
"event": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"dto.CreateCheckInResponse": {
"type": "object",
"properties": {
"checkin": {
"$ref": "#/definitions/dto.CheckIn"
}
}
},
"dto.FindByEmailCheckInResponse": {
"type": "object",
"properties": {
"checkins": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.CheckIn"
}
}
}
},
"dto.FindByUserIdCheckInResponse": {
"type": "object",
"properties": {
"checkins": {
"type": "array",
"items": {
"$ref": "#/definitions/dto.CheckIn"
}
}
}
}
}
}`

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "localhost:3001",
BasePath: "/api/v1",
Schemes: []string{},
Title: "RPKM67 API",
Description: "the RPKM67 API server.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
Loading
Loading