What version of ogen are you using?
v1.20.1
Can this issue be reproduced with the latest version?
Yes
What did you do?
Define sum path parameter with that schema:
oneOf:
- type: integer
- type: string
Try to decode in second, non integer variant.
What did you expect to see?
String variant value.
What did you see instead?
io.EOF
Explanation
Generated code will try to decode each variant sequentially, calling DecodeValue each time.
For path parameters decoder will be a pointer of uri.PathDecoder.
Its DecodeValue method calls cursor.readAll, which have that code:
func (c *cursor) readAll() (string, error) {
if c.pos == len(c.src) {
return "", io.EOF
}
defer func() { c.pos = len(c.src) }()
return c.src[c.pos:], nil
}
On the first call, parameter value will be consumed and pos moves after it.
Subsequent calls results in returning io.EOF.
What version of ogen are you using?
v1.20.1
Can this issue be reproduced with the latest version?
Yes
What did you do?
Define sum path parameter with that schema:
Try to decode in second, non integer variant.
What did you expect to see?
String variant value.
What did you see instead?
io.EOFExplanation
Generated code will try to decode each variant sequentially, calling
DecodeValueeach time.For path parameters decoder will be a pointer of
uri.PathDecoder.Its
DecodeValuemethod callscursor.readAll, which have that code:On the first call, parameter value will be consumed and pos moves after it.
Subsequent calls results in returning
io.EOF.