Giter Site home page Giter Site logo

Comments (8)

acao avatar acao commented on June 6, 2024 2

@alyjak @SilverDY 0.5.1 is the fix release! sorry for the delay

from codemirror-json-schema.

acao avatar acao commented on June 6, 2024 1

Here it is working for the n index of an object definition!
image

The only missing feature of this parser fix is, the parser only returns an array index pointer if it's an object. so an array like [{ foo: 1 }] works, but a validation error with foo: [1,2,null] does not return an array index to match the error that #/foo/2 should be an integer for example. so yay I've fixed this bug, but found more bugs 😆

from codemirror-json-schema.

imolorhe avatar imolorhe commented on June 6, 2024 1

do you agree that we should be including each array item in the parsed pointer map? this way, we can target specific array items for errors like these?

Yeah this sounds good to me!

from codemirror-json-schema.

SilverDY avatar SilverDY commented on June 6, 2024 1

@acao thank you so much for that!

from codemirror-json-schema.

acao avatar acao commented on June 6, 2024

It is not expected behavior. Required properties work in some cases but not all.

to note, @types/json-schema is a type library, so it is not present at runtime. this is true of any library prefixed with @types or any typescript - when typescript is transpiled for browser compilation with bundlers, all the type annotation and type imports are removed.

the library that takes care of validation logic is json-schema-library, so we will need to report this bug to them!

our validation tests don't cover everything because it's bad practice to test the features of external libraries in unit testing, and if they fail, there's nothing we can do about it except open a PR to json-schema-library and ask them to fix the bug. the vast amount of the business logic for our library is autocomplete, however for validation and hover we just provide a thin presentation layer for json-schema-library results

can you supply an example of the schema that isn't working?

from codemirror-json-schema.

SilverDY avatar SilverDY commented on June 6, 2024

I am facing the same problem.

{
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "$id": "https://example.com/product.schema.json",
    "properties": {
        "ex": {
            "type": "number"
        },
        "in": {
            "type": "number"
        }
    },
    "required": [
        "ex",
        "in"
    ],
    "additionalProperties": false
}

required doesn't work in any case.

from codemirror-json-schema.

acao avatar acao commented on June 6, 2024

Ok so I took a break from covid to check this out, and you're correct, it is indeed a bug with how we are generating the pointers from json-schema-library, and thus it is something we should test for!

I hope to have a patch fix released before the weekend

from codemirror-json-schema.

acao avatar acao commented on June 6, 2024

asking my collaborator @imolorhe - do you agree that we should be including each array item in the parsed pointer map? this way, we can target specific array items for errors like these?
image

update: The answer appears to be yes? I found a way to get the parser to handle this case, but the change breaks the autocomplete because the autocomplete doesn't expect the parser to have these pointers.

Otherwise, it restores error messages for required fields both at the root and in nested/declaration cases, at the cost of autocomplete. This will take a little while!

from codemirror-json-schema.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.