spec-first

command
v2.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

README

Spec-first example

This example shows a minimal spec-first workflow:

  • Define the OpenAPI source of truth in openapi.json.
  • Generate handler skeletons + error types.
  • Implement handlers and wire middleware.

Generate the skeletons:

go generate ./...

Files of interest:

  • openapi.json: source of truth.
  • spec_gen.go: generated routes/constants/handlers/errors.
  • main.go: wiring with OpenAPI request + response validation.
  • handlers.go: handler implementations.

Notes:

  • The generator emits StatusError types for non-2xx responses.
  • Response validation is enabled to catch mismatched handler output in dev/test.

Documentation

Overview

Code generated by spec-first example; DO NOT EDIT.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL