Open readygo67 opened 2 years ago
I can't reproduce your problem:
My main.go
:
type taskResponse struct {
Id string `json:"id" example:"0x29a97C6EfFB8A411DABc6aDEEfaa84f5067C8bbe"`
}
// @Summary Create a new task
// @Description description_xxx
// @Tags task
// @Router /task/ [post]
// @Accept json
// @Produce json
// @Success 201 {object} taskResponse
// @Failure 400 {string} error
// @Security ApiKeyAuth
func (db *database) createTaskHandler(c *gin.Context) {
...
}
My swagger.yaml
:
definitions:
main.taskResponse:
properties:
id:
example: 0x29a97C6EfFB8A411DABc6aDEEfaa84f5067C8bbe
type: string
type: object
when I try to generate API doc for the following code, the from's example value is displayed in scientific notation. I hope it displayed as string.
Anybody knows how to display the ethereum address as string?
` package main
import "github.com/gin-gonic/gin"
type TransferParam struct { From string
json:"from" example:"0x29a97C6EfFB8A411DABc6aDEEfaa84f5067C8bbe"
To stringjson:"to" example:"0xb064b8b8244414d9ba172e9d9120bcfd70bd8f1a"
Amount stringjson:"amount" example:"1000.12"
Name stringjson:"name" example:"mario"
}// transfer godoc // @Summary transfer native token // @Description transfer native token // @Tags // @Accept json // @Produce json // @Param param body TransferParam false "TransferParam" // @Success 200 // @Router /accounts [get] func transfer(ctx *gin.Context) {
}
`
I think when swaggo convert comments to yaml, it should embrace 0x29a97C6EfFB8A411DABc6aDEEfaa84f5067C8bbe with Quotation marks。