Skip to content

Commit

Permalink
configure role swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
GenesisBlock3301 committed Dec 19, 2023
1 parent 7a9c76d commit 769666c
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 8 deletions.
17 changes: 17 additions & 0 deletions backend/controllers/role_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ func NewRoleController(RoleService services.RoleService) *RoleController {
}
}

// CreateRoleController
// @BasePath /api/v1
// @Summary Create Role.
// @Param user body serializers.Role true "Role Info"
// @Tags Role
// @Accept json
// @Produce json
// @Success 200 {string} sent verify init.
// @Router /create/ [post]
func (u *RoleController) CreateRoleController(ctx *gin.Context) {
var roleInput serializers.Role
if err := ctx.ShouldBindJSON(&roleInput); err != nil {
Expand All @@ -31,6 +40,14 @@ func (u *RoleController) CreateRoleController(ctx *gin.Context) {
ctx.JSON(200, gin.H{"message": "Successfully role created!"})
}

// GetALLRoleController
// @BasePath /api/v1
// @Summary Create Role.
// @Tags Role
// @Accept json
// @Produce json
// @Success 200 {string} sent verify init.
// @Router /list/ [get]
func (u *RoleController) GetALLRoleController(ctx *gin.Context) {
limit := ctx.Query("limit")
offset := ctx.Query("offset")
Expand Down
67 changes: 65 additions & 2 deletions docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,39 @@ const docTemplate = `{
}
}
},
"/create/": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Role"
],
"summary": "Create Role.",
"parameters": [
{
"description": "Role Info",
"name": "user",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/serializers.Role"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/email-verify/": {
"get": {
"consumes": [
Expand Down Expand Up @@ -152,6 +185,28 @@ const docTemplate = `{
}
}
},
"/list/": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Role"
],
"summary": "Create Role.",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/login": {
"post": {
"description": "User login",
Expand Down Expand Up @@ -257,6 +312,14 @@ const docTemplate = `{
}
}
},
"serializers.Role": {
"type": "object",
"properties": {
"role_name": {
"type": "string"
}
}
},
"serializers.VerifyOTPSerializer": {
"type": "object",
"properties": {
Expand All @@ -283,8 +346,8 @@ var SwaggerInfo = &swag.Spec{
Host: "localhost:8080",
BasePath: "/api/v1",
Schemes: []string{},
Title: "Swagger Example API",
Description: "This is a sample server celler server.",
Title: "Role Based Authentication API",
Description: "This is golang full-featured project.",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
Expand Down
67 changes: 65 additions & 2 deletions docs/swagger.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"swagger": "2.0",
"info": {
"description": "This is a sample server celler server.",
"title": "Swagger Example API",
"description": "This is golang full-featured project.",
"title": "Role Based Authentication API",
"termsOfService": "http://swagger.io/terms/",
"contact": {
"name": "API Support",
Expand Down Expand Up @@ -81,6 +81,39 @@
}
}
},
"/create/": {
"post": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Role"
],
"summary": "Create Role.",
"parameters": [
{
"description": "Role Info",
"name": "user",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/serializers.Role"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/email-verify/": {
"get": {
"consumes": [
Expand Down Expand Up @@ -146,6 +179,28 @@
}
}
},
"/list/": {
"get": {
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Role"
],
"summary": "Create Role.",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
}
}
}
},
"/login": {
"post": {
"description": "User login",
Expand Down Expand Up @@ -251,6 +306,14 @@
}
}
},
"serializers.Role": {
"type": "object",
"properties": {
"role_name": {
"type": "string"
}
}
},
"serializers.VerifyOTPSerializer": {
"type": "object",
"properties": {
Expand Down
44 changes: 42 additions & 2 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ definitions:
- name
- password
type: object
serializers.Role:
properties:
role_name:
type: string
type: object
serializers.VerifyOTPSerializer:
properties:
code:
Expand All @@ -34,12 +39,12 @@ info:
email: support@swagger.io
name: API Support
url: http://www.swagger.io/support
description: This is a sample server celler server.
description: This is golang full-featured project.
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: http://swagger.io/terms/
title: Swagger Example API
title: Role Based Authentication API
version: "1.0"
paths:
/:
Expand Down Expand Up @@ -83,6 +88,27 @@ paths:
summary: Register User.
tags:
- User
/create/:
post:
consumes:
- application/json
parameters:
- description: Role Info
in: body
name: user
required: true
schema:
$ref: '#/definitions/serializers.Role'
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
summary: Create Role.
tags:
- Role
/email-verify/:
get:
consumes:
Expand Down Expand Up @@ -125,6 +151,20 @@ paths:
summary: Generate OTP.
tags:
- User
/list/:
get:
consumes:
- application/json
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
summary: Create Role.
tags:
- Role
/login:
post:
consumes:
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ func initEnv() {
schemas.SetTableName()
}

// @title Swagger Example API
// @title Role Based Authentication API
// @version 1.0
// @description This is a sample server celler server.
// @description This is golang full-featured project.
// @termsOfService http://swagger.io/terms/

// @contact.name API Support
Expand Down

0 comments on commit 769666c

Please sign in to comment.