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 to float64 -- 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:
|
err = json.Unmarshal(buf, &i2) |
Item 3 happens just above in marshalDeepObject:
|
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:
|
e := json.NewDecoder(bytes.NewReader(buf)) |
|
e.UseNumber() |
Given a parameter like this:
The generated client code:
map[string]any, resulting in the numbers being converted tofloat64-- already not great her I thinkfmt.Sprintf("=%v, ...)resulting in the integer parameter using floating point "e" notation if it's greater than ~ 1000001.23454678e9as not valid string representations of integersItem 2 happens in
MarshalDeepObject:runtime/deepobject.go
Line 75 in 35e8035
Item 3 happens just above in
marshalDeepObject:runtime/deepobject.go
Line 58 in 35e8035
I think that, if it has to go through the unfortunate JSON loop, it should use a
json.DecoderwithUseNumber()applied so that numbers are retained at full fidelity. This is whatstyleStructdoes for other styles:runtime/styleparam.go
Lines 235 to 236 in 35e8035