Giter VIP home page Giter VIP logo

Comments (3)

tdegrunt avatar tdegrunt commented on May 12, 2024

Hi Chris,

Do you have an example of these messages, that would probably help in me answering the question.
Nonetheless jsonschema, like xmlschema, is about enforcing a strict format on your json.

So, it could be that different schemas are needed, but lets wait with that conclusion until I see some examples :)

Cheers,
Tom

from jsonschema.

chrisdew avatar chrisdew commented on May 12, 2024

Thanks for taking the time to reply.

I had wrongly given you the impression that I wanted to be lax about validation, whereas what I want is all the schemas to be in one file, with the appropriate schemas to be used by the appropriate parts of the application.

There are 3 types of JSON document in my application, each of which needs to validate against a different schema.

These three schemas share 90% of their definitions.

I would like to put these three schemas (and the definitions) in one .json file and validate each type of document against a specific schema from the file. I'm under the impression that a file can contain only one schema, so I wrote "definition from a schema" instead.

Currently I am trying three separate schema .json files and one .json file containing all the definitions, but this seems like an ugly solution.

Is this the only way to achieve the sharing of definition between schemas?

P.S. I'm not sure that "definitions" is a special word in JSON Schema, I'm just using it as per: "The entry schema - adding constraints" http://json-schema.org/example2.html

{
    "id": "http://some.site.somewhere/entry-schema#",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "description": "schema for an fstab entry",
    "type": "object",
    "required": [ "storage" ],
    "properties": {
        "storage": {
            "type": "object",
            "oneOf": [
                { "$ref": "#/definitions/diskDevice" },
                { "$ref": "#/definitions/diskUUID" },
                { "$ref": "#/definitions/nfs" },
                { "$ref": "#/definitions/tmpfs" }
            ]
        }
    },
    "definitions": {
        "diskDevice": {},
        "diskUUID": {},
        "nfs": {},
        "tmpfs": {}
    }
}

from jsonschema.

chrisdew avatar chrisdew commented on May 12, 2024

I found what I needed in the API section for tv4 - does jsonschema do a similar thing?

tv4.addSchema() and tv4.getSchema(...#subschemas_id')

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.