Skip to content

Commit

Permalink
chore: improve swagger path
Browse files Browse the repository at this point in the history
  • Loading branch information
xjasonlyu committed Dec 6, 2023
1 parent 9b7bf2f commit dcd9ad7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
13 changes: 10 additions & 3 deletions game-service/api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,23 @@ func New(app *game.App) *gin.Engine {
// index page
r.GET("/", getIndex())

docs.SwaggerInfo.BasePath = "/game"
r.GET("/game-swagger/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))

gm := r.Group("/game")
{
gm.POST("/start", handleGameStart(app))
gm.POST("/stop", handleGameStop(app))
gm.POST("/action", handleGameAction(app))
}

docs.SwaggerInfo.BasePath = "/game"

sw := r.Group("/game-swagger")
{
sw.GET("/index.html", func(c *gin.Context) {
c.Redirect(http.StatusTemporaryRedirect, "/game-swagger/swagger-ui/index.html")
})
sw.GET("/swagger-ui/*any", ginSwagger.WrapHandler(swaggerfiles.Handler))
}

return r
}

Expand Down
9 changes: 9 additions & 0 deletions game-service/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@ const docTemplate = `{
"schema": {
"type": "string"
}
},
{
"description": "player current location",
"name": "location",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.PointDTO"
}
}
],
"responses": {
Expand Down
9 changes: 9 additions & 0 deletions game-service/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,15 @@
"schema": {
"type": "string"
}
},
{
"description": "player current location",
"name": "location",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.PointDTO"
}
}
],
"responses": {
Expand Down
6 changes: 6 additions & 0 deletions game-service/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ paths:
required: true
schema:
type: string
- description: player current location
in: body
name: location
required: true
schema:
$ref: '#/definitions/dto.PointDTO'
produces:
- application/json
responses:
Expand Down

0 comments on commit dcd9ad7

Please sign in to comment.