Skip to content

jayvynl/goctl-openapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goctl-openapi

This project is a plugin for goctl. It's able to generate openapi specification version 3 file from go-ctl api file.

Features

  • 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.

Install

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/[email protected]

Usage

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.