-
-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
Given a parameter like this:
- name: foo
in: query
style: deepObject
schema:
type: object
properties:
min:
type: integer
format: int64
max:
type: integer
format: int64
The generated client code:
- Marshals the struct to JSON
- Parses the JSON back as a
map[string]any
, resulting in the numbers being converted tofloat64
-- already not great her I think - Constructs the query parameter values using
fmt.Sprintf("=%v, ...)
resulting in the integer parameter using floating point "e" notation if it's greater than ~ 100000 - The generated server then refuses to parse values like
1.23454678e9
as not valid string representations of integers
Item 2 happens in MarshalDeepObject
:
Line 75 in 35e8035
err = json.Unmarshal(buf, &i2) |
Item 3 happens just above in marshalDeepObject
:
Line 58 in 35e8035
prefix + fmt.Sprintf("=%v", t), |
I think that, if it has to go through the unfortunate JSON loop, it should use a json.Decoder
with UseNumber()
applied so that numbers are retained at full fidelity. This is what styleStruct
does for other styles:
Lines 235 to 236 in 35e8035
e := json.NewDecoder(bytes.NewReader(buf)) | |
e.UseNumber() |
Metadata
Metadata
Assignees
Labels
No labels