swaggo / gin-swagger

gin middleware to automatically generate RESTful API documentation with Swagger 2.0.
MIT License
3.66k stars 266 forks source link

If the field of the struct does not have a json tag, gin returns uppercase, but the document generates lowercase. #303

Open leavest opened 1 month ago

leavest commented 1 month ago

If the field of the struct does not have a json tag, gin returns uppercase, but the document generates lowercase. for example define struct

type User struct {
    Name1 string `json:"name1"`
    Name2 string `json:"Name2"`
    Name3 string
}

//  @Success        200 {object}    User

Generated document image

    c.JSON(http.StatusOK, User{Name1: "name1", Name2: "name2", Name3: "name3"})

But actually image