@@ -70,14 +70,15 @@ function nullOptionalsAllowedApply(schema: object) {
7070 if ( schema [ '$ref' ] ) return ;
7171 switch ( schema [ 'type' ] ) {
7272 case 'object' :
73- for ( let prop in schema [ 'properties' ] ) {
73+ const properties = schema [ 'properties' ] || { } ;
74+ for ( let prop in properties ) {
7475 if ( req . indexOf ( prop ) < 0 ) {
7576 nullOptionalsAllowedApply ( schema [ 'properties' ] [ prop ] ) ;
7677 }
7778 }
7879 break ;
7980 case 'array' :
80- const items = schema [ 'items' ] ;
81+ const items = schema [ 'items' ] || { } ;
8182 nullOptionalsAllowedApply ( items ) ;
8283 if ( items [ 'oneOf' ] && ! ( items [ 'oneOf' ] as any [ ] ) . some ( subschema => subschema [ "type" ] == "null" ) ) {
8384 items [ 'oneOf' ] . push ( { type : 'null' } ) ;
@@ -226,7 +227,7 @@ export function disjoin(schema0: object | null, schema1: object | null ): object
226227 case 'properties' :
227228 let deleteProps = [ ] ;
228229 for ( let p in schema [ 'properties' ] ) {
229- let otherProp = schema1 [ 'properties' ] [ p ] || null ;
230+ let otherProp = schema1 ?. [ 'properties' ] ?. [ p ] || null ;
230231 if ( otherProp === null ) {
231232 deleteProps . push ( p ) ;
232233 } else {
@@ -321,7 +322,7 @@ export function fieldUnion(baseSchema: object, schema: object | null): object |
321322 } ;
322323 switch ( schema [ 'type' ] ) {
323324 case "object" :
324- let props = schema [ 'properties' ] ;
325+ let props = schema [ 'properties' ] || { } ;
325326 for ( let field in props ) {
326327 union [ field ] = fieldUnion ( baseSchema , props [ field ] ) ;
327328 }
@@ -489,7 +490,7 @@ export const deleteSubschemaProperties = (value: any, schema: object): any => {
489490 }
490491 return value === { } ? null : value ;
491492 } else if ( schemaType === 'array' && Array . isArray ( value ) ) {
492- return ( value as any [ ] ) . map ( item => deleteSubschemaProperties ( item , schema [ 'items' ] ) ) . filter ( ( item : any ) => item !== null ) ;
493+ return ( value as any [ ] ) . map ( item => deleteSubschemaProperties ( item , schema [ 'items' ] || { } ) ) . filter ( ( item : any ) => item !== null ) ;
493494 } else {
494495 return null ;
495496 }
0 commit comments