codemirror-json-schema icon indicating copy to clipboard operation
codemirror-json-schema copied to clipboard

Quick changes to support array item validation

Open tbrockman opened this issue 1 year ago • 6 comments

Not sure whether this contribution will be appreciated (and I totally won't be offended if it isn't), but I wanted syntax highlighting on individual (non-object) array items to work (plus to change some linting behavior to mirror VSCode a bit more closer, for ex. missing required properties highlighting the key) and I'd already done a bit of poking around the code to patch away the use of shikijs (my specific use-case makes it a bit less straight-forward to use things which require WASM), and had plans to make changes to autocomplete... so I just figured what the heck, may as well make a fork.

Rather than hoard my changes I thought I'd share them in case they're at all useful to the project. Admittedly, I haven't thoroughly tested them (beyond passing tests), so I'm open to making some edits if it turns out to have been an incorrect approach, but so far it seems to work for my needs.

This PR extends the existing getJsonPointers() code to add support for registering pointers to non-object array items, returning most specific error paths (when possible), and updates existing tests to reflect the changes. It also updates keyFrom and keyTo to be optional, to allow root objects and array elements to not have a key range (which makes sense to me), only a value range.

tbrockman avatar Sep 24 '24 19:09 tbrockman

🦋 Changeset detected

Latest commit: 69e36c638f670d0618be384204e6fc8e13b1a941

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
codemirror-json-schema Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

changeset-bot[bot] avatar Sep 24 '24 19:09 changeset-bot[bot]

Deploy Preview for codemirror-json-schema ready!

Name Link
Latest commit 69e36c638f670d0618be384204e6fc8e13b1a941
Latest deploy log https://app.netlify.com/sites/codemirror-json-schema/deploys/673b7c715d1c8b0008fbe332
Deploy Preview https://deploy-preview-142--codemirror-json-schema.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Sep 24 '24 19:09 netlify[bot]

awesome work, @tbrockman ! I plan to look at this more closely soon, I'm interested in seeing if we need to add any more test cases if you add a changeset, we can add this to the next release!

acao avatar Nov 18 '24 14:11 acao

@acao sounds great, will do when I find some time!

tbrockman avatar Nov 18 '24 16:11 tbrockman

sorry @tbrockman just getting to this now! I will have to be careful about reconciling the changes to pointers

acao avatar Jan 06 '25 19:01 acao

workaround: https://github.com/tkytel/mantela-editor/blob/c6839ee0aa48e81aaf688ff4056b43040d72049b/src/helpers/JsonSchemaLinter.ts

eggplants avatar Oct 05 '25 07:10 eggplants