huma icon indicating copy to clipboard operation
huma copied to clipboard

Panic if adding example tag to body field which is a pointer

Open jonas0616 opened this issue 3 years ago • 0 comments

In order to distinguish between zero value and missing field, pointer is sometimes used in body fields. For example,

type InputBody struct {
    Quota *int64 `json:"quota" example:"1611198330"`
}

However, it throws an exception when adding example tag to the pointer field:

panic: unable to generate JSON schema: unable to convert float64 to *int64: schema is invalid

BTW, it works well when example tag is not added.

jonas0616 avatar Jan 21 '21 03:01 jonas0616