@@ -162,6 +162,31 @@ public JsonNode GetSchema(Reflector reflector, Type type, JsonObject? defines =
162162 defines [ defTypeId ] = def ;
163163 }
164164 }
165+ else if ( TypeUtils . IsDictionary ( type ) )
166+ {
167+ var genericArgs = TypeUtils . GetDictionaryGenericArguments ( type ) ;
168+ if ( genericArgs == null )
169+ throw new InvalidOperationException ( $ "Unable to get generic arguments for dictionary type '{ type . GetTypeName ( pretty : false ) } '.") ;
170+
171+ foreach ( var genericArgument in genericArgs )
172+ {
173+ if ( TypeUtils . IsPrimitive ( genericArgument ) )
174+ continue ;
175+
176+ var defTypeId = genericArgument . GetSchemaTypeId ( ) ;
177+ if ( defines . ContainsKey ( defTypeId ) )
178+ continue ;
179+
180+ var defSchema = GetSchema ( reflector , genericArgument , defines ) ;
181+ if ( defSchema != null )
182+ defines [ defTypeId ] = defSchema ;
183+ }
184+
185+ if ( definesNeeded && ! defineContainsType )
186+ defines [ typeId ] = schema ;
187+
188+ schema = new JsonObject { [ Type ] = Object , [ AdditionalProperties ] = true } ;
189+ }
165190 else
166191 {
167192 schema = GenerateSchemaFromType ( reflector , type , defines ) ;
@@ -530,8 +555,7 @@ public JsonNode GenerateSchema(
530555 var schema = new JsonObject
531556 {
532557 // [SchemaDraft] = JsonValue.Create(SchemaDraftValue),
533- [ Type ] = Object ,
534- [ Properties ] = properties
558+ [ Type ] = Object
535559 } ;
536560
537561 foreach ( var parameter in types )
@@ -588,8 +612,12 @@ public JsonNode GenerateSchema(
588612 }
589613 }
590614
615+ if ( properties . Count > 0 )
616+ schema [ Properties ] = properties ;
617+
591618 if ( defines . Count > 0 && needToAddDefines )
592619 schema [ Defs ] = defines ;
620+
593621 if ( required . Count > 0 )
594622 schema [ Required ] = required ;
595623
0 commit comments