Docs example
This commit is contained in:
parent
fe6942aa81
commit
2aade5d2fe
2 changed files with 28 additions and 3 deletions
|
@ -32,6 +32,17 @@ const docTemplate = `{
|
|||
"User"
|
||||
],
|
||||
"summary": "Register a new user",
|
||||
"parameters": [
|
||||
{
|
||||
"description": "User to register",
|
||||
"name": "{string}",
|
||||
"in": "body",
|
||||
"required": true,
|
||||
"schema": {
|
||||
"$ref": "#/definitions/types.NewUser"
|
||||
}
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "User added",
|
||||
|
@ -55,6 +66,19 @@ const docTemplate = `{
|
|||
}
|
||||
}
|
||||
},
|
||||
"definitions": {
|
||||
"types.NewUser": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"password": {
|
||||
"type": "string"
|
||||
},
|
||||
"username": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"externalDocs": {
|
||||
"description": "OpenAPI",
|
||||
"url": "https://swagger.io/resources/open-api/"
|
||||
|
|
|
@ -16,9 +16,10 @@ import (
|
|||
// @Tags User
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Success 200 {string} string "User added"
|
||||
// @Failure 400 {string} string "Bad request"
|
||||
// @Failure 500 {string} string "Internal server error"
|
||||
// @Param {string} body types.NewUser true "User to register"
|
||||
// @Success 200 {string} string "User added"
|
||||
// @Failure 400 {string} string "Bad request"
|
||||
// @Failure 500 {string} string "Internal server error"
|
||||
// @Router /api/register [post]
|
||||
func (gs *GState) Register(c *fiber.Ctx) error {
|
||||
u := new(types.NewUser)
|
||||
|
|
Loading…
Reference in a new issue