Repository navigation
v0.26.0
The fork's second stable release, from the same commit as v0.26.0-rc.3.
Compared with v0.25.0, the generated code checks more of what a schema declares, and the generator reports more of what it does not check. The README lists every difference from upstream.
New in the generated code:
- Each primitive-union wrapper has a constructor per kind it holds, such as
NewFooString(v),NewFooDateTime(v)orNewFooNull(), so code outside the generated package can build one without decoding JSON. - A field or type whose schema sets
deprecatedhas aDeprecated:paragraph in its doc comment, which gopls and staticcheck report wherever it is used. A string in place oftrue, as schemas generated from TypeScript give it, is the paragraph's text.
New checks, which reject input that v0.25.0 accepted:
- A
oneOforanyOfwhose branches only listrequired, such asoneOf: [{required: [value]}, {required: [ref]}], needs exactly one, or at least one, of those property sets present. Such ananyOfno longer declares a map type per branch. - A conditional discriminator, an
if/then/elsekeyed on one property'sconstorenum, now also compiles:- when the property is optional and every
ifrequires it, so that its absence applies eachelse; - with a
notofrequiredin athenorelse, which forbids properties; - on the object itself, not only in an
allOf; - on a property declared through a
$ref, such as to a shared enum.
- when the property is optional and every
- A
nullpasses these checks, as it passesrequired.
New warnings:
- A
oneOfbranch whose$refcannot be resolved is reported with the reason, as one in ananyOforallOfis. Before, a missing file or a failed fetch could leave a near-empty file without a word. - A
oneOfthat falls back to a map is reported, and so is a conditional where no validator attaches (an enum, aoneOfholder, the elements of a declared array, the values ofadditionalProperties), instead of being dropped silently.
Built with Go 1.26.10. Go 1.25, which built v0.25.0, no longer gets security fixes, and govulncheck found 14 vulnerabilities of its standard library that the generator reaches, mostly through the fetching of remote $refs. Every release is now checked with govulncheck before it is published. The module itself still builds with Go 1.25.
Install with go install github.com/plheide/go-jsonschema@v0.26.0, from the assets below, or as the plheide/go-jsonschema or ghcr.io/plheide/go-jsonschema image.
The fork is a staging area for work offered upstream. FORK.md lists what isn't offered yet.
Changelog
- 4189846 Merge pull request #56 from plheide/ci/release-changelog-history
- 6506d74 Merge pull request #57 from plheide/api/wrapper-constructors
- 6694b09 Merge pull request #58 from plheide/fix/rc2-refs-and-presence
- bfc404c Merge pull request #59 from plheide/fix/rc3-bare-conditional
- cdde833 Merge pull request #60 from plheide/ci/go-1.26-toolchain
- 2feeb50 ci(fork): check out full history for releases, so the changelog is complete
- 7c666ab ci: build with Go 1.26.10, whose standard library is still supported
- b85762d ci: check for vulnerabilities before a release, and weekly on main
- aef93d3 docs(fork): list the constructors and Deprecated: paragraphs as fork changes
- 4681d55 docs(fork): list the rc.7 to v0.25.0 changes that wait for upstream review
- 34b1cb7 feat: check a oneOf or anyOf of required-only branches as a presence count
- 8e6f84d feat: compile an object's own if/then/else, and a $ref'd discriminator
- 084b12b feat: compile an optional discriminator and a not of required in conditionals
- 24fbd41 feat: give each primitive-union wrapper a constructor per kind
- 5eb3dcc feat: mark a deprecated field or type as Deprecated in its doc comment
- 180b7f2 fix: report a oneOf whose $ref leads nowhere, or that is left as a map