Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
booscaaa committed Feb 23, 2022
1 parent 8857cb3 commit e68b2ae
Show file tree
Hide file tree
Showing 4 changed files with 752 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ tmp
goapp

tmp

docs
326 changes: 326 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,326 @@
// Package docs GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag
package docs

import (
"bytes"
"encoding/json"
"strings"
"text/template"

"github.com/swaggo/swag"
)

var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"termsOfService": "todo-list-hateoas.herokuapp.com",
"contact": {
"name": "Vinícius Boscardin",
"email": "boscardinvinicius@gmail.com"
},
"license": {
"name": "Apache 2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0.html"
},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/item": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Fetch items by initials",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"item"
],
"summary": "Fetch items by initials",
"parameters": [
{
"type": "string",
"description": "vnb",
"name": "initials",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Item"
}
}
}
},
"post": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Create new item",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"item"
],
"summary": "Create new item",
"parameters": [
{
"description": "item",
"name": "company",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/domain.Item"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Item"
}
}
}
}
},
"/item/{id}": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Get item by id",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"item"
],
"summary": "Get item by id",
"parameters": [
{
"type": "integer",
"description": "1",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Item"
}
}
}
},
"put": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Update item by id",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"item"
],
"summary": "Update item by id",
"parameters": [
{
"description": "item",
"name": "item",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/domain.Item"
}
},
{
"type": "integer",
"description": "1",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Item"
}
}
}
},
"delete": {
"security": [
{
"ApiKeyAuth": []
}
],
"description": "Delete item by id",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"item"
],
"summary": "Delete item by id",
"parameters": [
{
"type": "integer",
"description": "1",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/domain.Item"
}
}
}
}
}
},
"definitions": {
"domain.Item": {
"type": "object",
"properties": {
"_links": {
"type": "array",
"items": {
"$ref": "#/definitions/domain.Link"
}
},
"date": {
"type": "string",
"example": "2021-02-02"
},
"description": {
"type": "string",
"example": "Descrição da tarefa 1"
},
"initials": {
"type": "string",
"maxLength": 3,
"example": "vin"
},
"name": {
"type": "string",
"example": "Tarefa 1"
}
}
},
"domain.Link": {
"type": "object",
"properties": {
"doc": {
"type": "string",
"example": "http(s)://\u003cDOMAIN_OR_IP\u003e/doc/index.html"
},
"href": {
"type": "string",
"example": "http(s)://\u003cDOMAIN_OR_IP\u003e/item/{id}"
},
"method": {
"type": "string",
"example": "GET"
}
}
}
}
}`

type swaggerInfo struct {
Version string
Host string
BasePath string
Schemes []string
Title string
Description string
}

// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = swaggerInfo{
Version: "2021.12.5.0",
Host: "todo-list-hateoas.herokuapp.com",
BasePath: "/",
Schemes: []string{},
Title: "Clean architecture and Level 3 of REST",
Description: "An application of studies on the implementation of clean architecture with golang with a plus of REST level 3 implementations",
}

type s struct{}

func (s *s) ReadDoc() string {
sInfo := SwaggerInfo
sInfo.Description = strings.Replace(sInfo.Description, "\n", "\\n", -1)

t, err := template.New("swagger_info").Funcs(template.FuncMap{
"marshal": func(v interface{}) string {
a, _ := json.Marshal(v)
return string(a)
},
"escape": func(v interface{}) string {
// escape tabs
str := strings.Replace(v.(string), "\t", "\\t", -1)
// replace " with \", and if that results in \\", replace that with \\\"
str = strings.Replace(str, "\"", "\\\"", -1)
return strings.Replace(str, "\\\\\"", "\\\\\\\"", -1)
},
}).Parse(doc)
if err != nil {
return doc
}

var tpl bytes.Buffer
if err := t.Execute(&tpl, sInfo); err != nil {
return doc
}

return tpl.String()
}

func init() {
swag.Register(swag.Name, &s{})
}
Loading

0 comments on commit e68b2ae

Please sign in to comment.