/doc

Golang document tools

Primary LanguageGo

A document generator for gin api

package main

import (
	"github.com/cro4k/doc/docer"
	"github.com/gin-gonic/gin"
	"example/annotation"
)

type Request struct {
	Name string `json:"name" doc:"must"`
}

type Response struct {
	Message string `json:"message"`
}

// SayHello
// there is no need to specify url path or http method for a controller, 
// docer will decode them automatically from the gin.Engine.
// @comment SayHello controller
// @req [Request]
// @rsp [Response]
func SayHello(c *gin.Context) {

}

func main() {
	e := gin.Default()
	e.POST("/hello", SayHello)

	// annotation.Elements are auto generated by 'ann build' command
	// before run 'ann build', you should install https://github.com/cro4k/annotation first
	docer.Init(annotation.Elements)
	documents := docer.Decode(e)
    
	//TODO export documents
}