Skip to content

Commit

Permalink
Merge pull request #86 from vortex14/swagger
Browse files Browse the repository at this point in the history
change base response
  • Loading branch information
vortex14 authored Sep 5, 2023
2 parents a9d2094 + 81d01d9 commit 8b855e7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ build
tmp
main/ci/agent/agent
main
build-errors.log
build-errors.log
.air.toml
3 changes: 1 addition & 2 deletions elements/forms/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ type TyphoonServer struct {
}

type ErrorResponse struct {
Message string `json:"message"`
Status bool `json:"status"`
Error string `json:"error"`
}

func (s *TyphoonServer) GetDocs() []byte {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func meHandler(ctx *gin.Context, logger interfaces.LoggerInterface) {
//
//println(fmt.Sprintf("%+v; %+v", m, ctx.Params, ctx.Quer))

ctx.JSON(400, &forms.ErrorResponse{Message: err.Error()})
ctx.JSON(400, &forms.ErrorResponse{Error: err.Error()})
return
}

Expand Down
6 changes: 3 additions & 3 deletions extensions/servers/gin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (s *TyphoonGinServer) onRequestHandler(ginCtx *Gin.Context) {

if action == nil {
s.LOG.Error(Errors.ActionPathNotFound.Error())
ginCtx.JSON(404, forms.ErrorResponse{Message: "not found", Status: false})
ginCtx.JSON(404, forms.ErrorResponse{Error: "not found"})
return
}

Expand All @@ -82,15 +82,15 @@ func (s *TyphoonGinServer) onRequestHandler(ginCtx *Gin.Context) {
paramsQuery := action.GetParams()
if paramsQuery != nil {
if err := ginCtx.BindQuery(paramsQuery); err != nil {
ginCtx.JSON(422, forms.ErrorResponse{Message: "unavailable query string", Status: false})
ginCtx.JSON(422, forms.ErrorResponse{Error: "unavailable query string"})
return
}
}

if action.IsValidRequestBody() {
if err := ginCtx.ShouldBindJSON(action.GetRequestModel()); err != nil {
s.LOG.Error(Errors.ActionErrRequestModel.Error())
ginCtx.JSON(422, forms.ErrorResponse{Message: "unprocessable entity", Status: false})
ginCtx.JSON(422, forms.ErrorResponse{Error: "unprocessable entity"})
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion main/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

func main() {
logrus.Info("starting discovery local server ...")
_ = discovery.Constructor("localhost", 12735, "http",
_ = discovery.Constructor("localhost:12735", 12735, "http",
nil,
nil,
nil).Run()
Expand Down
2 changes: 1 addition & 1 deletion main/gin/validate_headers/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type HeaderModel struct {

var TestAction = &gin.Action{
Action: &forms.Action{
Params: &MeParams{},
//Params: &MeParams{},
Headers: forms.HeaderRequestModel{
ErrorModel: ErrorResponseHeaderModel{
Message: "header error",
Expand Down

0 comments on commit 8b855e7

Please sign in to comment.