File tree 5 files changed +64
-4
lines changed
5 files changed +64
-4
lines changed Original file line number Diff line number Diff line change @@ -307,11 +307,25 @@ const deference = (
307
307
schema : SchemaObject | ReferenceObject ,
308
308
context : ContextSpecs ,
309
309
) : SchemaObject => {
310
- const { schema : resolvedSchema } = resolveRef < SchemaObject > ( schema , context ) ;
310
+ const refName = '$ref' in schema ? schema . $ref : undefined ;
311
+ if ( refName && context . parents ?. includes ( refName ) ) {
312
+ return { } ;
313
+ }
311
314
312
- return Object . entries ( resolvedSchema ) . reduce ( ( acc , [ key , value ] ) => {
313
- acc [ key ] = deferenceScalar ( value , context ) ;
315
+ const childContext : ContextSpecs = {
316
+ ...context ,
317
+ ...( refName
318
+ ? { parents : [ ...( context . parents || [ ] ) , refName ] }
319
+ : undefined ) ,
320
+ } ;
314
321
322
+ const { schema : resolvedSchema } = resolveRef < SchemaObject > (
323
+ schema ,
324
+ childContext ,
325
+ ) ;
326
+
327
+ return Object . entries ( resolvedSchema ) . reduce ( ( acc , [ key , value ] ) => {
328
+ acc [ key ] = deferenceScalar ( value , childContext ) ;
315
329
return acc ;
316
330
} , { } as any ) ;
317
331
} ;
Original file line number Diff line number Diff line change
1
+ import { defineConfig } from 'orval' ;
2
+
3
+ export default defineConfig ( {
4
+ basic : {
5
+ output : {
6
+ target : '../generated/zod' ,
7
+ client : 'zod' ,
8
+ } ,
9
+ input : {
10
+ target : '../specifications/circular.yaml' ,
11
+ } ,
12
+ } ,
13
+ } ) ;
Original file line number Diff line number Diff line change 15
15
"generate:vue-query" : " yarn orval --config ./configs/vue-query.config.ts" ,
16
16
"generate:swr" : " yarn orval --config ./configs/swr.config.ts" ,
17
17
"generate:multi-file" : " yarn orval --config ./configs/multi-file.config.ts" ,
18
+ "generate:zod" : " yarn orval --config ./configs/zod.config.ts" ,
18
19
"build" : " tsc"
19
20
},
20
21
"author" : " Victor Bury" ,
33
34
"axios" : " ^0.26.1" ,
34
35
"msw" : " ^0.35.0" ,
35
36
"swr" : " ^2.1.2" ,
36
- "vue" : " 3.2.47"
37
+ "vue" : " 3.2.47" ,
38
+ "zod" : " ^3.21.4"
37
39
}
38
40
}
Original file line number Diff line number Diff line change
1
+ openapi : 3.0.0
2
+ info :
3
+ title : Circular references
4
+ version : 0.0.0
5
+ paths :
6
+ /example :
7
+ get :
8
+ summary : Example
9
+ responses :
10
+ ' 200 ' :
11
+ description : ' Example'
12
+ content :
13
+ application/json :
14
+ schema :
15
+ $ref : ' #/components/schemas/Node'
16
+ components :
17
+ schemas :
18
+ Node :
19
+ type : object
20
+ properties :
21
+ id :
22
+ type : integer
23
+ name :
24
+ type : string
25
+ child :
26
+ $ref : ' #/components/schemas/Node'
Original file line number Diff line number Diff line change @@ -1373,3 +1373,8 @@ yargs@^17.0.1:
1373
1373
string-width "^4.2.0"
1374
1374
y18n "^5.0.5"
1375
1375
yargs-parser "^20.2.2"
1376
+
1377
+ zod@^3.21.4 :
1378
+ version "3.21.4"
1379
+ resolved "https://registry.yarnpkg.com/zod/-/zod-3.21.4.tgz#10882231d992519f0a10b5dd58a38c9dabbb64db"
1380
+ integrity sha512-m46AKbrzKVzOzs/DZgVnG5H55N1sv1M8qZU3A8RIKbs3mrACDNeIOeilDymVb2HdmP8uwshOCF4uJ8uM9rCqJw==
You can’t perform that action at this time.
1 commit comments
vercel[bot] commentedon Aug 16, 2023
Successfully deployed to the following URLs:
orval – ./
orval.vercel.app
orval-anymaniax.vercel.app
orval-git-master-anymaniax.vercel.app
orval.dev
www.orval.dev