All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
0.8.0 - 2023-07-10
- Update AJV version to support referenced
discriminator
entries inoneOf
types (see ajv-validator/ajv#1815).
0.7.2 - 2022-09-01
- When an
omitEmitField
option is specified, add that field's name as an accepted keyword to the underlying ajv instance. This will prevent ajv's strict mode from complaining about an unexpected keyword in the schema.
0.7.1 - 2022-08-31
- Fixes inverted negation when supplying an
omitEmitField
option.
0.7.0 - 2022-08-31
- Add support for the
omitEmitField
option in thegenerateCodecCode
method. When specified, schemas having a truthy value in the field indicated by theomitEmitField
value will not be added to the type emit.
0.7.0-0 - 2022-05-20
- Added support for the
externalizeValidatorLibrary
option ingenerateCodecCode
. When a value oftrue
is supplied for this option, the dependency on@ggoodman/typed-validator
will be treated as a runtime dependency.
0.6.1 - 2021-04-08
-
Fixed check for type-level compatibility between the local
ErrorObject
and theajv
equivalent.This was tripping up downstream build tools and so it was moved from the runtime code to the test suite (where it should have been from the beginning).
0.6.0 - 2021-04-08
-
Upgrade to
ajv@8.x
andajv-formats@2.x
.These upgrades dramatically reduce the amount of messy code manipulation needed to preprocess the 'standalone' code produced by ajv. This should make it simpler and less risky to upgrade ajv versions on an ongoing basis.
0.5.0 - 2021-04-08
-
Introduce the
anyType
option for chosing the type to be used for unconstained JSON Schemas, object values and array items.This is useful, for example, if the restrictiveness of the default
"JSONValue"
(designed to represent any valid JSON value) is getting in the way. We introduce the following new options:"any"
- Unconstrained values will be typed asany
."unknown"
- Unconstrained values will be typed asunknown
.
- Bump
json-schema-to-dts
to a version allowing the selection of ananyType
.
-
Export a reference to
ValidationError
as indicated by the generated type definitions.This may be helpful for logic consuming the code produced by this library if it wants to be able to use an
instanceof
check to identifyValidationError
instances. Alternatively, theValidationError.isValidationError
method can be used as a TypeScript type guard to perform a similar check.
0.4.5 - 2021-03-18
- Dropped superfluous
ValidationErrorStatic
interface.
0.4.4 - 2021-03-17
- Re-add missing dev dependencies.
0.4.3 - 2021-03-17
- Dramatic simplification of internals, deletion of a lot of code and dependencies.
0.4.2 - 2021-03-17
- Another attempt to fix the release process.
0.4.1 - 2021-03-17
- Fixed publishing workflow.
0.4.0 - 2021-03-17
-
Added optional for validating the
"format"
keyword for"type": "string"
values.To opt into this feature, set the
validateFormats
option totrue
when compiling your schemas:const { javaScript, schamaPathsToCodecNames, typeDefinitions, } = await generateCodecCode(schemas, { validateFormats: true, });
Format validation code will only be included in the generated JavaScript code when this feature is enabled.
To tweak the behaviour of these format validators, the
ajvFormatsOptions
setting can adjust the runtime behaviour ofajv-formats
. For a description of what options can be tweaked, please see theajv-formats
options documentation. -
Choose between any of Rollup's supported module formats for the generated JavaScript.
Previously,
json-schema-codec-generator
would only produce ESM code, however this may be difficult to run in certain environments. To produce CommonJS code (suitable for running on any Node.js version), you can setmoduleFormat: 'cjs'
.
- BREAKING: The shape of the options accepted by
generateCodecCode
has been changed. The options that were previously exposed at the top level of the options object are now nested within theajvOptions
sub-option.
0.3.2 - 2021-03-16
- Fixed working directory used for call to
npm publish
in release automation.
0.3.1 - 2021-03-16
- Fixed release and CI automation
- Added support for passing a
preferredName
adjacent to the inputschema
to have better control over generated type names. #1
- The
schemas
argument togenerateCodecCode
must now be an array ofSchemaEntry
objects, requiring.uri
and.schema
properties and supporting an optional.preferredName
value. #1