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] Library is not compatible with openapi_spec_validator >= 0.5.0 #41

Closed sergei-maertens closed 2 years ago

sergei-maertens commented 2 years ago

Describe the bug

It seems that yesterday openapi_spec_validator 0.5.0 was released, which dropped the validate_v-aliases that this library imports.

Downgrading to < 0.5.0 works - you might want to update your dependencies or fix the imports.

To Reproduce

  1. In a clean, fresh environment:
  2. pip install openapi3-parser
  3. python to open an interactive shell
  4. Try to parse an API spec:

    >>> parse("/path/to/spec.yaml")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/bbt/.virtualenvs/tmp-ab5c8e05221c2c5/lib/python3.10/site-packages/openapi_parser/parser.py", line 119, in parse
        specification = resolver.resolve()
      File "/home/bbt/.virtualenvs/tmp-ab5c8e05221c2c5/lib/python3.10/site-packages/openapi_parser/resolver.py", line 34, in resolve
        self._resolver.parse()
      File "/home/bbt/.virtualenvs/tmp-ab5c8e05221c2c5/lib/python3.10/site-packages/prance/__init__.py", line 146, in parse
        self._validate()
      File "/home/bbt/.virtualenvs/tmp-ab5c8e05221c2c5/lib/python3.10/site-packages/prance/__init__.py", line 322, in _validate
        BaseParser._validate(self)
      File "/home/bbt/.virtualenvs/tmp-ab5c8e05221c2c5/lib/python3.10/site-packages/prance/__init__.py", line 185, in _validate
        validator(parsed)
      File "/home/bbt/.virtualenvs/tmp-ab5c8e05221c2c5/lib/python3.10/site-packages/prance/__init__.py", line 229, in _validate_openapi_spec_validator
        from openapi_spec_validator import validate_v2_spec, validate_v3_spec
    ImportError: cannot import name 'validate_v2_spec' from 'openapi_spec_validator' (/home/bbt/.virtualenvs/tmp-ab5c8e05221c2c5/lib/python3.10/site-packages/openapi_spec_validator/__init__.py)

Expected behavior

Parsing succeeds without errors.

System details (please complete the following information):

manchenkoff commented 2 years ago

Nice catch @sergei-maertens, thanks a lot! Tbh, I had some ideas on re-writing those imports in the next release since it's kinda magic stuff. Your solution is much faster, could you please open the PR for that?