-
Notifications
You must be signed in to change notification settings - Fork 22
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
generated code makeover #81
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8ff18dd
to
f9885b6
Compare
05ae5be
to
ffdf9ce
Compare
ffdf9ce
to
b25480a
Compare
generate check will fail because i don't want to clutter the PR view with the diff from the generated files just yet |
ae17f83
to
c88b2cb
Compare
c88b2cb
to
13023b9
Compare
This was referenced Dec 18, 2023
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a breaking change PR. While the usage of the client library remains the same, we introduce the following breaking changes:
Motivated by Make API values optional #27 and InputVolumeMul doesn't accept
0
volume #60, we make all the API values optional by making every primitive request field a pointer (i.e.*int
,*string
,*bool
). This is because values like0
,""
,false
respectively are all potentially valid values in requests, but if intentionally set they'll just be omitted as every field is tagged withomitempty
. We also simply can't removeomitempty
from our request fields as it'll make them non-optional. The solution is to introduce pointers for these fields as now we can distinguish between present, not present, and intentional zero-value fields. In addition, to ease the UX for this, we introduce a new builder pattern for param structs:We simplify the generation code for complex types (like
Object
andArray<Object>
in the protocol documentation) and try to address any missing types that were once justinterface{}
andmap[string]any
. The only fields that remainmap[string]any
are mostly *Settings ones which are generic enough to meritmap[string]any
.TODO add mapstructure to all response structs so we can have a
Remaining
field in case any fields are missed.actually on second thought idk if this is the right approach. think it would overcomplicate a lot of stuff. the motivation behind this is so that if there's a missing field from one of the response structs, a user can still access it (albeit through a
map[string]any
) without having to wait for me to update the library. maybe instead i can just expose the raw response? the user can then just parse it into amap[string]any
themselvesGetRaw() json.RawMessage
method that returns the bytes it got from the server for that responseChange the types for fields ending in
Id
orIndex
to be ints instead of floats.And of course update the examples and the test generation accordingly to reflect the above.