Skip to content

Conversation

@fy0
Copy link

@fy0 fy0 commented Nov 18, 2025

#698

Usage examples:

huma.RegisterTypeSchema(reflect.TypeOf(pgtype.Text{}), func(huma.Registry) *huma.Schema {
	return &huma.Schema{
		Type:     "string",
		Nullable: true,
	}
})

huma.RegisterTypeSchema(reflect.TypeOf(pgtype.Bool{}), func(huma.Registry) *huma.Schema {
	return &huma.Schema{
		Type:     "boolean",
		Nullable: true,
	}
})

huma.RegisterTypeSchema(reflect.TypeOf(pgtype.Int8{}), func(huma.Registry) *huma.Schema {
	return &huma.Schema{
		Type:     "integer",
		Nullable: true,
	}
})

// Register the schema for the `any` interface type so that it appears as an arbitrary object in the documentation.
huma.RegisterTypeSchema(reflect.TypeOf((*any)(nil)).Elem(), func(huma.Registry) *huma.Schema {
	return &huma.Schema{
		Type:                 "object",
		AdditionalProperties: map[string]*huma.Schema{},
	}
})

// Handle []any
huma.RegisterTypeSchema(reflect.TypeOf([]any{}), func(huma.Registry) *huma.Schema {
	return &huma.Schema{
		Type: "array",
		Items: &huma.Schema{
			Type:                 "object",
			AdditionalProperties: map[string]*huma.Schema{},
		},
	}
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant