Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prance doesn't work with python 3.12.1 #160

Open
dmdhrumilmistry opened this issue Feb 1, 2024 · 0 comments
Open

Prance doesn't work with python 3.12.1 #160

dmdhrumilmistry opened this issue Feb 1, 2024 · 0 comments

Comments

@dmdhrumilmistry
Copy link

Expected Behaviour

Spec should get validated for valid swagger file.

Minimal Example Spec

Actual Behaviour

Raises AttributeError: '_io.BufferedReader' object has no attribute 'decode'

Steps to Reproduce

  • Execute below command:
$ prance validate http://petstore.swagger.io/v2/swagger.json
Processing "http://petstore.swagger.io/v2/swagger.json"...
 -> Resolving external references.
Traceback (most recent call last):
  File "/Users/apple/.pyenv/versions/3.12.1/bin/prance", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/prance/cli.py", line 114, in command_invoke
    original_invoke(ctx)
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/prance/cli.py", line 209, in validate
    __validate(parser, name)
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/prance/cli.py", line 65, in __validate
    parser.parse()
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/prance/__init__.py", line 148, in parse
    self._validate()
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/prance/__init__.py", line 316, in _validate
    BaseParser._validate(self)
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/prance/__init__.py", line 187, in _validate
    validator(parsed)
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/prance/__init__.py", line 248, in _validate_openapi_spec_validator
    validate_spec(self.specification)
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/openapi_spec_validator/shortcuts.py", line 17, in validate_spec
    return validator.validate(spec, spec_url=spec_url)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/openapi_spec_validator/validation/proxies.py", line 27, in validate
    for err in validator.iter_errors(instance, spec_url=spec_url):
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/openapi_spec_validator/validation/decorators.py", line 22, in wrapper
    for err in errors:
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/openapi_spec_validator/validation/validators.py", line 89, in iter_errors
    yield from self.schema_validator.iter_errors(instance)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<attrs generated init jsonschema.validators.create.<locals>.Validator>", line 5, in __init__
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/jsonschema/validators.py", line 216, in __attrs_post_init__
    self.resolver = RefResolver.from_schema(
                    ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/jsonschema/validators.py", line 772, in from_schema
    return cls(base_uri=id_of(schema), referrer=schema, *args, **kwargs)  # noqa: B026, E501
                        ^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/jsonschema/_legacy_validators.py", line 12, in id_of
    if schema is True or schema is False or "$ref" in schema:
                                            ^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/openapi_spec_validator/schemas/utils.py", line 28, in get_schema_content
    content, _ = get_schema(version)
                 ^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/openapi_spec_validator/schemas/utils.py", line 24, in get_schema
    return FilePathReader(schema_path_full).read()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/jsonschema_spec/readers.py", line 37, in read
    return all_urls_handler(uri), uri
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/jsonschema_spec/handlers/file.py", line 45, in __call__
    return self._open(uri)
           ^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/jsonschema_spec/handlers/urllib.py", line 18, in _open
    return super().__call__(fh)
           ^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/site-packages/jsonschema_spec/handlers/file.py", line 41, in __call__
    parsed_url = urlparse(uri)
                 ^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/urllib/parse.py", line 394, in urlparse
    url, scheme, _coerce_result = _coerce_args(url, scheme)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/urllib/parse.py", line 133, in _coerce_args
    return _decode_args(args) + (_encode_result,)
           ^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/urllib/parse.py", line 117, in _decode_args
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/urllib/parse.py", line 117, in <genexpr>
    return tuple(x.decode(encoding, errors) if x else '' for x in args)
                 ^^^^^^^^
  File "/Users/apple/.pyenv/versions/3.12.1/lib/python3.12/tempfile.py", line 494, in __getattr__
    a = getattr(file, name)
        ^^^^^^^^^^^^^^^^^^^
AttributeError: '_io.BufferedReader' object has no attribute 'decode'

Environment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant