# danielgtaylor/huma

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/danielgtaylor-huma).**

4,170 stars · 270 forks · Go · MIT

## Links

- GitHub: https://github.com/danielgtaylor/huma
- Homepage: https://huma.rocks/
- awesome-repositories: https://awesome-repositories.com/repository/danielgtaylor-huma.md

## Topics

`api` `documentation` `fastapi` `framework` `golang` `golang-library` `hacktoberfest` `huma` `json-schema` `openapi` `openapi-server` `openapi3` `openapi31` `rest` `rest-api` `swagger-ui` `web`

## Description

Huma is an OpenAPI REST framework for Go designed for building HTTP services with automatic OpenAPI 3.1 specification generation and JSON Schema validation. It serves as a toolkit for developing REST and RPC APIs with typed inputs and outputs, deriving interactive documentation directly from the source code.

The framework distinguishes itself by automating the synchronization between implementation and documentation. It uses a content-negotiation engine to manage multiple serialization formats via client headers and employs a JSON Schema input validator to automatically verify request parameters and bodies based on Go types.

The project covers a broad range of API capabilities, including request parameter binding via struct tags, the management of conditional requests using ETags, and the implementation of partial updates. It also provides tools for server lifecycle management, including command-line configuration, graceful shutdowns, and the integration of custom HTTP routers via a standardized adapter interface.

## Tags

### Security & Cryptography

