feat: Add support for json omitempty and embedded structs in apitypings#1318
Merged
mafredri merged 6 commits intoMay 10, 2022
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.
|
presleyp
approved these changes
May 6, 2022
Contributor
presleyp
left a comment
There was a problem hiding this comment.
This looks great, thanks!
coadler
approved these changes
May 6, 2022
deansheather
approved these changes
May 6, 2022
04b3b1f to
13fc406
Compare
Otherwise changes in the apitypings generator are not detected.
ccade36 to
3650ed7
Compare
mafredri
added a commit
that referenced
this pull request
May 10, 2022
…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
kylecarbs
pushed a commit
that referenced
this pull request
Jun 10, 2022
…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
This file contains hidden or 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
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.
Note: This PR targets #1308, it is a continuation but I felt it warranted a separate PR.
This PR adds support for the JSON
omitemptytag (reflected as a TypeScript optional) and embedded structs in thecodersdkpackage. 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.Marshalandjson.Unmarshaldo 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
jsontag added.Do these changes seem reasonable/are they helpful @presleyp @BrunoQuaresma?