Summary
TokensApiControllerApi.GetAppTokens (and any other endpoint with a time.Time field in the return) fails to decode the JSON epoch time to time.Time as it takes a string. This results in some data being corrupt or lost.
Reproduction
Given an app that has at least two tokens:
package main
import (
"context"
"fmt"
"os"
"github.com/sematext/sematext-api-client-go/stcloud"
)
func main() {
cfg := stcloud.NewConfiguration()
cfg.BasePath = "https://apps.sematext.com"
client := stcloud.NewAPIClient(cfg)
ctx := context.WithValue(context.Background),
stcloud.ContextAPIKey,
stcloud.APIKey{Key: os.Getenv("SEMATEXT_API_KEY"), Prefix: "apiKey"},
)
resp, httpResp, err := client.TokensApiControllerApi.GetAppTokens(ctx, /* appId */)
fmt.Printf("err=%v status=%d tokens %d\n", err, httpResp.StatusCode, len(resp.Data.Tokens))
}
Actual
err=<nil> status=200 tokens=1
Expected
err=<nil> status=200 tokens=2
// Or, if decoding really cannot succeed, err should be not be nil
Bugs
time.Time json unmarshal
stcloud/model_token_dto.go:
type TokenDto struct {
CreatedAt time.Time `json:createdAt,omitempty"`
...
}
The API sends createdAt as a JSON number, not an RFC3339 string. time.Time.UnmarshalJSON only accepts strings. This fails with:
Time.UnmarshalJSON: input is not a JSON string
Summary
TokensApiControllerApi.GetAppTokens(and any other endpoint with a time.Time field in the return) fails to decode the JSON epoch time totime.Timeas it takes a string. This results in some data being corrupt or lost.Reproduction
Given an app that has at least two tokens:
Actual
Expected
Bugs
time.Timejson unmarshalstcloud/model_token_dto.go:The API sends
createdAtas a JSON number, not an RFC3339 string.time.Time.UnmarshalJSONonly accepts strings. This fails with: