DEV Community

Philip Perry
Philip Perry

Posted on

5

Why we chose the Go Huma framework to develop our API endpoints

At the company where I work as a software engineer, we are in the process of developing an API that communicates with our micro services and will be used by our own products as well as being an API that our clients can use. Our overall deciding factor for choosing Golang for this was speed. Apart from fast execution time, Go also offers low memory consumption and efficient concurrency.

When it came to the first step of specifying the endpoints, we were looking for a solution to do so in code as we wanted to avoid a discrepancy between code and documentation. Our CEO had used the same approach using Python FastApi, so we googled for a FastApi solution for Go and came across Huma. With Huma one can automatically generate OpenAPI documentation from code and it generates a nice-looking documentation using stoplight elements. It generates the JSON schema from Go types and uses static typing for path/query/header params, bodies, response headers, etc. It does input model validation & error handling automatically based on the json schema.

We’ve found the framework fairly flexible and it allows for instance to use one own's router, although we just stuck with Chi which it uses as the default one. There are some downsides, for instance it doesn’t seem to support array query parameters, so we’re separating filters by comma. But that hasn’t been a deal breaker.

I plan to write more about my experience and learnings with Go Huma in future posts, but so far I have found it fit for purpose.

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (2)

Collapse
 
xuanlong5 profile image
xuanlong

Nowaday. Should use gRPC

Collapse
 
programmingdecoded profile image
Philip Perry

Thanks. I'll look into it. Since this API is also meant for customers, I think REST is probably still the best option, but might be worth switching to gRPC for internal APIs.

Bump.sh

Bump.sh is much more than stunning documentations for all your APIs.

Automatically generate docs that are always up-to-date with CI integrations.
Get alerted on breaking API changes and enjoy the generated diff on each version.

Centralize all your API docs, whether they’re public, private or partner, whether they’re OpenAPI or AsyncAPI, and whether you’re building or consuming it.

Discover Bump.sh

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay