Skip to content

Commit ad34a93

Browse files
authored
Check for nil options in ForType
Fixes #44
1 parent 6311905 commit ad34a93

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

jsonschema/infer.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ func For[T any](opts *ForOptions) (*Schema, error) {
9090

9191
// ForType is like [For], but takes a [reflect.Type]
9292
func ForType(t reflect.Type, opts *ForOptions) (*Schema, error) {
93+
if opts == nil {
94+
opts = &ForOptions{}
95+
}
9396
schemas := maps.Clone(initialSchemaMap)
9497
// Add types from the options. They override the default ones.
9598
maps.Copy(schemas, opts.TypeSchemas)

0 commit comments

Comments
 (0)