8000 GitHub - WaltCuller/swag-yapi: forked from swag
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.

WaltCuller/swag-yapi

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

swag-yapi

forked from swag and developed for yapi feature.

WARNING: This is still in beta stage, use with care!

Features

package main

type People struct {
	Name string `json:"name" mock:"@string(\"lower\",5)"`
	Age int `json:"age" mock:"@integer(0,100)"`
	Birthday string `json:"birthday" mock:"@datetime(\"yyyy-MM-dd A HH:mm:ss\")"`
}
  • upload swagger.json to yapi server.

  • adapt mock.js.

Usage

Installation

  1. To install it, either download a version from the release page, use go install/go get.
go get -u https://github.com/WaltCuller/swag-yapi
  1. Add comments to your API source code. See Declarative Comments Format.

  2. For response struct, swag-yapi use the customize tag: mock. See mock.js

  3. Add toml config to define the yapi server address and configuration.

[swagger]
type = "swagger" # yapi upload type
token = "xxxxx" # yapi token
merge = "normal" # merge type
server = "xxxxxx" # yapi server address
file_path = "docs/swagger/swagger.json" # swagger.json file path
  1. After added comments and tags, run swag-yapi init like swag init in the project's root folder which contains the main.go file. This will parse your comments and generate the require files(docsfolder and docs/docs.go)

  2. use swag-yapi upload with option -c to get the config and upload swagger.json to your yapi server.

Client help

$ swag-yapi -h
NAME:
   swag-yapi - Automatically generate RESTful API documentation with Swagger 2.0 for Go.

USAGE:
   swag-yapi [global options] command [command options] [arguments...]

VERSION:
   v1.7.0_0.0.1

COMMANDS:
   init, i    Create docs.go
   upload, u  upload swagger.json to yapi
   help, h    Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --help, -h     show help (default: false)
   --version, -v  print the version (default: false)

About

forked from swag

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 98.9%
  • Other 1.1%
0