File tree Expand file tree Collapse file tree 14 files changed +254
-14
lines changed
main/test/__snapshots__/3.1.x/plugins/valibot/default
defaults-with-ref-and-anyof
defaults-with-ref-and-anyof
defaults-with-ref-and-anyof
openapi-ts/src/openApi/3.1.x/parser Expand file tree Collapse file tree 14 files changed +254
-14
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @hey-api/openapi-ts " : patch
3+ ---
4+
5+ parser: merge ` default ` keyword with ` $ref ` in OpenAPI 3.1
Original file line number Diff line number Diff line change @@ -1455,7 +1455,9 @@ export const vCallWithDefaultParametersData = v.object({
14551455 'Error'
14561456 ] ) ) ,
14571457 parameterModel : v . optional ( v . union ( [
1458- vModelWithString ,
1458+ v . optional ( vModelWithString , {
1459+ prop : 'Hello World!'
1460+ } ) ,
14591461 v . null ( )
14601462 ] ) )
14611463 } ) )
@@ -1473,7 +1475,9 @@ export const vCallWithDefaultOptionalParametersData = v.object({
14731475 'Warning' ,
14741476 'Error'
14751477 ] ) ) ,
1476- parameterModel : v . optional ( vModelWithString )
1478+ parameterModel : v . optional ( vModelWithString , {
1479+ prop : 'Hello World!'
1480+ } )
14771481 } ) )
14781482} ) ;
14791483
Original file line number Diff line number Diff line change @@ -1486,7 +1486,9 @@ export const zCallWithDefaultParametersData = z.object({
14861486 'Error'
14871487 ] ) ) ,
14881488 parameterModel : z . optional ( z . union ( [
1489- zModelWithString ,
1489+ z . _default ( zModelWithString , {
1490+ prop : 'Hello World!'
1491+ } ) ,
14901492 z . null ( )
14911493 ] ) )
14921494 } ) )
@@ -1504,7 +1506,9 @@ export const zCallWithDefaultOptionalParametersData = z.object({
15041506 'Warning' ,
15051507 'Error'
15061508 ] ) ) ,
1507- parameterModel : z . optional ( zModelWithString )
1509+ parameterModel : z . _default ( z . optional ( zModelWithString ) , {
1510+ prop : 'Hello World!'
1511+ } )
15081512 } ) )
15091513} ) ;
15101514
Original file line number Diff line number Diff line change @@ -1484,7 +1484,9 @@ export const zCallWithDefaultParametersData = z.object({
14841484 'Error'
14851485 ] ) . optional ( ) ,
14861486 parameterModel : z . union ( [
1487- zModelWithString ,
1487+ zModelWithString . default ( {
1488+ prop : 'Hello World!'
1489+ } ) ,
14881490 z . null ( )
14891491 ] ) . optional ( )
14901492 } ) . optional ( )
@@ -1502,7 +1504,9 @@ export const zCallWithDefaultOptionalParametersData = z.object({
15021504 'Warning' ,
15031505 'Error'
15041506 ] ) . optional ( ) ,
1505- parameterModel : zModelWithString . optional ( )
1507+ parameterModel : zModelWithString . optional ( ) . default ( {
1508+ prop : 'Hello World!'
1509+ } )
15061510 } ) . optional ( )
15071511} ) ;
15081512
Original file line number Diff line number Diff line change @@ -1486,7 +1486,9 @@ export const zCallWithDefaultParametersData = z.object({
14861486 'Error'
14871487 ] ) ) ,
14881488 parameterModel : z . optional ( z . union ( [
1489- zModelWithString ,
1489+ zModelWithString . default ( {
1490+ prop : 'Hello World!'
1491+ } ) ,
14901492 z . null ( )
14911493 ] ) )
14921494 } ) )
@@ -1504,7 +1506,9 @@ export const zCallWithDefaultOptionalParametersData = z.object({
15041506 'Warning' ,
15051507 'Error'
15061508 ] ) ) ,
1507- parameterModel : z . optional ( zModelWithString )
1509+ parameterModel : z . optional ( zModelWithString ) . default ( {
1510+ prop : 'Hello World!'
1511+ } )
15081512 } ) )
15091513} ) ;
15101514
Original file line number Diff line number Diff line change @@ -1486,7 +1486,9 @@ export const zCallWithDefaultParametersData = z.object({
14861486 'Error'
14871487 ] ) ) ,
14881488 parameterModel : z . optional ( z . union ( [
1489- zModelWithString ,
1489+ z . _default ( zModelWithString , {
1490+ prop : 'Hello World!'
1491+ } ) ,
14901492 z . null ( )
14911493 ] ) )
14921494 } ) )
@@ -1504,7 +1506,9 @@ export const zCallWithDefaultOptionalParametersData = z.object({
15041506 'Warning' ,
15051507 'Error'
15061508 ] ) ) ,
1507- parameterModel : z . optional ( zModelWithString )
1509+ parameterModel : z . _default ( z . optional ( zModelWithString ) , {
1510+ prop : 'Hello World!'
1511+ } )
15081512 } ) )
15091513} ) ;
15101514
Original file line number Diff line number Diff line change 1+ // This file is auto-generated by @hey-api/openapi-ts
2+
3+ import * as z from 'zod/mini' ;
4+
5+ export const zAudioFormat = z . enum ( [
6+ 'pcm_16bit_44.1khz' ,
7+ 'pcm_16bit_24khz'
8+ ] ) ;
9+
10+ export const zLanguage = z . enum ( [
11+ 'en' ,
12+ 'es' ,
13+ 'fr'
14+ ] ) ;
15+
16+ export const zNestedConfig = z . object ( {
17+ model : z . _default ( z . string ( ) , 'gpt-4' ) ,
18+ temperature : z . _default ( z . number ( ) , 1 )
19+ } ) ;
20+
21+ export const zTestSchema = z . object ( {
22+ primitiveDefault : z . _default ( z . number ( ) , 42 ) ,
23+ refWithPrimitiveDefault : z . _default ( zAudioFormat , 'pcm_16bit_44.1khz' ) ,
24+ refWithObjectDefault : z . _default ( zNestedConfig , {
25+ model : 'gpt-4' ,
26+ temperature : 1
27+ } ) ,
28+ anyOfWithNullDefault : z . _default ( z . union ( [
29+ z . number ( ) ,
30+ z . null ( )
31+ ] ) , null ) ,
32+ anyOfWithRefAndNullDefault : z . _default ( z . union ( [
33+ zLanguage ,
34+ z . null ( )
35+ ] ) , null ) ,
36+ optionalAnyOfWithDefault : z . _default ( z . optional ( z . union ( [
37+ z . string ( ) ,
38+ z . null ( )
39+ ] ) ) , null )
40+ } ) ;
Original file line number Diff line number Diff line change @@ -1484,7 +1484,9 @@ export const zCallWithDefaultParametersData = z.object({
14841484 'Error'
14851485 ] ) . optional ( ) ,
14861486 parameterModel : z . union ( [
1487- zModelWithString ,
1487+ zModelWithString . default ( {
1488+ prop : 'Hello World!'
1489+ } ) ,
14881490 z . null ( )
14891491 ] ) . optional ( )
14901492 } ) . optional ( )
@@ -1502,7 +1504,9 @@ export const zCallWithDefaultOptionalParametersData = z.object({
15021504 'Warning' ,
15031505 'Error'
15041506 ] ) . optional ( ) ,
1505- parameterModel : zModelWithString . optional ( )
1507+ parameterModel : zModelWithString . optional ( ) . default ( {
1508+ prop : 'Hello World!'
1509+ } )
15061510 } ) . optional ( )
15071511} ) ;
15081512
Original file line number Diff line number Diff line change 1+ // This file is auto-generated by @hey-api/openapi-ts
2+
3+ import { z } from 'zod/v3' ;
4+
5+ export const zAudioFormat = z . enum ( [
6+ 'pcm_16bit_44.1khz' ,
7+ 'pcm_16bit_24khz'
8+ ] ) ;
9+
10+ export const zLanguage = z . enum ( [
11+ 'en' ,
12+ 'es' ,
13+ 'fr'
14+ ] ) ;
15+
16+ export const zNestedConfig = z . object ( {
17+ model : z . string ( ) . default ( 'gpt-4' ) ,
18+ temperature : z . number ( ) . default ( 1 )
19+ } ) ;
20+
21+ export const zTestSchema = z . object ( {
22+ primitiveDefault : z . number ( ) . default ( 42 ) ,
23+ refWithPrimitiveDefault : zAudioFormat . default ( 'pcm_16bit_44.1khz' ) ,
24+ refWithObjectDefault : zNestedConfig . default ( {
25+ model : 'gpt-4' ,
26+ temperature : 1
27+ } ) ,
28+ anyOfWithNullDefault : z . union ( [
29+ z . number ( ) ,
30+ z . null ( )
31+ ] ) . default ( null ) ,
32+ anyOfWithRefAndNullDefault : z . union ( [
33+ zLanguage ,
34+ z . null ( )
35+ ] ) . default ( null ) ,
36+ optionalAnyOfWithDefault : z . union ( [
37+ z . string ( ) ,
38+ z . null ( )
39+ ] ) . optional ( ) . default ( null )
40+ } ) ;
Original file line number Diff line number Diff line change @@ -1486,7 +1486,9 @@ export const zCallWithDefaultParametersData = z.object({
14861486 'Error'
14871487 ] ) ) ,
14881488 parameterModel : z . optional ( z . union ( [
1489- zModelWithString ,
1489+ zModelWithString . default ( {
1490+ prop : 'Hello World!'
1491+ } ) ,
14901492 z . null ( )
14911493 ] ) )
14921494 } ) )
@@ -1504,7 +1506,9 @@ export const zCallWithDefaultOptionalParametersData = z.object({
15041506 'Warning' ,
15051507 'Error'
15061508 ] ) ) ,
1507- parameterModel : z . optional ( zModelWithString )
1509+ parameterModel : z . optional ( zModelWithString ) . default ( {
1510+ prop : 'Hello World!'
1511+ } )
15081512 } ) )
15091513} ) ;
15101514
You can’t perform that action at this time.
0 commit comments