File tree 24 files changed +51
-44
lines changed
openapi-ts-tests/test/__snapshots__/3.0.x
discriminator-mapped-many
angular-query-experimental
24 files changed +51
-44
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @hey-api/openapi-ts " : patch
3
+ ---
4
+
5
+ fix: make descriminator field required when used with ` oneOf ` keyword
Original file line number Diff line number Diff line change 1
1
// This file is auto-generated by @hey-api/openapi-ts
2
2
3
3
export type Foo = ( {
4
- foo ? : 'one' | 'two' ;
4
+ foo : 'one' | 'two' ;
5
5
} & Bar ) | ( {
6
- foo ? : 'three' ;
6
+ foo : 'three' ;
7
7
} & Baz ) ;
8
8
9
9
export type Bar = {
Original file line number Diff line number Diff line change 1
1
// This file is auto-generated by @hey-api/openapi-ts
2
2
3
3
export type Foo = ( {
4
- type ? : 'Bar' ;
4
+ type : 'Bar' ;
5
5
} & Bar ) | ( {
6
- type ? : 'Baz' ;
6
+ type : 'Baz' ;
7
7
} & Baz ) ;
8
8
9
9
export type Baz = Qux ;
@@ -18,9 +18,9 @@ export type Qux = {
18
18
export type Quux = 'Bar' | 'Baz' ;
19
19
20
20
export type Quuz = ( {
21
- type ? : 'bar' ;
21
+ type : 'bar' ;
22
22
} & Bar ) | ( {
23
- type ? : 'baz' ;
23
+ type : 'baz' ;
24
24
} & Baz ) ;
25
25
26
26
export type ClientOptions = {
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -442,9 +442,9 @@ export type ModelSquare = {
442
442
* This is a model with one property with a 'one of' relationship where the options are not $ref
443
443
*/
444
444
export type CompositionWithOneOfDiscriminator = ( {
445
- kind ? : 'circle' ;
445
+ kind : 'circle' ;
446
446
} & ModelCircle ) | ( {
447
- kind ? : 'square' ;
447
+ kind : 'square' ;
448
448
} & ModelSquare ) ;
449
449
450
450
/**
Original file line number Diff line number Diff line change @@ -274,10 +274,10 @@ export const zModelSquare = z.object({
274
274
275
275
export const zCompositionWithOneOfDiscriminator = z . union ( [
276
276
z . object ( {
277
- kind : z . literal ( 'circle' ) . optional ( )
277
+ kind : z . literal ( 'circle' )
278
278
} ) . and ( zModelCircle ) ,
279
279
z . object ( {
280
- kind : z . literal ( 'square' ) . optional ( )
280
+ kind : z . literal ( 'square' )
281
281
} ) . and ( zModelSquare )
282
282
] ) ;
283
283
Original file line number Diff line number Diff line change @@ -710,6 +710,7 @@ const parseOneOf = ({
710
710
}
711
711
: valueSchemas [ 0 ] ! ,
712
712
} ,
713
+ required : [ schema . discriminator . propertyName ] ,
713
714
type : 'object' ,
714
715
} ;
715
716
irCompositionSchema = {
Original file line number Diff line number Diff line change @@ -423,6 +423,7 @@ const parseAllOf = ({
423
423
}
424
424
: valueSchemas [ 0 ] ! ,
425
425
} ,
426
+ required : [ ref . discriminator . propertyName ] ,
426
427
type : 'object' ,
427
428
} ;
428
429
if ( ref . required ?. includes ( ref . discriminator . propertyName ) ) {
You can’t perform that action at this time.
0 commit comments