Skip to content

feat: add nullable schema annotation#360

Open
somaz94 wants to merge 1 commit into
losisin:mainfrom
somaz94:feat/nullable-keyword
Open

feat: add nullable schema annotation#360
somaz94 wants to merge 1 commit into
losisin:mainfrom
somaz94:feat/nullable-keyword

Conversation

@somaz94

@somaz94 somaz94 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Closes #248.

Adds a nullable meta-keyword that is a shorthand for adding null to a value's type, so you can write # @schema nullable instead of repeating the inferred type in # @schema type: [string, null].

nameOverride: "" # @schema nullable
# => "type": ["string", "null"]

replicaCount: # @schema type: integer; nullable
# => "type": ["integer", "null"]

It is applied after the comment keyword loop, so it merges null into the final type regardless of the order keywords appear in the comment (the keyword map iterates in non-deterministic order). It is idempotent when null is already present, and nullable: false is a no-op.

Validation:

  • go test ./... — all packages pass
  • gofmt -l pkg/ and go vet ./pkg/ — clean
  • New code coverage: processComment and appendNullType both 100% (table tests for nil / scalar / list / already-null / both keyword orderings / false opt-out / invalid bool)
  • docs/README.md updated with a ### Nullable section + TOC entry

Note: 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.

@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (ca39afe) to head (f6a25be).

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     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@somaz94 somaz94 marked this pull request as ready for review June 12, 2026 01:14
@somaz94 somaz94 requested review from applejag and losisin as code owners June 12, 2026 01:14
@applejag

Copy link
Copy Markdown
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

@somaz94 somaz94 force-pushed the feat/nullable-keyword branch from e3d7b2d to f6a25be Compare June 17, 2026 01:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add new "meta-keyword" nullable

2 participants