Giter VIP home page Giter VIP logo

Comments (8)

sumitbharati avatar sumitbharati commented on July 18, 2024

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.

horejsek avatar horejsek commented on July 18, 2024

Thank you for the report. I will try to do address the issue sometime in the following weeks.

from python-fastjsonschema.

horejsek avatar horejsek commented on July 18, 2024

What version of fastjsonschema are you using? With the latest one it works for me.

from python-fastjsonschema.

sumitbharati avatar sumitbharati commented on July 18, 2024

I am using VERSION = '2.13' of fastjsonschema and Python version 3.6.5

from python-fastjsonschema.

sumitbharati avatar sumitbharati commented on July 18, 2024

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.

horejsek avatar horejsek commented on July 18, 2024

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.

victoraugustofd avatar victoraugustofd commented on July 18, 2024

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.

victoraugustofd avatar victoraugustofd commented on July 18, 2024

@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)

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.