Open larisa-pozhilova opened 9 years ago
i am putting a sample here. Hope this will help you.
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "name": { "$ref": "#/definitions/d_NonZeroLengthString" } }, "definitions": { "d_NonZeroLengthString": { "description": "Non Zero Length String", "type": "string", "minLength": 1 } } }
Hey, thank you for the reply.
I might have been not clear enough, but I already have the whole structure of the JSON schema files.
What I need is to make a flat JSON schema file out of several JSON schemas, one of them has others as #ref.
What I'm asking about is how to do it using this library if it is possible at all?
Thanks, Laura.
Hey Laura,
Below two are equivalent, in which first one has "ref" and second one does not
--------1st------------- { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "name": { "$ref": "#/definitions/d_NonZeroLengthString" } }, "definitions": { "d_NonZeroLengthString": { "description": "Non Zero Length String", "type": "string", "minLength": 1 } } }
---------2nd----equivalent to 1st------------------ { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "name": { "description": "Non Zero Length String", "type": "string", "minLength": 1 } } }
so probably you have to replace "ref" with their corresponding content in the sequence they have been called/used.
Hope it helps you.
Thanks
Again, my question is not about creating JSON schema manually. I have the whole folder of JSON schemas.
What I need is to validate the response agains the JSON schema, which has #ref inside it. So the validation is failing at the moment. I figured that I need to make my schema flat in my java app. How to do it programmatically?
Thanks, Laura.
There is mention of a schema inlining feature in #116 by @fge in the next major release. Maybe this is what you refer to?
I too am looking for such feature. Programmatically you could load the schema in a JsonNode, inline contents of external schemas and replace the $refs that you find. (Don't know best way to get to the referenced schema's that are loaded by the validator, yet).
@aschrijver Thank you a lot for the answer! It looks like something I was looking for.
Someone found a good solution? I'd like to load a flat schema too...
Hey,
I might have put it in a different issue tracker, apologies if so.
My problem is that I have a json schema, which has #ref in it with a relative paths. The whole thing is located at GitHub and should stay there.
What I want is to validate a json-string against the schema, but, as far as I understood, I need to create a flat json scheme with resolved #ref elements. Is there any way to do it?
Please, help me with this issue. It'd help me and my project tremendously!
Thanks, Laura.