- [Type-Derived JSON Schemas](https://awesome-repositories.com/f/security-cryptography/input-validation-schemas/type-derived-json-schemas.md) — Automatically generates JSON Schema validation rules from Go types to verify incoming request data.
- [Input Validation Schemas](https://awesome-repositories.com/f/security-cryptography/input-validation-schemas.md) — Automatically generates JSON Schemas from Go types to validate request data and return standard errors. ([source](https://huma.rocks/features/))
- [Authentication Documentation](https://awesome-repositories.com/f/security-cryptography/authentication-documentation.md) — Defines security requirements and token flows within the specification to inform clients how to authenticate. ([source](https://huma.rocks/how-to/oauth2-jwt/))

### Web Development

- [RESTful API Development](https://awesome-repositories.com/f/web-development/restful-api-development.md) — Building HTTP services with typed inputs and outputs while automating the generation of OpenAPI specifications.
- [OpenAPI Specification Generators](https://awesome-repositories.com/f/web-development/restful-apis/documentation-schemas/openapi-specification-generators.md) — Automatically generates OpenAPI 3.1 specifications directly from Go code structures to ensure documentation stays in sync.
- [API Parameter Validation](https://awesome-repositories.com/f/web-development/api-parameter-validation.md) — Enforces strict constraints such as numeric ranges and maximum lengths on API request parameters. ([source](https://cdn.jsdelivr.net/gh/danielgtaylor/huma@main/README.md))
- [API Resource Mapping](https://awesome-repositories.com/f/web-development/api-resource-mapping.md) — Implements the mapping of HTTP methods and resource paths to handler functions with strongly typed inputs and outputs. ([source](https://huma.rocks/features/operations/))
- [Content Negotiation](https://awesome-repositories.com/f/web-development/content-negotiation.md) — Manages data exchange by supporting multiple content types like JSON and CBOR via the Accept header. ([source](https://huma.rocks/features/))
- [Content Negotiation Pipelines](https://awesome-repositories.com/f/web-development/content-negotiation-pipelines.md) — Includes a content-negotiation engine that selects serialization formats based on client Accept headers.
- [Middleware Frameworks](https://awesome-repositories.com/f/web-development/middleware-frameworks.md) — Implements a request processing chain for handling cross-cutting concerns like authentication and tracing.
- [Request Middleware](https://awesome-repositories.com/f/web-development/request-middleware.md) — Provides mechanisms for injecting custom logic into the request pipeline globally or on a per-operation basis. ([source](https://huma.rocks/features/middleware/))
- [Content Negotiation](https://awesome-repositories.com/f/web-development/response-formatting/content-negotiation.md) — Determines request and response formats by matching Content-Type and Accept headers. ([source](https://huma.rocks/features/response-serialization/))
- [Response Serialization](https://awesome-repositories.com/f/web-development/response-serialization.md) — Provides a configurable pipeline for converting Go objects into various serialization formats for transmission. ([source](https://huma.rocks/features/response-serialization/))
- [REST API Frameworks](https://awesome-repositories.com/f/web-development/rest-api-frameworks.md) — Offers a structured framework for building HTTP endpoints with native support for request parameters, bodies, and response headers. ([source](https://cdn.jsdelivr.net/gh/danielgtaylor/huma@main/README.md))
- [REST API Services](https://awesome-repositories.com/f/web-development/rest-api-services.md) — Provides a framework for building HTTP services that support both REST and RPC patterns with automated documentation. ([source](https://huma.rocks/tutorial/installation/))
- [OpenAPI Frameworks](https://awesome-repositories.com/f/web-development/restful-apis/documentation-schemas/openapi-frameworks.md) — Serves as a comprehensive toolkit for building Go HTTP services with integrated OpenAPI 3.1 generation and validation.
- [OpenAPI Response Definitions](https://awesome-repositories.com/f/web-development/api-management-tools/api-development-management/api-documentation/openapi-response-definitions.md) — Maps response bodies and headers to Go structs to automate output formatting and OpenAPI response definitions. ([source](https://huma.rocks/features/response-outputs/))
- [Response Header Modifiers](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/http-response-handling/response-metadata-accessors/response-header-modifiers.md) — Allows assigning custom headers and cookies to outgoing responses using declarative struct tags. ([source](https://huma.rocks/features/response-outputs/))
- [Request and Response Transformers](https://awesome-repositories.com/f/web-development/backend-development/request-response-handling/request-and-response-transformers.md) — Provides mechanisms to modify structured response data and inject headers after the handler executes. ([source](https://huma.rocks/features/operations/))
- [RFC 7807 Implementations](https://awesome-repositories.com/f/web-development/error-response-mappers/rfc-7807-implementations.md) — Produces machine-readable error responses following the RFC 7807 Problem Details for HTTP APIs standard.
- [Descriptive HTTP Error Responses](https://awesome-repositories.com/f/web-development/http-error-handling/descriptive-http-error-responses.md) — Implements standardized error responses using the RFC 9457 Problem Details format. ([source](https://huma.rocks/features/response-errors/))
- [HTTP Routers](https://awesome-repositories.com/f/web-development/http-routers.md) — Provides a standardized adapter interface to decouple the framework from various HTTP routing libraries.
- [Partial Update Operations](https://awesome-repositories.com/f/web-development/partial-update-operations.md) — Create partial update endpoints based on existing resources using merge patch formats and conditional headers. ([source](https://huma.rocks/features/auto-patch/))
- [Pluggable Serialization Formats](https://awesome-repositories.com/f/web-development/pluggable-serialization-formats.md) — Adds support for new data formats by providing custom marshal and unmarshal functions. ([source](https://huma.rocks/features/response-serialization/))
- [Structured Body Binding](https://awesome-repositories.com/f/web-development/request-body-handling/request-body-alterations/request-body-attachers/structured-body-binding.md) — Maps HTTP request bodies to structured Go types using configurable content types and optionality settings. ([source](https://huma.rocks/features/request-inputs/))
- [Request Data Transformation](https://awesome-repositories.com/f/web-development/request-data-transformation.md) — Executes custom transformation logic on incoming request data before it reaches the handler. ([source](https://huma.rocks/features/request-resolvers/))
- [Specification Customizations](https://awesome-repositories.com/f/web-development/restful-apis/documentation-schemas/openapi-specification-generators/specification-customizations.md) — Provides configuration options to inject custom security schemes and extensions into the generated OpenAPI specification. ([source](https://huma.rocks/features/openapi-generation/))
- [Route Grouping](https://awesome-repositories.com/f/web-development/route-grouping.md) — Organizes API endpoints into logical hierarchies to share common middleware and path prefixes. ([source](https://huma.rocks/features/groups/))
- [Router Adapters](https://awesome-repositories.com/f/web-development/router-integrations/router-adapters.md) — Connect to any HTTP router via a standard adapter interface to add functionality to existing services. ([source](https://huma.rocks/features/bring-your-own-router/))
- [Schema Customization](https://awesome-repositories.com/f/web-development/schema-customization.md) — Allows overriding generated OpenAPI schemas to define custom validation rules and documentation for request and response bodies. ([source](https://huma.rocks/features/schema-customization/))
- [Strict Schema Validation](https://awesome-repositories.com/f/web-development/strict-schema-validation.md) — Allows rejecting requests that contain unexpected fields not defined in the JSON schema to prevent input errors. ([source](https://huma.rocks/features/request-validation/))

### Development Tools & Productivity

- [API Documentation Generators](https://awesome-repositories.com/f/development-tools-productivity/api-documentation-generators.md) — Produces up-to-date OpenAPI 3.1 specifications directly from source code to maintain accurate API documentation. ([source](https://cdn.jsdelivr.net/gh/danielgtaylor/huma@main/README.md))
- [Command-Line Argument Parsers](https://awesome-repositories.com/f/development-tools-productivity/command-line-argument-parsers.md) — Maps typed Go structures to command-line flags with support for default values and aliases. ([source](https://huma.rocks/features/cli/))
- [Interactive Documentation Interfaces](https://awesome-repositories.com/f/development-tools-productivity/openapi-configurations/documentation-generators/openapi-specification-generators/interactive-documentation-interfaces.md) — Generates a web interface that renders OpenAPI specifications for real-time testing and exploration of endpoints. ([source](https://huma.rocks/features/api-docs/))

### DevOps & Infrastructure

- [Handler Route Mapping](https://awesome-repositories.com/f/devops-infrastructure/rest-api-endpoint-management/handler-route-mapping.md) — Provides the core mechanism for mapping URL paths to handler functions using structured input and output models. ([source](https://huma.rocks/tutorial/your-first-api/))
- [Command Line Configuration Interfaces](https://awesome-repositories.com/f/devops-infrastructure/configuration-management/application-settings-management/command-line-configuration-interfaces.md) — Bootstraps servers with a command-line interface for managing runtime configuration and environment variables. ([source](https://cdn.jsdelivr.net/gh/danielgtaylor/huma@main/README.md))
- [Server Lifecycles](https://awesome-repositories.com/f/devops-infrastructure/server-lifecycles.md) — Provides built-in tools for managing server startup and executing graceful shutdowns of HTTP services.
- [Service CLI Wrappers](https://awesome-repositories.com/f/devops-infrastructure/service-cli-wrappers.md) — Creates a command-line layer to handle startup arguments, environment variable binding, and graceful shutdown logic. ([source](https://huma.rocks/features/cli/))
- [Service Lifecycle Management](https://awesome-repositories.com/f/devops-infrastructure/service-lifecycle-management.md) — Handles application startup and graceful shutdowns using configuration arguments or environment variables. ([source](https://huma.rocks/features/))

### Programming Languages & Runtimes

- [Request Parameter Parsing](https://awesome-repositories.com/f/programming-languages-runtimes/type-annotations/request-parameter-parsing.md) — Uses Go struct tags to automatically parse and bind values from paths, query strings, headers, and cookies. ([source](https://huma.rocks/features/request-inputs/))

### Software Engineering & Architecture

- [Data Validation Schemas](https://awesome-repositories.com/f/software-engineering-architecture/data-validation-schemas.md) — Checks request parameters against schemas or custom logic and returns detailed error messages. ([source](https://huma.rocks/why/))
- [Validation Constraints](https://awesome-repositories.com/f/software-engineering-architecture/metadata-attachments/struct-tags/validation-constraints.md) — Uses Go struct tags to define input constraints that automatically generate JSON Schemas and documentation. ([source](https://huma.rocks/features/request-validation/))
- [Request Middleware](https://awesome-repositories.com/f/software-engineering-architecture/request-middleware.md) — Implements a request middleware pipeline to handle cross-cutting concerns like authentication, metrics, and tracing. ([source](https://huma.rocks/why/))
- [Custom Schema Definitions](https://awesome-repositories.com/f/software-engineering-architecture/data-schema-validation/data-type-validation/custom-schema-definitions.md) — Applies advanced JSON Schema validation rules, including negation and schema unions, for custom API inputs. ([source](https://huma.rocks/features/request-validation/))
- [API Route Groups](https://awesome-repositories.com/f/software-engineering-architecture/integration-extensibility/api-design-management/api-patterns/api-route-groups.md) — Groups API operations under common base URL paths to support versioning and organized documentation. ([source](https://huma.rocks/features/bring-your-own-router/))
- [Partial Update Strategies](https://awesome-repositories.com/f/software-engineering-architecture/partial-update-strategies.md) — Implements architectural patterns for partial resource updates using PATCH operations. ([source](https://huma.rocks/features/))
- [Authorization Validation](https://awesome-repositories.com/f/software-engineering-architecture/request-validation/authorization-validation.md) — Inspects request headers for valid tokens and verifies that users possess required scopes for an operation. ([source](https://huma.rocks/how-to/oauth2-jwt/))

### User Interface & Experience

- [Struct Tag Binding](https://awesome-repositories.com/f/user-interface-experience/data-binding/struct-tag-binding.md) — Maps HTTP path, query, and header values to typed Go structures using declarative struct tags.
