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

Distinction between addVocabulary and addKeyword in the docs #2386

Closed
jauntyjocularjay opened this issue Feb 27, 2024 · 0 comments · Fixed by #2454
Closed

Distinction between addVocabulary and addKeyword in the docs #2386

jauntyjocularjay opened this issue Feb 27, 2024 · 0 comments · Fixed by #2454

Comments

@jauntyjocularjay
Copy link

jauntyjocularjay commented Feb 27, 2024

What version of Ajv you are you using?

8.12.0

What problem do you want to solve?

Confusion when attempting to add keywords to ajv in strict mode. When this is explained in the docs, somebody who is new may not understand the distinction between addVocabulary and addKeyword. For the newb, it may seem like one has to be added one by one, whereas the other allows you to add an entire array of keywords.

By default Ajv fails schema compilation when unknown keywords are used. Users can explicitly define the keywords that should be allowed and ignored:

ajv.addKeyword("allowedKeyword")

or

ajv.addVocabulary(["allowed1", "allowed2"])

Making this distinction more clear can avoid needless frustration and make ajv more friendly to users.

What do you think is the correct solution to problem?

I would add:

By default Ajv fails schema compilation when unknown keywords are used. Users can explicitly define the keywords that should be allowed and ignored:

ajv.addVocabulary(["allowed1", "allowed2"]) // to add from ajv.keywords library

or

ajv.addKeyword("allowedKeyword") // to add a user-defined keyword

For more information on vocabulary that can be added to ajv, refer to ajv.keywords.

Will you be able to implement it?

No, the link in github is dead
But I could, it is just a quick change to HTML or Markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

1 participant