Giter Club home page Giter Club logo

Comments (7)

santhosh-tekuri avatar santhosh-tekuri commented on May 28, 2024

Compiler.ExtractAnnotations must be set to true to read those

from jsonschema.

naivary avatar naivary commented on May 28, 2024

Thank you! I dont know if it is documented anywhere but I think it should be for clarification. Is it wanted that a readOnly attribute can still be provided via json which means the validation is still true?

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on May 28, 2024

List of annotations https://json-schema.org/understanding-json-schema/reference/annotations

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on May 28, 2024

Annotation keywords has no impact on validation

from jsonschema.

naivary avatar naivary commented on May 28, 2024

Alright. Thank you. Currently I'm implementing an API and would like to validate the given input JSON data. For exmaple that an application is not allowed to overwrite the id or set the id. Any idea how to implement it using readOnly?

from jsonschema.

santhosh-tekuri avatar santhosh-tekuri commented on May 28, 2024

you can think of readOnly as javadoc in java program. the compiler ignores the java doc. whereas java doc tool used them to generate html documentation. similarly jsonschema validator ignores those keywords, where as some editors might use those as hints while editing json.

what you are trying to achieve is not possible using readOnly. But you can try the following:

following schema does not allow to set id:

{
    "properties": {
        "id": false
    }
}

following schema allows either id is not set or id has a specific value say 1234:

{
    "properties": {
        "id": {
            "constant": 1234
        }
    }
}

from jsonschema.

naivary avatar naivary commented on May 28, 2024

Thank you! Solved the issue for me.

from jsonschema.

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.