Skip to content

Commit

Permalink
Fix golang CI check error: json.Unmarshal is not checked
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaycean committed Jan 11, 2021
1 parent ce2c1e4 commit 0d191cb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions api/internal/handler/route_export/route_export.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ package route_export

import (
"encoding/json"
"reflect"
"regexp"
"strings"

"github.com/apisix/manager-api/internal/core/entity"
"github.com/apisix/manager-api/internal/core/store"
"github.com/apisix/manager-api/internal/handler"
"github.com/apisix/manager-api/internal/log"
"github.com/getkin/kin-openapi/openapi3"
"github.com/gin-gonic/gin"
"github.com/shiningrush/droplet"
"github.com/shiningrush/droplet/wrapper"
wgin "github.com/shiningrush/droplet/wrapper/gin"
"reflect"
"regexp"
"strings"
)

type Handler struct {
Expand Down Expand Up @@ -164,7 +166,10 @@ func routeToOpenApi3(routes []*entity.Route) *openapi3.Swagger {
param.In = "header"
requestValidation := &entity.RequestValidation{}
reqBytes, _ := json.Marshal(&v)
json.Unmarshal(reqBytes, requestValidation)
err := json.Unmarshal(reqBytes, requestValidation)
if err != nil {
log.Errorf("json marshal failed: %s", err)
}
for key1, value1 := range requestValidation.Properties.(map[string]interface{}) {
for _, arr := range requestValidation.Required {
if arr == key1 {
Expand All @@ -182,7 +187,10 @@ func routeToOpenApi3(routes []*entity.Route) *openapi3.Swagger {
m := map[string]*openapi3.MediaType{}
reqBytes, _ := json.Marshal(&v)
schema := &openapi3.Schema{}
json.Unmarshal(reqBytes, schema)
err := json.Unmarshal(reqBytes, schema)
if err != nil {
log.Errorf("json marshal failed: %s", err)
}
for _, va := range route.Vars.([]interface{}) {
compile := regexp.MustCompile("^http_.*")
match := compile.Match([]byte(va.([]interface{})[0].(string)))
Expand Down

0 comments on commit 0d191cb

Please sign in to comment.