manchenkoff / openapi3-parser

OpenAPI 3 parser to use a specification inside of the code in your projects
https://pypi.org/project/openapi3-parser/
MIT License
61 stars 33 forks source link

[BUG] ImportError: cannot import name '_legacy_validators' from 'jsonschema' #50

Closed vinitshahdeo closed 1 year ago

vinitshahdeo commented 1 year ago

Describe the bug Facing ImportError: cannot import name '_legacy_validators' from 'jsonschema' (/usr/local/lib/python3.10/site-packages/jsonschema/__init__.py) while parsing a Open API JSON schema

To Reproduce

from openapi_parser import parse

specification = parse('swagger.json')

for path in specification.paths:
    supported_methods = ','.join([x.method.value for x in path.operations])

    print(f"Operation: {path.url}, methods: {supported_methods}")

Expected behavior This should parse the definition

manchenkoff commented 1 year ago

Hey @vinitshahdeo, thanks for opening this issue. I tried to reproduce the error but had no success. I've created 3 different projects based on python versions - 3.9, 3.10, 3.11, and all of them worked well.

By the way, this error is coming from one of the dependent packages, so if you could provide the list of installed packages or content of requirements.txt here, it would be very useful.

In the meantime, I would suggest updating jsonschema package to a newer version.

manchenkoff commented 1 year ago

Closed due to inactivity