Skip to content

Commit

Permalink
Merge pull request #104 from isaqueveras/swag-docs
Browse files Browse the repository at this point in the history
📝 Documentation using swagger
  • Loading branch information
isaqueveras committed Feb 11, 2023
2 parents d968b94 + ef3c3d1 commit 8476ddc
Show file tree
Hide file tree
Showing 16 changed files with 827 additions and 188 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*.dll
*.so
*.dylib
power-sso

# Test binary, built with `go test -c`
*.test
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ migrate-down:

lint:
golangci-lint run ./...

swag:
swag init -g main.go --output docs
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ $ make local
# Run the migrations
$ make migrate-up

# Generate documentation
$ make swag

# Run the application in development mode
$ go run main.go

Expand All @@ -62,9 +65,10 @@ $ npm run start
```

```bash
- The frontend will open on the port:3000 # access http://localhost:3000
- The backend will open on the port:5000 # access http://localhost:5000
- The mailcatcher will open on the port:1080 # access http://localhost:1080
- The frontend will open on the port:3000 # access http://localhost:3000
- The backend will open on the port:5000 # access http://localhost:5000
- The mailcatcher will open on the port:1080 # access http://localhost:1080
- The documentation will open on the port:5000: # access http://localhost:5000/swagger/index.html
```
## 😯 How to contribute to the project

Expand Down
254 changes: 254 additions & 0 deletions docs/docs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,254 @@
// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
// This file was generated by swaggo/swag at
// 2023-02-11 16:58:20.668754441 -0300 -03 m=+0.019358123

package docs

import (
"bytes"
"encoding/json"

"github.com/alecthomas/template"
"github.com/swaggo/swag"
)

var doc = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "This is PowerSSO app server.",
"title": "Documentation PowerSSO",
"contact": {
"name": "PowerSSO",
"url": "https://github.com/isaqueveras/power-sso/issues"
},
"license": {
"name": "MIT license",
"url": "https://github.com/isaqueveras/power-sso/blob/main/LICENSE"
},
"version": "1.0.0"
},
"host": "localhost:5000",
"basePath": "/",
"paths": {
"/v1/auth/activation/{token}": {
"post": {
"description": "Route to activate the user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Http/Auth"
],
"summary": "Activate the user",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"$ref": "#/definitions/utils.NoContent"
}
}
}
}
},
"/v1/auth/login": {
"post": {
"description": "Route to login a user account into the system",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Http/Auth"
],
"summary": "User login",
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object",
"$ref": "#/definitions/auth.SessionResponse"
}
}
}
}
},
"/v1/auth/logout": {
"delete": {
"description": "Route to logout a user account into the system",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Http/Auth"
],
"summary": "User logout",
"responses": {
"204": {
"description": "No Content",
"schema": {
"type": "object",
"$ref": "#/definitions/utils.NoContent"
}
}
}
}
},
"/v1/auth/register": {
"post": {
"description": "Register a user",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Http/Auth"
],
"summary": "Register a user",
"responses": {
"201": {
"description": "Created",
"schema": {
"type": "object",
"$ref": "#/definitions/utils.NoContent"
}
}
}
}
},
"/v1/project/create": {
"post": {
"description": "Register a project including several users to the project",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"Http/Project"
],
"summary": "Register a projet",
"responses": {
"201": {
"description": "Created",
"schema": {
"type": "object",
"$ref": "#/definitions/utils.NoContent"
}
}
}
}
}
},
"definitions": {
"auth.SessionResponse": {
"type": "object",
"properties": {
"about": {
"type": "string"
},
"avatar_url": {
"type": "string"
},
"created_at": {
"type": "string"
},
"email": {
"type": "string"
},
"expires_at": {
"type": "string"
},
"first_name": {
"type": "string"
},
"jwt_token": {
"type": "string"
},
"last_name": {
"type": "string"
},
"level": {
"type": "string"
},
"phone_number": {
"type": "string"
},
"raw_data": {
"type": "object"
},
"roles": {
"type": "array",
"items": {
"type": "string"
}
},
"session_id": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"utils.NoContent": {
"type": "object"
}
},
"securityDefinitions": {
"ApiKeyAuth": {
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}`

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{ Schemes: []string{}}

type s struct{}

func (s *s) ReadDoc() string {
t, err := template.New("swagger_info").Funcs(template.FuncMap{
"marshal": func(v interface {}) string {
a, _ := json.Marshal(v)
return string(a)
},
}).Parse(doc)
if err != nil {
return doc
}

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

return tpl.String()
}

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

1 comment on commit 8476ddc

@vercel
Copy link

@vercel vercel bot commented on 8476ddc Feb 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

power-sso – ./

power-sso-git-main-isaqueveras.vercel.app
power-sso-isaqueveras.vercel.app
power-sso.vercel.app

Please sign in to comment.