OPEN SWAG GO
Features

Code Snippets

The ready-to-copy request examples (curl, JavaScript, Python, Go and other clients) shown next to each operation are generated by the Scalar UI that docs.Mount serves. They are available automatically; there is nothing to install or configure in Go, and the available languages depend on the Scalar version you load.

What open-swag-go controls

Scalar builds each snippet from the generated openapi.json, so the snippets follow your endpoint definitions:

  • the method and path (router-style :id segments are normalised to {id}, v1.3.0+);
  • the parameters from Parameters, QueryParams and PathParams;
  • the request body content type and its example values from example:"..." tags;
  • the security schemes an endpoint requires (Endpoint.Security);
  • the base URLs from Config.Servers.

UIConfig has no snippet options. Pin the Scalar release with UIConfig.ScalarVersion (v1.3.0+) if you want the snippet languages and formatting to stay the same across upgrades.

Earlier versions of this page documented a Go snippet generator package. It was never used by the docs UI and was removed in v1.3.0. If you need snippets outside the docs page, generate them from openapi.json with any OpenAPI tooling. See the Changelog.