Docs example

This commit is contained in:
Imbus 2024-03-18 19:59:14 +01:00
parent fe6942aa81
commit 2aade5d2fe
2 changed files with 28 additions and 3 deletions

View file

@ -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/"

View file

@ -16,6 +16,7 @@ import (
// @Tags User
// @Accept json
// @Produce json
// @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"