Skip to content

feat: huma.RegisterTypeSchema#917

Open
fy0 wants to merge 1 commit intodanielgtaylor:mainfrom
fy0:main
Open

feat: huma.RegisterTypeSchema#917
fy0 wants to merge 1 commit intodanielgtaylor:mainfrom
fy0:main

Conversation

@fy0
Copy link
Copy Markdown

@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{},
		},
	}
})

@pot-code
Copy link
Copy Markdown

this would be awesome

@wolveix wolveix added the enhancement New feature or request label Feb 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants