File tree Expand file tree Collapse file tree 4 files changed +95
-2
lines changed Expand file tree Collapse file tree 4 files changed +95
-2
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' fets ' : patch
3
+ ---
4
+
5
+ Support ` exclusiveMinimum ` or ` exclusiveMaximum ` as booleans instead of numbers only
Original file line number Diff line number Diff line change @@ -242,8 +242,10 @@ export type OASModel<
242
242
: never ;
243
243
244
244
// Later suggest using json-machete
245
- export type FixJSONSchema < T > = FixAdditionalPropertiesForAllOf <
246
- FixMissingAdditionalProperties < FixMissingTypeObject < FixExtraRequiredFields < T > > >
245
+ export type FixJSONSchema < T > = RemoveExclusiveMinimumAndMaximum <
246
+ FixAdditionalPropertiesForAllOf <
247
+ FixMissingAdditionalProperties < FixMissingTypeObject < FixExtraRequiredFields < T > > >
248
+ >
247
249
> ;
248
250
249
251
type FixAdditionalPropertiesForAllOf < T > = T extends { allOf : any [ ] }
@@ -270,6 +272,14 @@ type FixExtraRequiredFields<T> = T extends {
270
272
}
271
273
: T ;
272
274
275
+ // Currently boolean values for those two are not supported
276
+ type RemoveExclusiveMinimumAndMaximum < T > = T extends {
277
+ exclusiveMinimum ?: boolean ;
278
+ exclusiveMaximum ?: boolean ;
279
+ }
280
+ ? Omit < T , 'exclusiveMinimum' | 'exclusiveMaximum' >
281
+ : T ;
282
+
273
283
export type OASRequestParams <
274
284
TOAS extends OpenAPIDocument ,
275
285
TPath extends keyof OASPathMap < TOAS > ,
Original file line number Diff line number Diff line change
1
+ import { createClient , NormalizeOAS } from 'fets' ;
2
+ import exampleExclusiveOas from './fixtures/example-exclusive-oas' ;
3
+
4
+ const client = createClient < NormalizeOAS < typeof exampleExclusiveOas > > ( { } ) ;
5
+
6
+ const res = await client [ '/minmaxtest' ] . post ( {
7
+ json : {
8
+ sequence : 1 ,
9
+ } ,
10
+ } ) ;
11
+
12
+ if ( res . ok ) {
13
+ const successBody = await res . json ( ) ;
14
+ console . log ( successBody . sequence ) ;
15
+ }
Original file line number Diff line number Diff line change
1
+ export default {
2
+ openapi : '3.0.3' ,
3
+ info : {
4
+ title : 'Minmaxtest' ,
5
+ description : 'Minmaxtest' ,
6
+ version : '0.1.0' ,
7
+ } ,
8
+ components : {
9
+ securitySchemes : {
10
+ basicAuth : {
11
+ type : 'http' ,
12
+ scheme : 'basic' ,
13
+ } ,
14
+ } ,
15
+ schemas : { } ,
16
+ } ,
17
+ paths : {
18
+ '/minmaxtest' : {
19
+ post : {
20
+ requestBody : {
21
+ content : {
22
+ 'application/json' : {
23
+ schema : {
24
+ type : 'object' ,
25
+ properties : {
26
+ sequence : {
27
+ type : 'integer' ,
28
+ exclusiveMinimum : true ,
29
+ minimum : 0 ,
30
+ } ,
31
+ } ,
32
+ required : [ 'sequence' ] ,
33
+ additionalProperties : false ,
34
+ } ,
35
+ } ,
36
+ } ,
37
+ required : true ,
38
+ } ,
39
+ responses : {
40
+ '201' : {
41
+ description : 'Default Response' ,
42
+ content : {
43
+ 'application/json' : {
44
+ schema : {
45
+ type : 'object' ,
46
+ properties : {
47
+ sequence : {
48
+ type : 'integer' ,
49
+ exclusiveMinimum : true ,
50
+ minimum : 0 ,
51
+ } ,
52
+ } ,
53
+ required : [ 'sequence' ] ,
54
+ additionalProperties : false ,
55
+ } ,
56
+ } ,
57
+ } ,
58
+ } ,
59
+ } ,
60
+ } ,
61
+ } ,
62
+ } ,
63
+ } as const ;
You can’t perform that action at this time.
0 commit comments