Skip to content

Commit

Permalink
[housekeeping] use dedicated strconv fns
Browse files Browse the repository at this point in the history
  • Loading branch information
lispyclouds committed Dec 19, 2024
1 parent 7222df8 commit a0db4d0
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"log/slog"
"os"
"regexp"
"strconv"

"github.com/pb33f/libopenapi"
v3 "github.com/pb33f/libopenapi/datamodel/high/v3"
Expand Down Expand Up @@ -179,13 +180,13 @@ func interpolatePath(cmd *cobra.Command, h *HandlerData) error {
value, _ = flags.GetString(param.Name)
case Integer:
v, _ := flags.GetInt(param.Name)
value = fmt.Sprintf("%d", v)
value = strconv.FormatInt(int64(v), 10)
case Number:
v, _ := flags.GetFloat64(param.Name)
value = fmt.Sprintf("%g", v)
value = strconv.FormatFloat(v, 'g', -1, 64)
case Boolean:
v, _ := flags.GetBool(param.Name)
value = fmt.Sprintf("%t", v)
value = strconv.FormatBool(v)
}

h.Path = pattern.ReplaceAllString(h.Path, value)
Expand Down

0 comments on commit a0db4d0

Please sign in to comment.