Skip to content

v0.26.0

Choose a tag to compare

@github-actions github-actions released this 26 Oct 07:04
· 93 commits to main since this release
cdde833

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) or NewFooNull(), so code outside the generated package can build one without decoding JSON.
  • A field or type whose schema sets deprecated has a Deprecated: paragraph in its doc comment, which gopls and staticcheck report wherever it is used. A string in place of true, as schemas generated from TypeScript give it, is the paragraph's text.

New checks, which reject input that v0.25.0 accepted:

  • A oneOf or anyOf whose branches only list required, such as oneOf: [{required: [value]}, {required: [ref]}], needs exactly one, or at least one, of those property sets present. Such an anyOf no longer declares a map type per branch.
  • A conditional discriminator, an if/then/else keyed on one property's const or enum, now also compiles:
    • when the property is optional and every if requires it, so that its absence applies each else;
    • with a not of required in a then or else, 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.
  • A null passes these checks, as it passes required.

New warnings:

  • A oneOf branch whose $ref cannot be resolved is reported with the reason, as one in an anyOf or allOf is. Before, a missing file or a failed fetch could leave a near-empty file without a word.
  • A oneOf that falls back to a map is reported, and so is a conditional where no validator attaches (an enum, a oneOf holder, the elements of a declared array, the values of additionalProperties), 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