File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
packages/create_freestyle_fetch/src Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -140,6 +140,19 @@ export class SchemaGenerator {
140140 return parts . join ( ' & ' )
141141 }
142142
143+ // Handle nullable types (e.g. type: ['string', 'null'])
144+ if ( Array . isArray ( schema . type ) ) {
145+ const nonNullTypes = schema . type . filter ( ( t ) => t !== 'null' )
146+ if ( nonNullTypes . length === 1 ) {
147+ const innerSchema = {
148+ ...schema ,
149+ type : nonNullTypes [ 0 ] ,
150+ } as OpenAPIV3_1 . SchemaObject
151+ return `${ this . mapSchemaObjectToType ( name , innerSchema ) } | null`
152+ }
153+ return 'any'
154+ }
155+
143156 switch ( schema . type ) {
144157 case 'string' :
145158 if ( schema . enum )
@@ -173,7 +186,7 @@ export class SchemaGenerator {
173186 value
174187 )
175188 props . push (
176- ` '${ key } '${ isRequired ? '' : '?' } : ${ typeStr } ;`
189+ ` '${ key } '${ isRequired ? '' : '?' } : ${ typeStr } ${ isRequired ? '' : ' | undefined' } ;`
177190 )
178191 }
179192 )
You can’t perform that action at this time.
0 commit comments