- Avoid unnecessary null pointer exception if reference schema is given
- Fix ValidationResults.toString().
- Mark an
additionalProperty
as evaluated. - Export ValidationResults as part of the public API
- Widen range on
http
to include 1.0.0
- Apply pub.dev linting guidelines.
- Add an
JsonSchema.empty({SchemaVersion schemaVersion})
constructor - Update
logging
andcollection
dependencies
- Clean up pubspec, add .pubignore
- Bump minimum Dart SDK version to 2.12.0
- Migration to null safety
- Remove usages of
.slice
to help downstream packages work around a dart2js compiler bug
- Fix bug where
type
getter would throw whentypeList
was null
- Performance:
- cache calls to
resolvePath
JsonSchema.schemaMap
is now truly unmodifiable (was before in practice anyway) andhashCode
is cached by taking advantage of that.
- cache calls to
- 4.0 Release Mistake:
Validator.evaluatedProperties
was accidentally made public, pull it back to private.
json_schema 4.0 continues our journey to support additional new versions of the JSON Schema specification (Draft 2019-09 and Draft 2020-12)! Custom vocabulary and format support is also included in this release! In addition to those major features, we have better support for certain built-in formats, as well as improved spec test compliance.
We have greatly reduced the number of dependencies in preparation for a null-safety release (which we're planning in another major release). This has also come with a new Makefile instead our old dart_dev
based commands (see README).
- Additions:
- Support for JSON Schema Draft 2019-09 (
SchemaVersion.draft2019_09
) - Support for JSON Schema Draft 2020-12 (
SchemaVersion.draft2020_12
) - Default draft is still draft7 for compatibility.
- Custom Keywords:
List<CustomVocabulary> customVocabularies
can be passed to all JsonSchema factories.CustomVocabulary
CustomKeyword
ValidationContext
- Custom Formats:
Map<String, Function> customFormats
can be passed to andJsonSchema
factory.ValidationContext
- Support for JSON Schema Draft 2019-09 (
- Deprecated:
validateWithResults
in favor ofvalidate
which now returns the same thing (ValidationResults
).DefaultValidators
and related globals in favor of passingcustomFormats
to theJsonSchema
factories.
- Removed Deprecations:
- Removed
bin/schemadot.dart
,lib/schema_dot.dart
and related examples - Removed
lib/browser.dart
andlib/vm.dart
and associated globalscreateSchemaFromUrlBrowser
,configureJsonSchemaForBrowser
,globalCreateJsonSchemaFromUrl
createSchemaFromUrlVm
,configureJsonSchemaForVm
andresetGlobalTransportPlatform
. These were for configuring the runtime environment, which now happens automatically. - Removed
JsonSchema.createSchemaAsync
in favor ofJsonSchema.createAsync
- Removed
JsonSchema.createSchema
in favor ofJsonSchema.create
- Removed
JsonSchema.createSchemaFromUrl
in favor ofJsonSchema.createFromUrl
- Removed
RefProvider.asyncSchema
,RefProvider.syncSchema
,RefProvider.asyncJson
, andRefProvider.syncJson
in favor ofRefProvider.async
andRefProvider.async
, which are easier to use. - Removed
JsonSchema.refMap
- Removed
- Breaking change to
validate
:- now returns
ValidationResult
instead ofbool
likevalidateWithResults
(now deprecated).
- now returns
- Notable change of behavior to
resolvePath
with 2019-09 and 2020-12:- When used with draft 2019-09 or draft 2020-12,
$ref
s alongside other keywords, which wasn't allowed in earlier drafts, can't always be resolved. We make a best-effort to resolve authoritatively and fall back to throwing an error if the resolution is ambiguous. In future releases, we may release support for resolving this sort of ambiguity (properties + ref, sub-property of a $ref and as sub-property conflicting, etc) based on user-preference. $dynamicRef
s cannot yet be resolved using this method (you will only receive the ref itself.)
- When used with draft 2019-09 or draft 2020-12,
- Add
Validator.validateWithResults
(This new method gives the most complete and customizable validation results) - Add
JsonSchema.validateWithResults
- Deprecate
JsonSchema.validate
- Deprecate
Validator.validate
- Deprecate
JsonSchema.validateWithErrors
- Deprecate
Validator.errors
- Deprecate
Validator.errorObjects
- Remove the need for separate browser and VM imports
- Deprecate non-json RefProviders
- More specific missing-required property errors
- Removed support for Dart 1
- Add note about root path in error string when instance path is empty
- Expose
ValidationError
class
- Use deep equality to compare maps, fixing equality when enums are present
- New
validateWithErrors
method onJsonSchema
returns all validation errors as a list of objects ValidationError
objects include both instance & schema paths for each error- Error logic tweaked to provide consistent error paths in JSON pointer notation
- json_schema is no longer bound to dart:io and works in the browser!
- Full JSON Schema draft6 compatibility
- Much better $ref resolution, including deep nesting of $refs
- More typed keyword getters for draft6 like
examples
- Synchronous schema evaluation by default
- Optional async evaluation and fetching with
createSchemaAsync
- Automatic parsing of JSON strings passed to
createSchema
andcreateSchemaAsync
- Ability to do custom resolution of $refs with
RefProvider
andRefProviderAsync
- Optional parsing of JSON strings passed to
validate
withparseJson = true
- Dart 2.0 compatibility
- Many small changes to make things more in line with modern dart.
- Please see the migration guide for additional info.
- Code cleanup
- Strong mode
- Switch build tools to dart_dev
- Update dependency constraint on the
args
package.
- Add a dependency on the
args
package.
- Add a dependency on the
logging
package.