File tree 4 files changed +53
-1
lines changed
packages/core/src/getters
4 files changed +53
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { keyword } from 'esutils' ;
2
+ import type { ValueIteratee } from 'lodash' ;
2
3
import uniqBy from 'lodash.uniqby' ;
4
+
3
5
import {
4
6
MediaTypeObject ,
5
7
ReferenceObject ,
@@ -48,6 +50,7 @@ export const getResReqTypes = (
48
50
name : string ,
49
51
context : ContextSpecs ,
50
52
defaultType = 'unknown' ,
53
+ uniqueKey : ValueIteratee < ResReqTypesValue > = 'value' ,
51
54
) : ResReqTypesValue [ ] => {
52
55
const typesArray = responsesOrRequests
53
56
. filter ( ( [ _ , res ] ) => Boolean ( res ) )
@@ -213,7 +216,7 @@ export const getResReqTypes = (
213
216
214
217
return uniqBy (
215
218
typesArray . flatMap ( ( it ) => it ) ,
216
- 'value' ,
219
+ uniqueKey ,
217
220
) ;
218
221
} ;
219
222
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ export const getResponse = ({
37
37
operationName ,
38
38
context ,
39
39
'void' ,
40
+ ( type ) => type . key . startsWith ( '2' ) + type . value ,
40
41
) ;
41
42
42
43
const filteredTypes = contentType
Original file line number Diff line number Diff line change @@ -167,4 +167,15 @@ export default defineConfig({
167
167
target : '../specifications/enums.yaml' ,
168
168
} ,
169
169
} ,
170
+ errors : {
171
+ output : {
172
+ target : '../generated/swr/errors/endpoints.ts' ,
173
+ schemas : '../generated/swr/errors/model' ,
174
+ client : 'swr' ,
175
+ mock : true ,
176
+ } ,
177
+ input : {
178
+ target : '../specifications/errors.yaml' ,
179
+ } ,
180
+ } ,
170
181
} ) ;
Original file line number Diff line number Diff line change
1
+ openapi : ' 3.0.0'
2
+ info :
3
+ version : 1.0.0
4
+ title : Swagger Errors
5
+ license :
6
+ name : MIT
7
+ paths :
8
+ /error :
9
+ get :
10
+ summary : Get an Error Item
11
+ operationId : createItems
12
+ responses :
13
+ ' 200 ' :
14
+ description : Success
15
+ content :
16
+ application/json :
17
+ schema :
18
+ $ref : ' #/components/schemas/Item'
19
+ ' 400 ' :
20
+ description : Error
21
+ content :
22
+ application/json :
23
+ schema :
24
+ $ref : ' #/components/schemas/Item'
25
+ default :
26
+ description : Error
27
+ content :
28
+ application/json :
29
+ schema :
30
+ $ref : ' #/components/schemas/Item'
31
+ components :
32
+ schemas :
33
+ Item :
34
+ type : object
35
+ properties :
36
+ prop :
37
+ type : string
You can’t perform that action at this time.
0 commit comments