Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Add post 'Get started with JSON Schema in Node.js' #9

Merged
merged 10 commits into from
May 16, 2022
Merged

Add post 'Get started with JSON Schema in Node.js' #9

merged 10 commits into from
May 16, 2022

Conversation

simonplend
Copy link
Contributor

@simonplend simonplend commented Mar 13, 2022

I haven't rewritten the introduction as I think it's still appropriate in this context.

Follow-up tasks:

  • Note on schema generation vs scaffolding
  • Replace image
  • A paragraph or two on Ajv's strict mode

- Author avatar
- Article cover image
The documentation page that was previously linked to doesn't
provide any reference to installation. The page we're now
linking to includes installation instructions and links to
the CLI documentation.
Copy link
Member

@Relequestual Relequestual left a comment

Choose a reason for hiding this comment

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

I've left a few suggestions.

It would be great if you could mention, at least at the end, which version of AJV you're using here.

I'd also like to just see a touch on what AJVs safe mode is, and how and why you would want to disable it.

Not to say that AJVs safe mode doesn't provide some good defaults, such as https://ajv.js.org/strict-mode.html#unconstrained-tuples, but it can easily prevent valid schemas from being allowed to run. It's a "gotcha" we are sometimes seeing.

I'd also like to change the header image. I really like https://unsplash.com/photos/a8YV2C3yBMk
I think it's good symbolism of getting started, not too difficult, but lots of potential.
(Happy to make that change if you've enabled edit by maintainers on your branch)

@simonplend
Copy link
Contributor Author

It would be great if you could mention, at least at the end, which version of AJV you're using here.

No problem.

I'd also like to just see a touch on what AJVs safe mode is, and how and why you would want to disable it.

Not to say that AJVs safe mode doesn't provide some good defaults, such as https://ajv.js.org/strict-mode.html#unconstrained-tuples, but it can easily prevent valid schemas from being allowed to run. It's a "gotcha" we are sometimes seeing.

I'm happy to add a paragraph or two on Ajv's strict mode. I haven't run into any issues myself though, so haven't had the need to adjust the strict defaults — could you give me an example of a valid schema that it would prevent from running?

I'd also like to change the header image. I really like https://unsplash.com/photos/a8YV2C3yBMk I think it's good symbolism of getting started, not too difficult, but lots of potential. (Happy to make that change if you've enabled edit by maintainers on your branch)

Go for it! (edits by maintainers are enabled on this branch)

@Relequestual
Copy link
Member

could you give me an example of a valid schema that it would prevent from running?

Yeah sure. There are a few in the docs, but a specific example is adding any additional keywords which aren't part of the spec.

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

So a JSON Schema of { "type": "boolean", "myComment": "foobar a boolean" } would be blocked by AJV unless the user specifically either disables strict mode or specifies additional allowable keywords. This is problematic if you don't control the schemas.

It's mostly, I want people to be aware that, if their schema is blocked from being used by AJV, it might be because of strict mode, which is a limitation enabled by default, and not part of the JSON Schema specification.

@Relequestual
Copy link
Member

In a direct message discussiong, Simon agreed it was OK for me to make an editorial comment on AJVs safe mode before publishing.

@Relequestual Relequestual merged commit 031f830 into json-schema-org:main May 16, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants