Our great sponsors
-
openapi-generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
-
kin-openapi
OpenAPI 3.0 (and Swagger v2) implementation for Go (parsing, converting, validation, and more)
-
swagger-petstore
swagger-codegen contains a template-driven engine to generate documentation, API clients and server stubs in different languages by parsing your OpenAPI / Swagger definition.
-
goa
🌟 Goa: Elevate Go API development! 🚀 Streamlined design, automatic code generation, and seamless HTTP/gRPC support. ✨
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
Then define the corresponding YAML/JSON specification (again manually) either using Swagger 2.0 (with go-swagger) or OpenAPI 3 (with kin-openapi), and
I had a play with this approach a couple of months ago. The goal was to come up with a workflow built around the https://openapi-generator.tech (https://github.com/OpenAPITools/openapi-generator) OpenAPI code generator which would enable a swagger/OpenAPI spec doc to be iterated upon and for changes to the spec doc to result in automated updates to generated GO server code.
Then define the corresponding YAML/JSON specification (again manually) either using Swagger 2.0 (with go-swagger) or OpenAPI 3 (with kin-openapi), and
Finally, if you need to generate clients, use the corresponding generate -like tools, go-swagger uses swagger generate, and for OpenAPI 3 you could use oapi-codegen.
I ended up with https://github.com/jjssoftware/go-user-api which uses an automated github workflow and it did work.
Not specific to Go, but included, there are two main code generators: Swagger codegen (the private company project) and OpenAPI codegen (the opensource, community driven project)
I am using https://goa.design/ for two smaller projects. It generate server backend code and OpenAPI spec. And I use this OpenAPI spec for generate dart client code.
I've tried go-swagger comments to instrument existing code, but wasn't quite satisfied due to magical nature and error friendliness of those comments. So I decided to implement first-class OpenAPI generation on top of self-documenting action handlers: https://github.com/swaggest/rest/blob/master/_examples/basic/main.go. Schemas are generated from request and response structures using reflection and field tags.