Skip to content

Commit

Permalink
docs: add swagger docs for HTTP API
Browse files Browse the repository at this point in the history
  • Loading branch information
inchori committed Nov 27, 2023
1 parent 51ba3da commit 1b0eaf1
Show file tree
Hide file tree
Showing 13 changed files with 1,560 additions and 11 deletions.
511 changes: 511 additions & 0 deletions docs/docs.go

Large diffs are not rendered by default.

484 changes: 484 additions & 0 deletions docs/swagger.json

Large diffs are not rendered by default.

306 changes: 306 additions & 0 deletions docs/swagger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
definitions:
dto.LoginRequest:
properties:
email:
type: string
password:
type: string
type: object
dto.LoginResponse:
properties:
token:
type: string
type: object
dto.PostCreateRequest:
properties:
content:
type: string
title:
type: string
type: object
dto.PostResponse:
properties:
content:
type: string
id:
type: integer
title:
type: string
type: object
dto.PostUpdateRequest:
properties:
content:
type: string
title:
type: string
type: object
dto.PostsResponse:
properties:
count:
type: integer
posts:
items:
$ref: '#/definitions/dto.PostResponse'
type: array
type: object
dto.UserCreateRequest:
properties:
email:
type: string
name:
type: string
password:
type: string
type: object
dto.UserResponse:
properties:
email:
type: string
id:
type: integer
name:
type: string
type: object
dto.UserUpdateRequest:
properties:
name:
type: string
password:
type: string
type: object
info:
contact:
email: sic61695@gmail.com
name: Inchul Song
license:
name: Apache 2.0
url: http://www.apache.org/licenses/LICENSE-2.0.html
termsOfService: http://swagger.io/terms/
title: Simple Blog CRUD API
version: "1.0"
paths:
/v1/auth/login:
post:
consumes:
- application/json
parameters:
- description: Login
in: body
name: request
required: true
schema:
$ref: '#/definitions/dto.LoginRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.LoginResponse'
security: []
summary: User Login
tags:
- auth
/v1/posts:
post:
consumes:
- application/json
parameters:
- description: Create a Post Request Body
in: body
name: request
required: true
schema:
$ref: '#/definitions/dto.PostCreateRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.PostResponse'
summary: Create a Post
tags:
- Post
/v1/posts/{id}:
delete:
parameters:
- description: Post ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
security:
- Bearer: []
summary: Delete a post
tags:
- Post
get:
parameters:
- description: Post ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.PostResponse'
summary: Get a Post By ID
tags:
- Post
put:
consumes:
- application/json
parameters:
- description: Update Post Request Body
in: body
name: request
required: true
schema:
$ref: '#/definitions/dto.PostUpdateRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.PostResponse'
security:
- Bearer: []
summary: Update Post
tags:
- Post
/v1/posts/users/{userId}:
get:
parameters:
- description: User ID
in: path
name: userId
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.PostsResponse'
security:
- Bearer: []
summary: Get Posts By User ID
tags:
- Post
/v1/users/{id}:
delete:
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
responses:
"200":
description: OK
schema:
type: string
security:
- Bearer: []
summary: Delete a user
tags:
- User
get:
parameters:
- description: User ID
in: path
name: id
required: true
type: integer
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.UserResponse'
summary: Get a User By ID
tags:
- User
put:
consumes:
- application/json
parameters:
- description: Update User Request Body
in: body
name: request
required: true
schema:
$ref: '#/definitions/dto.UserUpdateRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.UserResponse'
security:
- Bearer: []
summary: Update a User
tags:
- User
/v1/users/{name}:
get:
parameters:
- description: Username
in: path
name: name
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.UserResponse'
summary: Get a User By Name
tags:
- User
/v1/users/signIn:
post:
consumes:
- application/json
parameters:
- description: Create a User Request Body
in: body
name: request
required: true
schema:
$ref: '#/definitions/dto.UserCreateRequest'
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/dto.UserResponse'
summary: Create a Post
tags:
- User
securityDefinitions:
Bearer:
description: Type "Bearer" followed by a space and JWT token.
in: header
name: Authorization
type: apiKey
swagger: "2.0"
11 changes: 11 additions & 0 deletions dto/auth_response.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package dto

type LoginResponse struct {
Token string `json:"token"`
}

func NewLoginResponse(token string) LoginResponse {
return LoginResponse{
Token: token,
}
}
17 changes: 15 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
module grpc_identity

go 1.20
go 1.21

toolchain go1.21.0

require (
entgo.io/ent v0.12.5
github.com/go-sql-driver/mysql v1.7.1
github.com/gofiber/contrib/jwt v1.0.7
github.com/gofiber/fiber/v2 v2.51.0
github.com/gofiber/swagger v0.1.14
github.com/golang-jwt/jwt/v5 v5.1.0
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1
github.com/grpc-ecosystem/grpc-gateway/v2 v2.18.1
github.com/sirupsen/logrus v1.9.3
github.com/spf13/viper v1.17.0
github.com/stretchr/testify v1.8.4
github.com/swaggo/swag v1.16.2
golang.org/x/crypto v0.15.0
google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17
google.golang.org/grpc v1.59.0
Expand All @@ -22,20 +26,27 @@ require (

require (
ariga.io/atlas v0.14.1-0.20230918065911-83ad451a4935 // indirect
github.com/KyleBanks/depth v1.2.1 // indirect
github.com/MicahParks/keyfunc/v2 v2.1.0 // indirect
github.com/agext/levenshtein v1.2.1 // indirect
github.com/andybalholm/brotli v1.0.6 // indirect
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-openapi/inflect v0.19.0 // indirect
github.com/go-openapi/jsonpointer v0.20.0 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/spec v0.20.9 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/hcl/v2 v2.13.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.3 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
Expand All @@ -52,17 +63,19 @@ require (
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.5.0 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/swaggo/files/v2 v2.0.0 // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.51.0 // indirect
github.com/valyala/tcplisten v1.0.0 // indirect
github.com/zclconf/go-cty v1.8.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.15.0 // indirect
google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
Expand Down
Loading

0 comments on commit 1b0eaf1

Please sign in to comment.