MCPcopy Index your code
hub / github.com/massCodeIO/massCode / resolveRef

Function resolveRef

src/main/http/import/openapi.ts:87–103  ·  view source on GitHub ↗
(root: UnknownRecord, value: unknown)

Source from the content-addressed store, hash-verified

85}
86
87function resolveRef(root: UnknownRecord, value: unknown): unknown {
88 if (!isRecord(value) || typeof value.$ref !== 'string')
89 return value
90 if (!value.$ref.startsWith('#/'))
91 return value
92
93 return (
94 value.$ref
95 .slice(2)
96 .split('/')
97 .reduce<unknown>((current, segment) => {
98 if (!isRecord(current))
99 return undefined
100 return current[segment.replace(/~1/g, '/').replace(/~0/g, '~')]
101 }, root) ?? value
102 )
103}
104
105function openApiTemplateToVariables(value: string): string {
106 return value

Callers 2

parseParametersFunction · 0.85
parseRequestBodyFunction · 0.85

Calls 1

isRecordFunction · 0.70

Tested by

no test coverage detected