Skip to content

Commit

Permalink
docs: fix API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Jul 3, 2024
1 parent 9f56962 commit 5a9da7d
Show file tree
Hide file tree
Showing 5 changed files with 2,467 additions and 811 deletions.
2 changes: 1 addition & 1 deletion api/api.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Package api contains common constants for daemon and client.
package api

//go:generate go run github.com/go-swagger/go-swagger/cmd/swagger generate spec -o swagger.json --scan-models
//go:generate go run github.com/go-swagger/go-swagger/cmd/swagger generate spec -o swagger.json

// Common constants for daemon and client.
const (
Expand Down
36 changes: 18 additions & 18 deletions api/server/routes/syms/syms.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ func AddRoutes(rg *gin.RouterGroup, db db.Database) {
}
c.JSON(http.StatusOK, successResponse{Success: true})
})
// swagger:route GET /syms/{uuid} Syms getSymbols
// swagger:route GET /syms/{uuid}/{addr} Syms getSymbol
//
// Symbols
// Symbol
//
// Get symbols for a given uuid.
//
Expand All @@ -69,13 +69,19 @@ func AddRoutes(rg *gin.RouterGroup, db db.Database) {
// description: file UUID
// required: true
// type: string
// + name: addr
// in: path
// description: symbol address
// required: true
// type: integer
//
// Responses:
// 200: symsResponse
// 200: symResponse
// 500: genericError
rg.GET("/syms/:uuid", func(c *gin.Context) {
rg.GET("/syms/:uuid/:addr", func(c *gin.Context) {
uuid := c.Param("uuid")
syms, err := syms.Get(uuid, db)
addr := c.Param("addr")
sym, err := syms.GetForAddr(uuid, cast.ToUint64(addr), db)
if err != nil {
if errors.Is(err, model.ErrNotFound) {
c.AbortWithStatusJSON(http.StatusNotFound, types.GenericError{Error: err.Error()})
Expand All @@ -84,11 +90,11 @@ func AddRoutes(rg *gin.RouterGroup, db db.Database) {
c.AbortWithStatusJSON(http.StatusInternalServerError, types.GenericError{Error: err.Error()})
return
}
c.JSON(http.StatusOK, symsResponse(syms))
c.JSON(http.StatusOK, symResponse(sym))
})
// swagger:route GET /syms/{uuid}/{addr} Syms getSymbol
// swagger:route GET /syms/{uuid} Syms getSymbols
//
// Symbol
// Symbols
//
// Get symbols for a given uuid.
//
Expand All @@ -101,19 +107,13 @@ func AddRoutes(rg *gin.RouterGroup, db db.Database) {
// description: file UUID
// required: true
// type: string
// + name: addr
// in: path
// description: symbol address
// required: true
// type: integer
//
// Responses:
// 200: symResponse
// 200: symsResponse
// 500: genericError
rg.GET("/syms/:uuid/:addr", func(c *gin.Context) {
rg.GET("/syms/:uuid", func(c *gin.Context) {
uuid := c.Param("uuid")
addr := c.Param("addr")
sym, err := syms.GetForAddr(uuid, cast.ToUint64(addr), db)
syms, err := syms.Get(uuid, db)
if err != nil {
if errors.Is(err, model.ErrNotFound) {
c.AbortWithStatusJSON(http.StatusNotFound, types.GenericError{Error: err.Error()})
Expand All @@ -122,6 +122,6 @@ func AddRoutes(rg *gin.RouterGroup, db db.Database) {
c.AbortWithStatusJSON(http.StatusInternalServerError, types.GenericError{Error: err.Error()})
return
}
c.JSON(http.StatusOK, symResponse(sym))
c.JSON(http.StatusOK, symsResponse(syms))
})
}
Loading

0 comments on commit 5a9da7d

Please sign in to comment.