Problem
getRefInfo in packages/core/src/getters/ref.ts decodes JSON Pointer path segments for $ref values, but it only handles the / escape (~1). It does not decode the tilde escape (~0).
Per RFC 6901 section 3, JSON Pointer reference tokens must decode both escape sequences:
~1 becomes /
~0 becomes ~
The replacement order matters. ~1 should be decoded before ~0 so escaped tokens are not decoded incorrectly.
Current behavior
A schema named My~Type must be referenced as:
{ "$ref": "#/components/schemas/My~0Type" }
Today, Orval leaves the escaped tilde in the decoded path segment. That means #/components/schemas/My~0Type is treated as if the schema name were My~0Type, instead of My~Type.
This can cause refs to resolve to the wrong name or fail to resolve when a component key contains a literal ~.
Expected behavior
getRefInfo should decode JSON Pointer escape sequences according to RFC 6901:
part.replaceAll('~1', '/').replaceAll('~0', '~')
For example:
| Ref |
Decoded schema name |
#/components/schemas/My~0Type |
My~Type |
#/components/schemas/Path~1To~0Thing |
Path/To~Thing |
Impact
This is a general $ref correctness issue. Specs with component names containing a literal tilde (~) can generate incorrect names or fail to resolve refs correctly.
The fix should only affect refs that contain ~0; existing refs without tilde escapes should continue to behave the same.
Suggested scope
Files likely involved:
packages/core/src/getters/ref.ts
packages/core/src/getters/ref.test.ts
packages/core/src/resolvers/ref.test.ts
Suggested test coverage:
getRefInfo decodes #/components/schemas/My~0Type to My~Type
getRefInfo decodes a path segment containing both ~1 and ~0
resolveRef resolves a schema whose component key contains a literal ~
Problem
getRefInfoinpackages/core/src/getters/ref.tsdecodes JSON Pointer path segments for$refvalues, but it only handles the/escape (~1). It does not decode the tilde escape (~0).Per RFC 6901 section 3, JSON Pointer reference tokens must decode both escape sequences:
~1becomes/~0becomes~The replacement order matters.
~1should be decoded before~0so escaped tokens are not decoded incorrectly.Current behavior
A schema named
My~Typemust be referenced as:{ "$ref": "#/components/schemas/My~0Type" }Today, Orval leaves the escaped tilde in the decoded path segment. That means
#/components/schemas/My~0Typeis treated as if the schema name wereMy~0Type, instead ofMy~Type.This can cause refs to resolve to the wrong name or fail to resolve when a component key contains a literal
~.Expected behavior
getRefInfoshould decode JSON Pointer escape sequences according to RFC 6901:For example:
#/components/schemas/My~0TypeMy~Type#/components/schemas/Path~1To~0ThingPath/To~ThingImpact
This is a general
$refcorrectness issue. Specs with component names containing a literal tilde (~) can generate incorrect names or fail to resolve refs correctly.The fix should only affect refs that contain
~0; existing refs without tilde escapes should continue to behave the same.Suggested scope
Files likely involved:
packages/core/src/getters/ref.tspackages/core/src/getters/ref.test.tspackages/core/src/resolvers/ref.test.tsSuggested test coverage:
getRefInfodecodes#/components/schemas/My~0TypetoMy~TypegetRefInfodecodes a path segment containing both~1and~0resolveRefresolves a schema whose component key contains a literal~