Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): update dependency ajv to v7 #636

Merged
merged 11 commits into from
Mar 5, 2021
Merged

Conversation

renovate[bot]
Copy link
Contributor

@renovate renovate bot commented Jan 29, 2021

THIS IS A BREAKING CHANGE

As I pointed out at 38a07a0, this is a breaking change because this changes dataPath and message in an error object.

WhiteSource Renovate

This PR contains the following updates:

Package Change Age Adoption Passing Confidence
ajv ^6.12.6 -> ^7.1.1 age adoption passing confidence

Release Notes

ajv-validator/ajv

v7.1.1

Compare Source

Support readonly arrays with JSONSchemaType (@​LinusU, #​1447)

v7.1.0

Compare Source

Support for JSON Type Definition RFC 8927 - a simple schema language provided as an alternative to JSON Schema.

See these docs:

Allow ":" in keyword names (#​1421, @​teq0)

v7.0.4

Compare Source

Fix: duplicate functions in standalone validation code with mutually recursive schemas (#​1361)
Fix: reference resolution when base URI change was not applied (#​1414)

v7.0.3

Compare Source

Fixes:

Docs:

v7.0.2

Compare Source

Remove duplicate functions from standalone validation code (#​1361)

v7.0.1

Compare Source

Update error message for maxLength/minLength keywords

v7.0.0

Compare Source

Please note: this document covers the changes from v6.12.6.

The main changes
  • support of JSON Schema draft-2019-09 features: unevaluatedProperties and unevaluatedItems, dynamic recursive references and other additional keywords.
  • comprehensive support for standalone validation code - compiling one or multiple schemas to standalone modules with one or multiple exports.
  • to reduce the mistakes in JSON schemas and unexpected validation results, strict mode is added - it prohibits ignored or ambiguous JSON Schema elements. See Strict mode and Options for more details
  • to make code injection from untrusted schemas impossible, code generation is fully re-written to be type-level safe against code injection.
  • to simplify Ajv extensions, the new keyword API that is used by pre-defined keywords is available to user-defined keywords - it is much easier to define any keywords now, especially with subschemas.
  • schemas are compiled to ES6 code (ES5 code generation is supported with an option).
  • to improve reliability and maintainability the code is migrated to TypeScript.
  • separate Ajv classes from draft-07 and draft-2019-09 support with different default imports (see Getting started or v7.0.0-beta.5 for the details).

Please note:

  • the support for JSON-Schema draft-04 is removed - if you have schemas using "id" attributes you have to replace them with "\$id" (or continue using version 6 that will be supported until 02/28/2021).
  • all formats are separated to ajv-formats package - they have to be explicitly added if you use them.
  • Ajv instance can only be created with new keyword, as Ajv is now ES6 class.
  • browser bundles are automatically published to ajv-dist package (but still available on cdnjs.com).
  • order of schema keyword validation changed - keywords that apply to all types (allOf etc.) are now validated first, before the keywords that apply to specific data types. You can still define custom keywords that apply to all types AND are validated after type-specific keywords using option post: true in keyword definition.
  • regular expressions in keywords "pattern" and "patternProperties" are now used as if they had unicode "u" flag, as required by JSON Schema specification - it means that some regular expressions that were valid with Ajv v6 are now invalid (and vice versa).
Better TypeScript support:
  • Methods compile and compileAsync now return type-guards - see Getting started.
  • Method validate is a type-guard.
  • Better separation of asynchronous schemas on type level.
  • Type utility JSONSchemaType that generates the type for JSON Schema for type interface in the type parameter - it simplifies writing schemas (no unions support at the moment).
API changes:
  • addVocabulary - NEW method that allows to add an array of keyword definitions.
  • addKeyword - keyword name should be passed as property in definition object, not as the first parameter (old API works with "deprecated" warning). Also "inline" keywords support is removed, code generation keywords can now be defined with "code" keyword - the same definition format that is used by all pre-defined keywords
  • Ajv no longer allows to create the instance without new keyword (it is ES6 class).
Added options (and defaults):
  • strict: true - strict mode
  • strictTypes: "log" - prevent mistakes related to type keywords and keyword applicability (see Strict Types)
  • strictTuples: "log" - prevent incomplete tuple schemas (see Prohibit unconstrained tuples)
  • allowUnionTypes: false - allow multiple non-null types in "type" keyword
  • allowMatchingProperties: false - allow overlap between "properties" and "patternProperties" keywords
  • loopEnum: Infinity - optimise validation of enums, similar to loopRequired
  • validateFormats: true - enable format validation
  • code: {optimize: number|boolean} - control code optimisation
  • code: {es5: true} - generate ES5 code, the default is to generate ES6 code.
  • code: {lines: true} - add line breaks to generated code - simplifies debugging of compiled schemas when you need it
Changed options:
  • keywords - now expects the array of keyword definitions (old API works with "deprecated" warning)
Removed options:
  • errorDataPath - was deprecated, now removed.
  • format - validateFormats: false can be used instead, old format mode can be chosen via ajv-formats package.
  • nullable: nullable keyword is supported by default.
  • jsonPointers: JSONPointers are used to report errors by default, jsPropertySyntax: true (deprecated) can be used if old format is needed.
  • extendRefs: $ref siblings are validated by default (consistent with draft 2019-09), ignoreKeywordsWithRef (deprecated) can be used instead to ignore $ref siblings.
  • missingRefs: now exception is always thrown. Pass empty schema with $id that should be ignored to ajv.addSchema.
  • processCode: replaced with code: {process: (code, schemaEnv: object) => string}.
  • sourceCode: replaced with code: {source: true}.
  • schemaId: removed, as JSON Schema draft-04 is no longer supported.
  • strictDefaults, strictKeywords, strictNumbers: it is default now, controlled with strict.
  • uniqueItems: '"uniqueItems" keyword is always validated.
  • unknownFormats: the same can be achieved by passing true for formats that need to be ignored via ajv.addFormat or formats option.
  • cache and serialize: Map is used as cache, schema object as key.

Renovate configuration

📅 Schedule: "after 9pm,before 9am" in timezone Asia/Tokyo.

🚦 Automerge: Disabled by config. Please merge this manually once you are satisfied.

♻️ Rebasing: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 Ignore: Close this PR and you won't be reminded about these updates again.


  • If you want to rebase/retry this PR, check this box

This PR has been generated by WhiteSource Renovate. View repository job log here.

@renovate renovate bot requested review from a team, koba04 and shintaroNagata and removed request for a team January 29, 2021 13:57
@renovate renovate bot added the renovate label Jan 29, 2021
@renovate renovate bot force-pushed the renovate/ajv-7.x branch from bf080e1 to 8a230c4 Compare January 29, 2021 14:52
@koba04 koba04 self-assigned this Feb 1, 2021
@renovate renovate bot force-pushed the renovate/ajv-7.x branch from 8a230c4 to d3eaeda Compare February 1, 2021 22:13
@koba04
Copy link
Contributor

koba04 commented Feb 2, 2021

I'll update the JSON Schema version from draft4 to draft7 at #652

@renovate renovate bot force-pushed the renovate/ajv-7.x branch from d3eaeda to 8b331ac Compare February 11, 2021 12:54
@renovate renovate bot changed the title fix(deps): update dependency ajv to v7 chore(deps): update dependency ajv to v7 Feb 15, 2021
@renovate renovate bot force-pushed the renovate/ajv-7.x branch 2 times, most recently from 24b9071 to 0d30342 Compare February 17, 2021 13:25
BREAKING CHANGE: The format of dataPath and message in an error object have been changed.
dataPath: .desktop.css[0] -> /desktop/css/0
message: *** is a required property -> *** should have required property 'version'
@koba04
Copy link
Contributor

koba04 commented Feb 22, 2021

@shintaroNagata I've fixed problems to bump ajv to v7 🚀 Could you review this?

@shintaroNagata
Copy link
Contributor

shintaroNagata commented Mar 2, 2021

@koba04
Sorry, I've missed your comment. I will check your work within a few days.

Copy link
Contributor

@shintaroNagata shintaroNagata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@koba04
Thank you for your PR! I've checked your work.
Will you consider to update following 2 files ?

  • packages/plugin-manifest-validator/README.md
  • packages/plugin-manifest-validator/manifest-schema.d.ts

@koba04
Copy link
Contributor

koba04 commented Mar 5, 2021

@shintaroNagata Thank you for your feedback!!! I've updated them.

Copy link
Contributor

@shintaroNagata shintaroNagata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@shintaroNagata shintaroNagata merged commit a5490d5 into master Mar 5, 2021
@shintaroNagata shintaroNagata deleted the renovate/ajv-7.x branch March 5, 2021 14:26
tasshi-me pushed a commit that referenced this pull request Oct 22, 2024
* fix(deps): update dependency ajv to v7

* deps: update yarn.lock

* fix: all tests and lint errors with ajv v7

BREAKING CHANGE: The format of dataPath and message in an error object have been changed.
dataPath: .desktop.css[0] -> /desktop/css/0
message: *** is a required property -> *** should have required property 'version'

* fix: put maxItems in the correct location

* refactor: remove unnecessary code

* refactor: define SchemaValidateFunction locally

* test: add a test for maxItems

* chore: add a note for PR that expose SchemaValidateFunction

* types: regenerate manifest-schema.d.ts

* docs: update an error object format

* docs: update a link to the documentation for validation errors

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: Toru Kobayashi <koba0004@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants