Skip to content

Commit d9b2792

Browse files
committed
feat: enhance schema generation to support value types for additionalProperties
1 parent e042542 commit d9b2792

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

ReflectorNet/src/Utils/Json/JsonSchema.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,19 @@ public JsonNode GetSchema(Reflector reflector, Type type, JsonObject? defines =
182182
defines[defTypeId] = defSchema;
183183
}
184184

185+
if (genericArgs.Length >= 2)
186+
{
187+
// Use the value type's schema for additionalProperties
188+
var valueTypeSchema = GetSchema(reflector, genericArgs[1], defines);
189+
schema = new JsonObject { [Type] = Object, [AdditionalProperties] = valueTypeSchema };
190+
}
191+
else
192+
{
193+
schema = new JsonObject { [Type] = Object, [AdditionalProperties] = true };
194+
}
195+
185196
if (definesNeeded && !defineContainsType)
186197
defines[typeId] = schema;
187-
188-
schema = new JsonObject { [Type] = Object, [AdditionalProperties] = true };
189198
}
190199
else
191200
{

0 commit comments

Comments
 (0)