feat: generate definition for complex types

This commit is contained in:
Stevan Freeborn
2024-06-30 14:42:10 -05:00
parent 96ed89c9ce
commit 057803a8f9
2 changed files with 109 additions and 5 deletions
@@ -447,7 +447,61 @@ public class JsonSchemaGeneratorTestData : IEnumerable<object[]>
},
}
};
// class parameter type with no attributes
yield return new object[]
{
Tool.CreateFromFunction(TestToolName,TestToolDescription,(Person person) => person),
new JsonObject()
{
["type"] = "object",
["definitions"] = new JsonObject()
{
[$"{typeof(Person).FullName}"] = new JsonObject()
{
["type"] = "object",
["properties"] = new JsonObject()
{
["String"] = new JsonObject()
{
["type"] = "string",
["description"] = string.Empty
},
["Int32"] = new JsonObject()
{
["type"] = "integer",
["description"] = string.Empty
}
},
["required"] = new JsonArray()
{
"String",
"Int32"
}
}
},
["properties"] = new JsonObject()
{
["person"] = new JsonObject()
{
["$ref"] = $"#/definitions/{typeof(Person).FullName}",
["description"] = string.Empty
}
},
["required"] = new JsonArray()
{
"person",
},
}
};
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
class Person
{
public string Name { get; } = string.Empty;
public int Age { get; }
}