Unsupported time.Time (json.Marshaler/Unmarshaler?)
toqueteos opened this issue · comments
Good morning!
Yesterday evening I was giving oto a try and found that time.Time
is not supported which made me think it was because I was on Windows at that time.
I just tried on Ubuntu with the same result:
parse input object type: parse type: parse type: /usr/local/go/src/time/time.go:139:2: wall must be exported
Which led me to think oto is not checking if a type satifies json.Marshaler and/or json.Unmarshaler.
Is this something that I should solve in my template?
Here's my sample definition:
package definition
import "time"
type ThingService interface {
CreateThing(CreateThingRequest) CreateThingResponse
}
type CreateThingRequest struct {
Thing Thing
}
type CreateThingResponse struct {
Result bool
}
type Thing struct {
ID int64
OwnerID int64
Type string
Props map[string]interface{}
Created time.Time
Enabled bool
}
I know I could fix this by using a string
as type for Created
instead but this feels weird as time.Time
is supported by encoding/json
.
We usually in our APIs explicitly convert dates and times, to a string
or to an int
depending on the case.
Is not as much as it is supported in Go, is how easy is to make a template for another language or client
Ok I'll deal with this on my side then.