Questions tagged [python-jsonschema]

126 questions
2
votes
1 answer

Json schema: is it possible to validate a string is a JSON array or object?

For some reason, I have a property, say "references", that is a JSON string itself. "references": { "type": "string" }, But I want to validate the string is a JSON array (after "decoding"): "references": { "type": "array", …
2
votes
0 answers

Retrieve a list of all properties from a schema (resolving references)

Consider a "complex" schema which uses references from other files like the one below. Is there a simple way to get a list of all properties defined in a schema, perhaps using some of the machinery already in python-jsonschema? I think I only need…
DilithiumMatrix
  • 17,795
  • 22
  • 77
  • 119
2
votes
1 answer

Validating json with jsonschema and robotframework

Can anyone help get me started on how to use RobotFramework to validate json responses via a json-schema? Ideally, the json-schema is externally referenced via an http request: Example…
Guy
  • 9,720
  • 7
  • 38
  • 42
2
votes
0 answers

Python jsonschema: how to query schema to determine the type of a property?

Consider the following use case: I have the configuration of a network router (OpenWRT) in text format that I'm converting to JSON (NetJSON to be specific), the text format used by the router only uses strings and I have to convert many…
nemesisdesign
  • 8,159
  • 12
  • 58
  • 97
1
vote
1 answer

json-schema - reference all nested properties as string regardless of name

I am trying to reference all nested properties as string regardless of name. An example of the data looks like this (except with a bunch of columns): [ { "var_1": "some_string", "var_2": { "col_1": "x", …
alexb523
  • 718
  • 2
  • 9
  • 26
1
vote
2 answers

Json Schema validation: should raise Exception when there are unrecognized fields

A simple example: import json from jsonschema import validate schema = { "type" : "object", "properties" : { "description" : {"type" : "string"}, "value_c" : { "type": "object", "properties": {"x": {…
1
vote
1 answer

Jsonstatdataset rename

I am trying to read a table from the Central Statistics Office for Ireland. I am reading it into a collection and successfully displaying the first dataset dataset = collection.dataset(0) print(dataset) which returns: name: 'dataset' label: …
1
vote
0 answers

Python-jsonschema validation of Pydantic class

So we're using pydantic and python-jsonschema to validate user input. Pydantic for internal validation, and python-jsonschema for validation on the portal. And I've come across an interesting issue, and I can't wrap my head around it. Example…
thevoiddancer
  • 385
  • 2
  • 9
1
vote
0 answers

How to generate all test cases from a JSON schema

I am developing a system where we create documents that are created from json-files. The json files are described by a json schema of the following kind, where a key either could have a static default value or have one of multiple enumerated…
NiklasR
  • 473
  • 6
  • 19
1
vote
2 answers

Best Match for Validation error with oneof or anyof

I am trying to get proper validation error from oneof or anyof pattern. I have json schema with two or more oneof/anyof condition as mentioned below: json_schema = { "type": "object", "properties": { "comment": { …
1
vote
0 answers

I want to Save Maps in JSON File from Selenium Scrape data

I scraped a website and I get all the data from it and I want store it in json file so I could use it as an API the problem is that when it tries to write maps in JSON file it get duplicated because I called json.dumps inside for loop this is what…
1
vote
1 answer

How to validate sub-schemas based on value in parent schema

I am trying to validate a JSON schema using jsonschema lib. scenario: I need to make sure if a specific value in a property is sent in the parent object, the child(sub-schema) should also get the same value in the same property. JSON:-> { "type":…
1
vote
1 answer

JSON Schema enum with maximum and minimum

I have a JSON object like this. { "test": bla bla bla } This test can be a number between 0 and 120 or an empty string. I want to validate this JSON object using a JSON schema like this. { "type": ["number", "string"], "enum": [""], …
Hirusha Fernando
  • 1,156
  • 10
  • 29
1
vote
1 answer

Can you use separate files for json subschemas?

I am new to using JSON schemas and I am pretty confused about subschemas. I have done many searches and read https://json-schema.org/understanding-json-schema/structuring.html but I feel like I am not getting some basic concepts. I'd like to break…
Arcturus13
  • 11
  • 2
1
vote
0 answers

JSON Schema - validate schema on root if property in another subschema contains a fix value

I would like to validate the following json: { "endpoints": [ { "ip_name": "plantuml_ip", "ip": "172.18.0.2", "ports": [ { "name": "plantuml_port", "port": 8080, "proto": "HTTPS_TERM" …
Zili
  • 455
  • 2
  • 4
  • 10
1 2
3
8 9