@@ -3,7 +3,6 @@ import { getScalar } from '../getters';
3
3
import { ContextSpecs , ResolverValue , SchemaType } from '../types' ;
4
4
import { isReference } from '../utils' ;
5
5
import { resolveRef } from './ref' ;
6
- import { resolveObject } from './object' ;
7
6
8
7
export const resolveValue = ( {
9
8
schema,
@@ -20,22 +19,48 @@ export const resolveValue = ({
20
19
context ,
21
20
) ;
22
21
23
- const resolvedObject = resolveObject ( { schema : schemaObject , context } ) ;
24
-
25
- const { name, specKey, schemaName } = imports [ 0 ] ;
22
+ const resolvedImport = imports [ 0 ] ;
26
23
27
24
const importSpecKey =
28
- specKey ||
25
+ resolvedImport . specKey ||
29
26
( context . specKey !== context . target ? context . specKey : undefined ) ;
30
27
28
+ let hasReadonlyProps = false ;
29
+
30
+ const spec = context . specs [ context . specKey ] ;
31
+
32
+ // Avoid infinite loop
33
+ if (
34
+ name &&
35
+ ! name . startsWith ( resolvedImport . name ) &&
36
+ ! spec ?. components ?. schemas ?. [ name ]
37
+ ) {
38
+ const scalar = getScalar ( {
39
+ item : schemaObject ,
40
+ name : resolvedImport . name ,
41
+ context : {
42
+ ...context ,
43
+ specKey : importSpecKey || context . specKey ,
44
+ } ,
45
+ } ) ;
46
+
47
+ hasReadonlyProps = scalar . hasReadonlyProps ;
48
+ }
49
+
31
50
return {
32
- value : name ,
33
- imports : [ { name, specKey : importSpecKey , schemaName } ] ,
51
+ value : resolvedImport . name ,
52
+ imports : [
53
+ {
54
+ name : resolvedImport . name ,
55
+ specKey : importSpecKey ,
56
+ schemaName : resolvedImport . schemaName ,
57
+ } ,
58
+ ] ,
34
59
type : ( schemaObject ?. type as SchemaType ) || 'object' ,
35
60
schemas : [ ] ,
36
61
isEnum : ! ! schemaObject ?. enum ,
37
62
originalSchema : schemaObject ,
38
- hasReadonlyProps : resolvedObject . hasReadonlyProps ,
63
+ hasReadonlyProps,
39
64
isRef : true ,
40
65
} ;
41
66
}
1 commit comments
vercel[bot] commentedon Apr 12, 2023
Successfully deployed to the following URLs:
orval – ./
orval.vercel.app
orval.dev
www.orval.dev
orval-anymaniax.vercel.app
orval-git-master-anymaniax.vercel.app