Files
go-omni/examples/contracts
k2safe 7670b222ac feat: release configurable API response contracts
Define reusable response bodies in .api with typed code mappings, per-route overrides and matching OpenAPI schemas. Add application and callback encoders, early response policy selection, and isolated remote-consumer release verification.

Release v0.8.0-preview after full race, vet, build and local MySQL workflow acceptance.
2026-09-23 20:42:38 +08:00
..

接口定义示例

user.api 是入口,导入 shared.api。包含 JSON/path/query/header 混合请求、分页与重复 query 参数、嵌套对象、optional 指针、user 与 admin/user 分组以及 Auth/Audit 命名中间件。

在 go-omni 根目录执行:

go run ./cmd/go-omni api validate --api examples/contracts/user.api
go run ./cmd/go-omni api generate --api examples/contracts/user.api \
  --dir ../userService --module example.com/userService --framework-dir .

项目中补充 internal/service 的业务实现和 internal/middleware 的 Auth/Audit hook,再启动服务。初始占位实现返回 501。

需要立即能返回成功结果的最小项目,用 go-omni api new 创建问候示例。完整语法、目录、更新策略见 API.md。