diff --git a/openapi/generator_test.go b/openapi/generator_test.go index 072577f..314ddd3 100644 --- a/openapi/generator_test.go +++ b/openapi/generator_test.go @@ -741,12 +741,10 @@ func (c customUnit) ParseExample(v string) (interface{}, error) { return fmt.Sprintf("%s USD", v), nil } -type customTime struct { - time.Time -} +type customTime time.Time func (c customTime) String() string { - return c.Format("2006-01-02T15:04:05") + return time.Time(c).Format("2006-01-02T15:04:05") } func (c customTime) ParseExample(v string) (interface{}, error) { @@ -754,7 +752,7 @@ func (c customTime) ParseExample(v string) (interface{}, error) { if err != nil { return nil, err } - return customTime{t1}, nil + return customTime(t1), nil } // TestGenerator_parseExampleValue tests the parsing of example values. @@ -913,13 +911,13 @@ func TestGenerator_parseExampleValue(t *testing.T) { "mapping to customTime", reflect.TypeOf(customTime{}), "2022-02-07T18:00:00+09:00", - customTime{time.Date(2022, time.February, 7, 18, 0, 0, 0, time.FixedZone("", 9*3600))}, + customTime(time.Date(2022, time.February, 7, 18, 0, 0, 0, time.FixedZone("", 9*3600))), }, { "mapping pointer to customTime", reflect.PtrTo(reflect.TypeOf(customTime{})), "2022-02-07T18:00:00+09:00", - customTime{time.Date(2022, time.February, 7, 18, 0, 0, 0, time.FixedZone("", 9*3600))}, + customTime(time.Date(2022, time.February, 7, 18, 0, 0, 0, time.FixedZone("", 9*3600))), }, }