@@ -35,19 +35,27 @@ export function isAnySchema(schema: JSONSchema): boolean {
3535 * @internal
3636 */
3737export function separateObjectSchema ( schema : ObjectSchema , separatedProperties : string [ ] ) : [ matched : ObjectSchema , rest : ObjectSchema ] {
38- if ( Object . keys ( schema ) . some ( k => k !== 'type' && k !== 'properties' && k !== 'required' && k !== 'additionalProperties' && LOGIC_KEYWORDS . includes ( k ) ) ) {
38+ if ( Object . keys ( schema ) . some (
39+ k => ! [ 'type' , 'properties' , 'required' , 'additionalProperties' ] . includes ( k )
40+ && LOGIC_KEYWORDS . includes ( k )
41+ && ( schema as any ) [ k ] !== undefined ,
42+ ) ) {
3943 return [ { type : 'object' } , schema ]
4044 }
4145
4246 const matched : ObjectSchema = { ...schema }
4347 const rest : ObjectSchema = { ...schema }
4448
45- matched . properties = schema . properties && Object . entries ( schema . properties )
46- . filter ( ( [ key ] ) => separatedProperties . includes ( key ) )
47- . reduce ( ( acc , [ key , value ] ) => {
48- acc [ key ] = value
49+ matched . properties = separatedProperties
50+ . reduce ( ( acc : Record < string , JSONSchema > , key ) => {
51+ const keySchema = schema . properties ?. [ key ] ?? schema . additionalProperties
52+
53+ if ( keySchema !== undefined ) {
54+ acc [ key ] = keySchema
55+ }
56+
4957 return acc
50- } , { } as Record < string , JSONSchema > )
58+ } , { } )
5159
5260 matched . required = schema . required ?. filter ( key => separatedProperties . includes ( key ) )
5361
0 commit comments