<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Codegen on Notes</title>
    <link>http://hugo.gandalfalex.de/tags/codegen/</link>
    <description>Recent content in Codegen on Notes</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 08 Jun 2026 00:00:00 +0000</lastBuildDate>
    <atom:link href="http://hugo.gandalfalex.de/tags/codegen/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>OpenAPI Code Generator</title>
      <link>http://hugo.gandalfalex.de/notes/golang/go_generate/</link>
      <pubDate>Mon, 08 Jun 2026 00:00:00 +0000</pubDate>
      <guid>http://hugo.gandalfalex.de/notes/golang/go_generate/</guid>
      <description>&lt;h2 id=&#34;overview&#34;&gt;Overview&lt;/h2&gt;&#xA;&lt;p&gt;Two generators run in sequence against a single OpenAPI spec:&lt;/p&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;Generator&lt;/th&gt;&#xA;          &lt;th&gt;Owns&lt;/th&gt;&#xA;          &lt;th&gt;Output&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;code&gt;oapi-codegen&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Types, enums, nested structs, optional pointers&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;generated/types.go&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;code&gt;gen/main.go&lt;/code&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Per-tag interfaces, route registration, strict glue&lt;/td&gt;&#xA;          &lt;td&gt;&lt;code&gt;generated/interfaces.go&lt;/code&gt;, &lt;code&gt;routes.go&lt;/code&gt;, &lt;code&gt;routes.go&lt;/code&gt;, &lt;code&gt;requests.go&lt;/code&gt;&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;p&gt;The result is a clean boundary: generated code you never touch, and handler files you fully own.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;prerequisites&#34;&gt;Prerequisites&lt;/h2&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;make install-tools&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Installs &lt;code&gt;oapi-codegen&lt;/code&gt; into &lt;code&gt;$(go env GOPATH)/bin&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;h2 id=&#34;project-layout&#34;&gt;Project layout&lt;/h2&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;spec/&#xA;  api.yaml              ← source of truth, edit this&#xA;&#xA;cfg/&#xA;  types.yaml            ← oapi-codegen config (types only)&#xA;&#xA;gen/&#xA;  main.go               ← custom splitter — generates per-tag interfaces + routes&#xA;&#xA;generated/              ← never edit, safe to delete and rebuild&#xA;  types.go&#xA;  interfaces.go&#xA;  routes.go&#xA;  requests.go           ← strict mode only&#xA;&#xA;server/&#xA;  middleware/           ← hand-written&#xA;  handlers/             ← hand-written, implement generated interfaces&#xA;  server.go             ← wires router + middleware + handlers&#xA;&#xA;Makefile&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;hr&gt;&#xA;&lt;h2 id=&#34;usage&#34;&gt;Usage&lt;/h2&gt;&#xA;&lt;h3 id=&#34;standard-mode&#34;&gt;Standard mode&lt;/h3&gt;&#xA;&lt;p&gt;Handlers receive &lt;code&gt;*gin.Context&lt;/code&gt; directly. Full manual control.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
