File tree 3 files changed +148
-1
lines changed
packages/mock/src/faker/getters
3 files changed +148
-1
lines changed Original file line number Diff line number Diff line change @@ -232,7 +232,9 @@ export const getMockScalar = ({
232
232
] ;
233
233
}
234
234
235
- value = `faker.helpers.arrayElement(${ enumValue } )` ;
235
+ value = item . path ?. endsWith ( '[]' )
236
+ ? `faker.helpers.arrayElements(${ enumValue } )`
237
+ : `faker.helpers.arrayElement(${ enumValue } )` ;
236
238
}
237
239
238
240
return {
Original file line number Diff line number Diff line change @@ -156,4 +156,15 @@ export default defineConfig({
156
156
target : '../specifications/arrays.yaml' ,
157
157
} ,
158
158
} ,
159
+ enums : {
160
+ output : {
161
+ target : '../generated/swr/enums/endpoints.ts' ,
162
+ schemas : '../generated/swr/enums/model' ,
163
+ client : 'swr' ,
164
+ mock : true ,
165
+ } ,
166
+ input : {
167
+ target : '../specifications/enums.yaml' ,
168
+ } ,
169
+ } ,
159
170
} ) ;
Original file line number Diff line number Diff line change
1
+ openapi : 3.0.3
2
+ info :
3
+ title : Arrays
4
+ version : 1.0.0
5
+ paths :
6
+ /api/cat :
7
+ get :
8
+ summary : sample cat
9
+ responses :
10
+ ' 200 ' :
11
+ description : OK
12
+ content :
13
+ application/json :
14
+ schema :
15
+ $ref : ' #/components/schemas/Cat'
16
+ /api/required-cat :
17
+ get :
18
+ summary : sample required cat
19
+ responses :
20
+ ' 200 ' :
21
+ description : OK
22
+ content :
23
+ application/json :
24
+ schema :
25
+ $ref : ' #/components/schemas/RequiredCat'
26
+ /api/dog :
27
+ get :
28
+ summary : sample dog
29
+ responses :
30
+ ' 200 ' :
31
+ description : OK
32
+ content :
33
+ application/json :
34
+ schema :
35
+ $ref : ' #/components/schemas/Dog'
36
+ /api/required-dog :
37
+ get :
38
+ summary : sample required dog
39
+ responses :
40
+ ' 200 ' :
41
+ description : OK
42
+ content :
43
+ application/json :
44
+ schema :
45
+ $ref : ' #/components/schemas/RequiredDog'
46
+ /api/duck :
47
+ get :
48
+ summary : sample duck
49
+ responses :
50
+ ' 200 ' :
51
+ description : OK
52
+ content :
53
+ application/json :
54
+ schema :
55
+ $ref : ' #/components/schemas/Duck'
56
+ components :
57
+ schemas :
58
+ Siamese :
59
+ type : object
60
+ properties :
61
+ colours :
62
+ type : array
63
+ items :
64
+ type : string
65
+ enum :
66
+ - BLACK
67
+ - BROWN
68
+ - WHITE
69
+ - GREY
70
+ RequiredSiamese :
71
+ type : object
72
+ required : ['colours']
73
+ properties :
74
+ colours :
75
+ type : array
76
+ items :
77
+ type : string
78
+ enum :
79
+ - BLACK
80
+ - BROWN
81
+ - WHITE
82
+ - GREY
83
+ Cat :
84
+ type : object
85
+ properties :
86
+ petsRequested :
87
+ type : array
88
+ items :
89
+ $ref : ' #/components/schemas/Siamese'
90
+ RequiredCat :
91
+ type : object
92
+ properties :
93
+ petsRequested :
94
+ type : array
95
+ items :
96
+ $ref : ' #/components/schemas/RequiredSiamese'
97
+ Bulldog :
98
+ type : object
99
+ properties :
100
+ colour :
101
+ type : string
102
+ enum :
103
+ - BLACK
104
+ - BROWN
105
+ RequiredBulldog :
106
+ type : object
107
+ required : ['colour']
108
+ properties :
109
+ colour :
110
+ type : string
111
+ enum :
112
+ - BLACK
113
+ - BROWN
114
+ Dog :
115
+ type : object
116
+ properties :
117
+ petsRequested :
118
+ type : array
119
+ items :
120
+ $ref : ' #/components/schemas/Bulldog'
121
+ RequiredDog :
122
+ type : object
123
+ properties :
124
+ petsRequested :
125
+ type : array
126
+ items :
127
+ $ref : ' #/components/schemas/RequiredBulldog'
128
+ Duck :
129
+ type : object
130
+ properties :
131
+ petsRequested :
132
+ type : array
133
+ items :
134
+ type : string
You can’t perform that action at this time.
0 commit comments