This project is a plugin for goctl. It's able to generate openapi specification version 3 file from go-ctl api file.
- generate correct schema for any level of embedded structure type.
- generate correct schema for complicated type definition like
map[string][]map[int][]*Author
. - parse parameter constraints from validate tag.
This plugin's version and goctl's version should have the same major and minor version, it's recommended to install the matching version. If versions doesn't match, it may not work properly.
For example, if you use goctl v1.6.3, then you should install this plugin with:
go install github.com/jayvynl/goctl-openapi@v1.6
Help messages.
Usage goctl-openapi:
-filename string
openapi file name, default "openapi.json", "-" will output to stdout.
-format string
serialization format, "json" or "yaml", default "json".
-pretty
pretty print of json.
-version
show version and exit.
Usage example.
goctl api plugin -plugin goctl-openapi -api example.api -dir example
Take the api file from example, the generated openapi file can be visualized by swagger editor.