Skip to content

Commit b42bd9e

Browse files
authored
Simplify GenerateOutputSchema to use idiomatic For[T]() pattern (#7046)
1 parent 4e0efe1 commit b42bd9e

1 file changed

Lines changed: 1 addition & 14 deletions

File tree

pkg/cli/mcp_schema.go

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package cli
22

33
import (
4-
"fmt"
5-
"reflect"
6-
74
"github.com/google/jsonschema-go/jsonschema"
85
)
96

@@ -30,15 +27,5 @@ import (
3027
// OutputSchema: schema,
3128
// }
3229
func GenerateOutputSchema[T any]() (*jsonschema.Schema, error) {
33-
// Get the type of T
34-
var zero T
35-
typ := reflect.TypeOf(zero)
36-
37-
// Use jsonschema.ForType to generate schema from Go type
38-
schema, err := jsonschema.ForType(typ, &jsonschema.ForOptions{})
39-
if err != nil {
40-
return nil, fmt.Errorf("failed to generate schema: %w", err)
41-
}
42-
43-
return schema, nil
30+
return jsonschema.For[T](nil)
4431
}

0 commit comments

Comments
 (0)