Skip to content

Types and naming

  • Names come from operationId (or method + path). A name already taken — the same operationId in two services — gets the method appended (getUser → getUserGet), and a number only if that is taken too (getUserGet2).
  • An operationId that is not a usable function name (delete, default, 2fa) falls back to a name built from the method and position; the same goes for a path argument called in or delete.
  • A schema named like a Go package (handler.LoginBody) becomes HandlerLoginBody, and every $ref follows. A schema named like a global type the generated code uses (Date, Record, …) gets a Model suffix; one that starts with a digit (2FA) gets a leading _.
  • Identical types are written once, without mixing what is different. Query / variable types of a tag are shared when their shapes match, and a close one is derived with Omit<…> & { … }. Of the models, a schema the document names is a contract and never becomes an alias of another; an inline object the generator named reuses an identical model when its shape says something of its own (it names another model, or has three fields) — a bare { id, name } stays separate.
  • Only the imports a module uses are written, so a project may compile with noUnusedLocals.
  • Property names that are not identifiers are quoted; doc comments from the document’s descriptions are kept (and defused if they contain */).