Summary
nodeToRaw decodes a YAML node into any and re-marshals it as JSON. yaml.v3 decodes out-of-int64 integers and all decimals into float64, so every path that promises verbatim preservation silently rounds numbers:
x-* extensions (extensionsFrom),
- oneOf/anyOf sibling preservation,
- the §4.7 carve-out (
not/if-then-else/dependentSchemas/contains/unevaluated*),
- tuple items-after-prefix.
This defeats exactly the documented "preserved verbatim in Extensions" guarantee. #23 fixed the Value/BigVal channel; the raw-preservation channel has the same class of bug.
Reproduction
openapi: 3.1.0
info: {title: t, version: '1'}
paths: {}
components:
schemas:
S:
type: object
x-big: 12345678901234567890123
x-frac: 1.000000000000000000001
Result: Extensions["openapi:x-big"] == 1.2345678901234568e+22, Extensions["openapi:x-frac"] == 1.
Root cause
compilers/openapi/schema.go:866-881 — node.Decode(&any) + json.Marshal instead of a number-preserving conversion.
Expected
Raw preservation must be number-safe: either serialize from the yaml.Node tree directly (rendering scalar numbers from their source text) or decode with a number-preserving representation (e.g. json.Number semantics). "Preserved verbatim" should mean byte-faithful for every scalar the source can express.
Summary
nodeToRawdecodes a YAML node intoanyand re-marshals it as JSON. yaml.v3 decodes out-of-int64 integers and all decimals intofloat64, so every path that promises verbatim preservation silently rounds numbers:x-*extensions (extensionsFrom),not/if-then-else/dependentSchemas/contains/unevaluated*),This defeats exactly the documented "preserved verbatim in Extensions" guarantee. #23 fixed the Value/BigVal channel; the raw-preservation channel has the same class of bug.
Reproduction
Result:
Extensions["openapi:x-big"] == 1.2345678901234568e+22,Extensions["openapi:x-frac"] == 1.Root cause
compilers/openapi/schema.go:866-881—node.Decode(&any)+json.Marshalinstead of a number-preserving conversion.Expected
Raw preservation must be number-safe: either serialize from the
yaml.Nodetree directly (rendering scalar numbers from their source text) or decode with a number-preserving representation (e.g.json.Numbersemantics). "Preserved verbatim" should mean byte-faithful for every scalar the source can express.