Fuego: an OpenAPI framework
Ewen QUIMERC’H Edouard LACOURT
go-fuego/fuego
Who are we?
A major issue working with APIs
API
Consumers (front,
other APIs, mobile
app…)
How can consumers and API systems exchange information seamlessly?
GET data
Bad request
Route does not exist
500 errors
OpenAPI!
REST API API users
Fully detailed interface contract
json/yaml description
OpenAPI: the good is the ugly
… but it’s unreadable
& unmaintainable for
humans 🤢
Everything is declared
& standardised …
❤️
=
Swagger UI as interactive documentation
🤩
Swagger UI, the OpenAPI for humans
REST API
Machines
Humans
Raw JSON/YAML spec
Swagger
Browser
Client Generators
❓
Server-side OpenAPI state of the art
1. Generate OpenAPI spec from
source code
2. Generate server code from existing
OpenAPI spec
Server code
boilerplate
interfaces
Code-first : better than Doc-first?
Faster Prototyping
Code agility > Specification burden
Ease of Use
Code familiar for developers > learn a
specification format.
Flexibility
Refactor code > Refactor yaml spec
Less Emphasis on Design
Tool Limitations
OpenAPI state of the art : mostly in dynamic languages
No Go code-first framework?
We should create one!
- Strong static typing
- Good performance
- Error as values
- Simplicity
❓
Introducing Fuego 🔥
100% accurate OpenAPI generation in Go
Using latest features of the Go programming
language (generics, built-in router…)
Fuego 🔥 features
Compatible with Go std lib (no lock-in) : Use any http.Handler middleware or handler! Fuego
also supports log/slog, context and html/template.
Serialization/Deserialization: Fuego automatically serializes and deserializes JSON, XML and
HTML Forms based on user-provided structs (or not, if you want to do it yourself)
Validation: simple validator based on go-playground/validator
Transformation: easily transform your data by implementing the fuego.InTransform and
fuego.OutTransform interfaces - also useful for custom validation
Error handling: Centralized error handling with the standard RFC 9457.
Rendering / content-negociation : Simple and fast rendering system based on
html/template - you can still also use your own template system like templ or gomponents
Introducing Fuego 🔥
Introducing Fuego 🔥
Integrating Fuego 🔥 in your workflow
Start-time Generation: never get out-of-date: when the server starts,
the documentation is updated
Expose the running API in non-prod envs
Opt-in On-demand generation: generate without
starting the server
Golden file target
Oasdiff - see the difference between the old spec
and the new one in HTML
LOCAL
ACROSS TEAMS
Demo Fuego 🔥
Fuego 🔥 Demo
What Open-Source brought us
- Sharing a minimal working version does not stop a
project from being exposed under the spotlight
- Project hype & fun : 900+ stars, 25 contributors, a lot of
kind comments & issues to improve the framework:
community is awesome
- Known in our company for being the Open-Source guys
- Talks & meetups! Don’t be shy, it works
Fuego: an OpenAPI framework
Thanks!
Ewen QUIMERC’H Edouard LACOURT
go-fuego/fuego

apidays Paris 2024 - Generate OpenAPI Schema from Golang Code with the Fuego Framework, Ew

  • 1.
    Fuego: an OpenAPIframework Ewen QUIMERC’H Edouard LACOURT go-fuego/fuego
  • 2.
  • 3.
    A major issueworking with APIs API Consumers (front, other APIs, mobile app…) How can consumers and API systems exchange information seamlessly? GET data Bad request Route does not exist 500 errors
  • 4.
    OpenAPI! REST API APIusers Fully detailed interface contract json/yaml description
  • 5.
    OpenAPI: the goodis the ugly … but it’s unreadable & unmaintainable for humans 🤢 Everything is declared & standardised … ❤️ =
  • 6.
    Swagger UI asinteractive documentation 🤩
  • 7.
    Swagger UI, theOpenAPI for humans REST API Machines Humans Raw JSON/YAML spec Swagger Browser Client Generators ❓
  • 8.
    Server-side OpenAPI stateof the art 1. Generate OpenAPI spec from source code 2. Generate server code from existing OpenAPI spec Server code boilerplate interfaces
  • 9.
    Code-first : betterthan Doc-first? Faster Prototyping Code agility > Specification burden Ease of Use Code familiar for developers > learn a specification format. Flexibility Refactor code > Refactor yaml spec Less Emphasis on Design Tool Limitations
  • 10.
    OpenAPI state ofthe art : mostly in dynamic languages No Go code-first framework? We should create one! - Strong static typing - Good performance - Error as values - Simplicity ❓
  • 11.
    Introducing Fuego 🔥 100%accurate OpenAPI generation in Go Using latest features of the Go programming language (generics, built-in router…)
  • 12.
    Fuego 🔥 features Compatiblewith Go std lib (no lock-in) : Use any http.Handler middleware or handler! Fuego also supports log/slog, context and html/template. Serialization/Deserialization: Fuego automatically serializes and deserializes JSON, XML and HTML Forms based on user-provided structs (or not, if you want to do it yourself) Validation: simple validator based on go-playground/validator Transformation: easily transform your data by implementing the fuego.InTransform and fuego.OutTransform interfaces - also useful for custom validation Error handling: Centralized error handling with the standard RFC 9457. Rendering / content-negociation : Simple and fast rendering system based on html/template - you can still also use your own template system like templ or gomponents
  • 13.
  • 14.
  • 15.
    Integrating Fuego 🔥in your workflow Start-time Generation: never get out-of-date: when the server starts, the documentation is updated Expose the running API in non-prod envs Opt-in On-demand generation: generate without starting the server Golden file target Oasdiff - see the difference between the old spec and the new one in HTML LOCAL ACROSS TEAMS
  • 16.
  • 17.
    What Open-Source broughtus - Sharing a minimal working version does not stop a project from being exposed under the spotlight - Project hype & fun : 900+ stars, 25 contributors, a lot of kind comments & issues to improve the framework: community is awesome - Known in our company for being the Open-Source guys - Talks & meetups! Don’t be shy, it works
  • 18.
    Fuego: an OpenAPIframework Thanks! Ewen QUIMERC’H Edouard LACOURT go-fuego/fuego

Editor's Notes

  • #2 Next slide: A theodo on fait des api / des front et on a des problème de communication et donc pour y répondre on se met d’accord avec un langugae commun : open api
  • #7 Spec precis / verbeux
  • #8 Soit via des comms Avantages peu import le router Inconvénients C’est pas typé Ca respecte pas forcément la réalité Soit de la génération depuis oapi-codegen (spec first) C’est ce qui marche le mieux en Go en 2023 Avantages et inconvénients A investiguer Moins flexible ? Pas de (de)serializer donc pas de garantie sur la donnée renvoyée
  • #10 TODO : montrer un exemple de code ouverture : Dans les autres languages les framework sont code first