Help us shape the future of Go! Take the 2026 Go Developer Survey

gen-openapi

command
v0.20.7 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

gen-openapi — 从 idl/*.thrift 生成 OpenAPI 3.0 规范(swagger)。

与 hz 同源同真相:hz 消费 api.* 注解生成 router/handler 桩,本工具消费同一批 注解生成带完整 request/response schema 的 OpenAPI 3.0 规范,输出到 openapi/openapi.json(随仓提交,core 经 go:embed 在 /openapi.json 服务)。

支持的注解(与 hz 语义一致):

  • 方法级: api.get / api.post / api.put / api.delete = "路径"(:param 风格)
  • 字段级: api.path / api.query / api.header → parameters;api.body → JSON 请求体; api.form → multipart 请求体

用法:

go run ./cmd/gen-openapi                # 生成 openapi/openapi.json
go run ./cmd/gen-openapi --check        # 只校验产物与 IDL 同步(CI 用)

Jump to

Keyboard shortcuts

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