File tree Expand file tree Collapse file tree
mini/string-with-guid-format
v3/string-with-guid-format
v4/string-with-guid-format
openapi-ts/src/plugins/zod Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ " @hey-api/openapi-ts " : patch
3+ ---
4+
5+ ** plugin(zod)** : handle ` guid ` string format
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 zGetFooData = z . object ( {
6+ body : z . optional ( z . never ( ) ) ,
7+ path : z . object ( {
8+ guidId : z . guid ( )
9+ } ) ,
10+ query : z . optional ( z . never ( ) )
11+ } ) ;
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 zGetFooData = z . object ( {
6+ body : z . never ( ) . optional ( ) ,
7+ path : z . object ( {
8+ guidId : z . string ( )
9+ } ) ,
10+ query : z . never ( ) . optional ( )
11+ } ) ;
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' ;
4+
5+ export const zGetFooData = z . object ( {
6+ body : z . never ( ) . optional ( ) ,
7+ path : z . object ( {
8+ guidId : z . guid ( )
9+ } ) ,
10+ query : z . never ( ) . optional ( )
11+ } ) ;
Original file line number Diff line number Diff line change @@ -46,6 +46,19 @@ for (const zodVersion of zodVersions) {
4646 } ) ,
4747 description : 'generates anyOf string and binary string' ,
4848 } ,
49+ {
50+ config : createConfig ( {
51+ input : 'string-with-guid-format.yaml' ,
52+ output : 'string-with-guid-format' ,
53+ plugins : [
54+ {
55+ compatibilityVersion : zodVersion . compatibilityVersion ,
56+ name : 'zod' ,
57+ } ,
58+ ] ,
59+ } ) ,
60+ description : 'handles string guid format' ,
61+ } ,
4962 ] ;
5063
5164 it . each ( scenarios ) ( '$description' , async ( { config } ) => {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export const identifiers = {
2020 globalRegistry : 'globalRegistry' ,
2121 gt : 'gt' ,
2222 gte : 'gte' ,
23+ guid : 'guid' ,
2324 infer : 'infer' ,
2425 int : 'int' ,
2526 intersection : 'intersection' ,
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ function formatNode(ctx: StringResolverContext): ChainResult {
3636 }
3737 case 'email' :
3838 return $ ( z ) . attr ( identifiers . email ) . call ( ) ;
39+ case 'guid' :
40+ return $ ( z ) . attr ( identifiers . guid ) . call ( ) ;
3941 case 'ipv4' :
4042 return $ ( z ) . attr ( identifiers . ipv4 ) . call ( ) ;
4143 case 'ipv6' :
Original file line number Diff line number Diff line change @@ -36,6 +36,8 @@ function formatNode(ctx: StringResolverContext): ChainResult {
3636 }
3737 case 'email' :
3838 return $ ( z ) . attr ( identifiers . email ) . call ( ) ;
39+ case 'guid' :
40+ return $ ( z ) . attr ( identifiers . guid ) . call ( ) ;
3941 case 'ipv4' :
4042 return $ ( z ) . attr ( identifiers . ipv4 ) . call ( ) ;
4143 case 'ipv6' :
Original file line number Diff line number Diff line change 1+ openapi : 3.1.1
2+ info :
3+ title : OpenAPI 3.1.1 string with GUID format example
4+ version : ' 1'
5+ paths :
6+ /foo/{guidId} :
7+ get :
8+ operationId : getFoo
9+ parameters :
10+ - name : guidId
11+ in : path
12+ required : true
13+ schema :
14+ type : string
15+ format : guid
16+ responses :
17+ ' 200 ' :
18+ description : OK
You can’t perform that action at this time.
0 commit comments