99 "encoding/json"
1010 "fmt"
1111 "log"
12+ "reflect"
1213 "time"
1314
1415 "github.com/google/jsonschema-go/jsonschema"
@@ -34,8 +35,8 @@ func ExampleAddTool_customMarshalling() {
3435 // In this case, you can use jsonschema.For along with jsonschema.ForOptions
3536 // to customize the schema inference for your custom type.
3637 inputSchema , err := jsonschema.For [Input ](& jsonschema.ForOptions {
37- TypeSchemas : map [any ]* jsonschema.Schema {
38- MyDate {} : {Type : "string" },
38+ TypeSchemas : map [reflect. Type ]* jsonschema.Schema {
39+ reflect . TypeFor [ MyDate ]() : {Type : "string" },
3940 },
4041 })
4142 if err != nil {
@@ -152,9 +153,9 @@ func ExampleAddTool_complexSchema() {
152153 // !+customschemas
153154
154155 // Distinguished Go types allow custom schemas to be reused during inference.
155- customSchemas := map [any ]* jsonschema.Schema {
156- Probability ( 0 ): {Type : "number" , Minimum : jsonschema .Ptr (0.0 ), Maximum : jsonschema .Ptr (1.0 )},
157- WeatherType ( "" ): {Type : "string" , Enum : []any {Sunny , PartlyCloudy , Cloudy , Rainy , Snowy }},
156+ customSchemas := map [reflect. Type ]* jsonschema.Schema {
157+ reflect . TypeFor [ Probability ](): {Type : "number" , Minimum : jsonschema .Ptr (0.0 ), Maximum : jsonschema .Ptr (1.0 )},
158+ reflect . TypeFor [ WeatherType ]( ): {Type : "string" , Enum : []any {Sunny , PartlyCloudy , Cloudy , Rainy , Snowy }},
158159 }
159160 opts := & jsonschema.ForOptions {TypeSchemas : customSchemas }
160161 in , err := jsonschema.For [WeatherInput ](opts )
0 commit comments