-
Notifications
You must be signed in to change notification settings - Fork 889
feat: Add support for json omitempty and embedded structs in apitypings #1318
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
feat: Add support for json omitempty and embedded structs in apitypings #1318
Conversation
Codecov Report
@@ Coverage Diff @@
## mafredri/feat-paginate-template-versions-endpoint #1318 +/- ##
======================================================================================
- Coverage 66.78% 56.52% -10.26%
======================================================================================
Files 282 152 -130
Lines 18471 16624 -1847
Branches 235 0 -235
======================================================================================
- Hits 12335 9397 -2938
- Misses 4866 6128 +1262
+ Partials 1270 1099 -171
Continue to review full report at Codecov.
|
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.
This looks great, thanks!
04b3b1f
to
13fc406
Compare
Otherwise changes in the apitypings generator are not detected.
ccade36
to
3650ed7
Compare
…1308) * feat: Implement pagination for template versions * feat: Use unified pagination between users and template versions * Sync codepaths between users and template versions * Create requestOption type in codersdk and add test * Fix created_at edge case for pagination cursor in queries * feat: Add support for json omitempty and embedded structs in apitypings (#1318) * Add scripts/apitypings/main.go to Makefile
…1308) * feat: Implement pagination for template versions * feat: Use unified pagination between users and template versions * Sync codepaths between users and template versions * Create requestOption type in codersdk and add test * Fix created_at edge case for pagination cursor in queries * feat: Add support for json omitempty and embedded structs in apitypings (#1318) * Add scripts/apitypings/main.go to Makefile
Note: This PR targets #1308, it is a continuation but I felt it warranted a separate PR.
This PR adds support for the JSON
omitempty
tag (reflected as a TypeScript optional) and embedded structs in thecodersdk
package. The properties of embedded structs now appear directly on the struct that embeds them via TypeScriptinterface .. extends
. This behaves the same way as the Gojson.Marshal
andjson.Unmarshal
do when a struct is embedded (example playground).As discussed in #1308 (comment), the generated typings are not ideal for comfortable use in the frontend, this tries to amend that.
If we don't want the above behavior, the field can either be named or a have
json
tag added.Do these changes seem reasonable/are they helpful @presleyp @BrunoQuaresma?