-
-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: properly (un)marshal custom time type #4
Conversation
Hello @jpmcb, |
Nice work tracking this down. I'm sure there are alot of sharp edges within the Go API client since it's being auto-generated out of the open-sauced/api repo via the swagger doc. We should probably investigate if this is possible to fix in the upstream API swagger doc, which then lands in this generated API client code, instead of dropping a patch here directly in the client code (unless absolutely necessary). Although, it's not immediately clear to me how we should go about doing this since rolling the client already takes abit of hand rolling and we don't want to get bogged down with reinventing alot of tech to accurately represent the API. Any ideas @cecobask ? Let me take a deep dive on this and see if anything comes up in some investigation. |
dt.Time = time.Time{} | ||
return nil | ||
} | ||
parsedTime, err := time.Parse(time.DateOnly, s) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't using only time.DateOnly
pretty rigid? Right now I believe we only use this for PR "days" but in the future, if we use other "date-time" formats, which should follow the very general internet date/time format, this will force any date-time
to always just be "days"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parsing that I implemented doesn't account for time. I should have renamed the type to Date
here.
If we go forward with the patching, I think it might be better to have 2 separate struct types - Date
& DateTime
.
Generating the swagger file based on this entity src/pull-requests/entities/pull-request-insight.entity.ts results in:
Afterward, when generating the go client, based on the swagger file that was previously generated results in:
This is when the need for a custom type I think it will be better if we define the
After this is done, I could come up with two options:
@jpmcb, let me know what you think is best here. I can implement these changes once I receive a confirmation 👍🏻 |
Great deep dive on this. The original patch in the API was intended to align the TypeSciprt types with the Swagger decorates so that we could consume the swagger doc as a client generator.
And yes, you're right, because the swagger generator didn't intelligently convert the
That's probably more agnostic in the end anyways instead of trying to wrangle the go client bits to have aligned types with what's generated by the swagger doc. Again, thanks so much for the deep dive on this, really really helpful as we iron out the kinks and the process with how the client gets generated. If you want to take a stab at this, go for it! Let me know what other sharp edges you hit so we can iterate on the client generation. |
Closing in favor of #5. |
Description
This PR fixes the bug #3.
I tested this change locally by adding a replace directive to the
go.mod
file on my feature branch:What type of PR is this? (check all applicable)
Related Tickets & Documents
Fixes #3.
Relates to: open-sauced/pizza-cli#38
Added tests?
Added to documentation?
Are there any post-deployment tasks we need to perform?
Release a new version of the
go-api
client.