Comments (8)
I further tried removing $ref and compiling and then I got this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/dnbusr1/z-gda-pad/anaconda3/lib/python3.6/site-packages/fastjsonschema/__init__.py", line 153, in compile
resolver, code_generator = _factory(definition, handlers)
File "/dnbusr1/z-gda-pad/anaconda3/lib/python3.6/site-packages/fastjsonschema/__init__.py", line 193, in _factory
resolver = RefResolver.from_schema(definition, handlers=handlers)
File "/dnbusr1/z-gda-pad/anaconda3/lib/python3.6/site-packages/fastjsonschema/ref_resolver.py", line 89, in from_schema
**kwargs
File "/dnbusr1/z-gda-pad/anaconda3/lib/python3.6/site-packages/fastjsonschema/ref_resolver.py", line 78, in __init__
self.walk(schema)
File "/dnbusr1/z-gda-pad/anaconda3/lib/python3.6/site-packages/fastjsonschema/ref_resolver.py", line 151, in walk
elif 'id' in node and isinstance(node['id'], str):
TypeError: string indices must be integers
from python-fastjsonschema.
Thank you for the report. I will try to do address the issue sometime in the following weeks.
from python-fastjsonschema.
What version of fastjsonschema are you using? With the latest one it works for me.
from python-fastjsonschema.
I am using VERSION = '2.13' of fastjsonschema and Python version 3.6.5
from python-fastjsonschema.
if I run below:
validate = fastjsonschema.compile({ "$schema": "http://json-schema.org/draft-04/schema#", "title": "organization", "description": "JSON schema", "type": "object", "properties": { "transactionDetail": { "id": "https://example.com/transactionDetail", "type": "object", "properties": { "transactionID": { "description": "A number assigned by the calling application to uniquely identify this request.", "type": "string" }, "transactionTimestamp": { "description": "The date and time when this request was submitted.", "type": "string" } }, "required": [ "transactionID" ], "additionalProperties": false }, "organization": { "$ref": "#/definitions/organization" } }, "additionalProperties": false, "definitions": { "organization": { "type": "object", "properties": { "identifier": { "description": "identification number.", "type": "string", "minLength": 1, "maxLength": 12 }, "countryCode": { "description": "The two-letter country code.", "type": "string", "minLength": 2, "maxLength": 2 }, "timestamp": { "description": "The date and time that the record was created.", "type": "string" }, "required": [ "identifier", "countryCode" ], "additionalProperties": false } } } })
Getting this error:
Traceback (most recent call last): File "<stdin>", line 23, in <module> NameError: name 'false' is not defined
from python-fastjsonschema.
Ok. Your first posted schema is working because required
and additionalProperties
are on the correct level. In your non-working schema you put them inside properties which is wrong. I fixed this that now it is reporting as more readable exception.
from python-fastjsonschema.
Hi there, I am facing the same problem with the following JSON Schema:
{ "$id": "https://github.com/victoraugustofd/git-phoenix/blob/master/src/phoenix-schema.json", "$schema": "http://json-schema.org/draft-07/schema#", "title": "Git Phoenix Template Schema", "description": "A schema validator for Git Phoenix templates.", "definitions": { "actions": { "$id": "#actions", "type": "string", "enum": [ "create-branch", "merge" ] }, "execution": { "$id": "#execution", "type": "object", "properties": { "step": { "type": "integer" }, "do": { "type": "object", "properties": { "action": { "$ref": "#actions" }, "parameters": { "type": "object" } }, "allOf": [ { "if": { "properties": { "action": { "const": "create-branch" } } }, "then": { "properties": { "parameters": { "properties": { "name": { "type": "string" }, "origin": { "type": "string" }, "origin-pattern": { "type": "string" }, "origin-pattern-example": { "type": "string" }, "prefix": { "type": "string" }, "pattern": { "type": "string" }, "pattern-example": { "type": "string" } }, "required": [ "name", "origin" ], "additionalProperties": false } } } }, { "if": { "properties": { "action": { "const": "merge" } } }, "then": { "properties": { "parameters": { "properties": { "origin": { "type": "string" }, "destination": { "type": "array", "items": { "type": "string" }, "minItems": 1 }, "origin-pattern": { "type": "string" }, "origin-pattern-example": { "type": "string" }, "allow-new-merge": { "type": "boolean" } }, "required": [ "origin", "destination" ], "additionalProperties": false } } } } ], "required": [ "action", "parameters" ], "additionalProperties": false } }, "required": [ "step", "do" ], "additionalProperties": false }, "action": { "$id": "#action", "type": "object", "properties": { "name": { "type": "string" }, "execution": { "type": "array", "items": { "$ref": "#execution" }, "minItems": 1 } }, "required": [ "name", "execution" ], "additionalProperties": false }, "command": { "$id": "#command", "type": "object", "properties": { "name": { "type": "string" }, "actions": { "type": "array", "items": { "$ref": "#action" }, "minItems": 1 } }, "required": [ "name", "actions" ], "additionalProperties": false } }, "type": "object", "properties": { "init": { "type": "object", "properties": { "execution": { "type": "array", "items": { "$ref": "#execution" }, "minItems": 1 } } }, "commons": { "type": "object" }, "commands": { "type": "array", "items": { "$ref": "#command" }, "minItems": 1 } }, "required": [ "commands" ], "additionalProperties": false }
fastjsonschema version: 2.14.1
Python version: 3.8.0
@horejsek could you help me, please?
Thanks in advance.
from python-fastjsonschema.
@sumitbharati I commented a solution for this problem on issue #78. If you are still facing this problem, check my comment there.
from python-fastjsonschema.
Related Issues (20)
- Uniqueness enforced if uniqueItems explicitly set to False HOT 1
- 2.16.1: test_compile_to_code_custom_format fails HOT 3
- 2.16.2 not available on pypi.org HOT 1
- RFC 3339 date month and mday should be two digit HOT 2
- Getting UnboundLocalError HOT 3
- are the compiled validation functions cached? HOT 2
- Datadog's Guarddog detects exec in setup.py and complains HOT 4
- Python 3.10 venv build is failing HOT 1
- sdist is missing tests HOT 1
- Cannot parse int64 types HOT 1
- [Potential bug] not working validation for properties not defined in the schema object HOT 1
- Release request HOT 1
- Wrong tag name for 2.17.0 HOT 1
- 2.17.0 sdist contains "stray" tests/examples/lengths that breaks tests HOT 2
- errors for missing required properties
- Error occurs when fastjsonschema generates empty except block HOT 2
- Feature request: automatically add nested defaults HOT 7
- RFE: is it possible to start making github releases?🤔 HOT 1
- test_pattern_with_escape_no_warnings fails with python 3.12 HOT 2
- unspecified required properties yield unexpected behavior HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-fastjsonschema.