@@ -22,7 +22,7 @@ import {
2222 ResolveOptions ,
2323 RichReference ,
2424} from './types'
25- import { resolveSpec , SPEC_TYPE_GRAPH_API , SPEC_TYPE_OPEN_API_31 } from './spec-type'
25+ import { resolveSpec } from './spec-type'
2626import { ErrorMessage } from './errors'
2727import { createCycledJsoHandlerHook } from './cycle-jso'
2828import { JSON_SCHEMA_PROPERTY_ALL_OF , JSON_SCHEMA_PROPERTY_REF } from './rules/jsonschema.const'
@@ -60,12 +60,14 @@ const IMPOSSIBLE_ORIGIN_PARENT: ChainItem = { parent: undefined, value: 'ERROR!!
6060
6161export const defineOriginsAndResolveRef = ( value : unknown , options ?: ResolveOptions ) => {
6262 const spec = resolveSpec ( value )
63+ const source = options ?. source ?? value
64+
6365 const internalOptions = {
6466 resolveRef : DEFAULT_OPTION_RESOLVE_REF ,
6567 originsAlreadyDefined : ! ! options ?. originsFlag ,
6668 ...options ,
6769 originsFlag : options ?. originsAlreadyDefined ? undefined : options ?. originsFlag ,
68- source : options ?. source ?? value ,
70+ source,
6971 ignoreSymbols : new Set ( [
7072 ...( options ?. originsFlag ? [ options . originsFlag ] : [ ] ) ,
7173 ...( options ?. inlineRefsFlag ? [ options . inlineRefsFlag ] : [ ] ) ,
@@ -140,7 +142,13 @@ export const deDefineOriginsAndResolvedRefSymbols = (value: unknown, options?: R
140142const createDefineOriginsAndResolveRefHook : ( rootJso : unknown , options : InternalResolveOptions , cycleJsoHook : SyncCloneHook < DefineOriginsAndResolveRefState > ) => DefineOriginsAndResolveRefSyncCloneHook = ( rootJso , options , cycleJsoHook ) => {
141143 const cyclingGuard : Set < unknown > = new Set ( )
142144 const syntheticTitleCache : Map < string , Record < PropertyKey , unknown > > = new Map ( )
143- const defineOriginsAndResolveRefHook : DefineOriginsAndResolveRefSyncCloneHook = ( { key, value, state, path, rules, } ) => {
145+ const defineOriginsAndResolveRefHook : DefineOriginsAndResolveRefSyncCloneHook = ( {
146+ key,
147+ value,
148+ state,
149+ path,
150+ rules,
151+ } ) => {
144152 if ( state . ignoreTreeUnderSymbols ) {
145153 return { value }
146154 }
@@ -189,7 +197,7 @@ const createDefineOriginsAndResolveRefHook: (rootJso: unknown, options: Internal
189197 }
190198 const reference = parseRef ( $ref )
191199
192- const processWrapRefWithAllOfReference = ( resolvedRefWithSibling : ResolvedRefWithSiblings ) => {
200+ const processWrapRefWithAllOfReference = ( resolvedRefWithSibling : ResolvedRefWithSiblings ) => {
193201 const {
194202 refValue,
195203 origin,
@@ -282,9 +290,9 @@ const createDefineOriginsAndResolveRefHook: (rootJso: unknown, options: Internal
282290 }
283291 }
284292
285- const processResolvedReference = ( resolvedRefWithSibling : ResolvedRefWithSiblings ) => {
293+ const processResolvedReference = ( resolvedRefWithSibling : ResolvedRefWithSiblings ) => {
286294 if ( hasChildrenOrigins ( resolvedRefWithSibling ) ) {
287- return processReferenceWithChildren ( resolvedRefWithSibling )
295+ return processReferenceWithChildren ( resolvedRefWithSibling )
288296 }
289297 return processWrapRefWithAllOfReference ( resolvedRefWithSibling )
290298 }
0 commit comments