feat: add nullable schema annotation#360
Open
somaz94 wants to merge 1 commit into
Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #360 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 20 20
Lines 2099 2120 +21
=========================================
+ Hits 2099 2120 +21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
Lots of nice changes @somaz94! I'm only seeing this on my phone for now, and want to look at this via a proper computer before I'm willing to review these PRs I'm still on vacay until end of July, but I'll try get hold of a computer to review this before then so we don't waste your will for contributing |
e3d7b2d to
f6a25be
Compare
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.
Closes #248.
Adds a
nullablemeta-keyword that is a shorthand for addingnullto a value's type, so you can write# @schema nullableinstead of repeating the inferred type in# @schema type: [string, null].It is applied after the comment keyword loop, so it merges
nullinto the final type regardless of the order keywords appear in the comment (the keyword map iterates in non-deterministic order). It is idempotent whennullis already present, andnullable: falseis a no-op.Validation:
go test ./...— all packages passgofmt -l pkg/andgo vet ./pkg/— cleanprocessCommentandappendNullTypeboth 100% (table tests for nil / scalar / list / already-null / both keyword orderings /falseopt-out / invalid bool)docs/README.mdupdated with a### Nullablesection + TOC entryNote: item-level
items/nullable(mentioned in #248 as combining with #247) is intentionally left as a follow-up to keep this PR a single reviewable slice.