python-openapi/openapi-core

[Bug]: ImportError: cannot import name 'OpenAPI' from 'openapi_core'

mdenhoedt opened this issue · 1 comments

Actual Behavior

D:/> python
Python 3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from openapi_core import OpenAPI
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'OpenAPI' from 'openapi_core' (C:\Users\user-name\AppData\Local\Programs\Python\Python312\Lib\site-packages\openapi_core\__init__.py)

Expected Behavior

I didn't expect the library would crash on the import as suggested by the documentation.

Steps to Reproduce

pip install openapi-core          
Collecting openapi-core
  Using cached openapi_core-0.18.2-py3-none-any.whl.metadata (6.3 kB)
Requirement already satisfied: asgiref<4.0.0,>=3.6.0 in c:\users\martijnhoe\appdata\local\programs\python\python312\lib\site-packages (from openapi-core) (3.7.2)
Requirement already satisfied: isodate in c:\users\martijnhoe\appdata\local\programs\python\python312\lib\site-packages (from openapi-core) (0.6.1)
Requirement already satisfied: jsonschema<5.0.0,>=4.18.0 in c:\users\martijnhoe\appdata\local\programs\python\python312\lib\site-packages (from openapi-core) (4.20.0)
Requirement already satisfied: jsonschema-spec<0.3.0,>=0.2.3 in c:\users\martijnhoe\appdata\local\programs\python\python312\lib\site-packages (from openapi-core) (0.2.4)
Requirement already satisfied: more-itertools in c:\users\martijnhoe\appdata\local\programs\python\python312\lib\site-packages (from openapi-core) (10.1.0)
Requirement already satisfied: openapi-schema-validator<0.7.0,>=0.6.0 in c:\users\martijnhoe\appdata\local\programs\python\python312\lib\site-packages (from openapi-core) (0.6.2)
Requirement already satisfied: openapi-spec-validator<0.8.0,>=0.7.1 in c:\users\martijnhoe\appdata\local\programs\python\python312\lib\site-packages (from openapi-core) (0.7.1)
Requirement already satisfied: parse in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from openapi-core) (1.20.0)
Requirement already satisfied: werkzeug in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from openapi-core) (3.0.1)
Requirement already satisfied: attrs>=22.2.0 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from jsonschema<5.0.0,>=4.18.0->openapi-core) (23.1.0)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from jsonschema<5.0.0,>=4.18.0->openapi-core) (2023.7.1)
Requirement already satisfied: referencing>=0.28.4 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from jsonschema<5.0.0,>=4.18.0->openapi-core) (0.30.2)
Requirement already satisfied: rpds-py>=0.7.1 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from jsonschema<5.0.0,>=4.18.0->openapi-core) (0.13.2)
Requirement already satisfied: PyYAML>=5.1 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from jsonschema-spec<0.3.0,>=0.2.3->openapi-core) (6.0.1)
Requirement already satisfied: pathable<0.5.0,>=0.4.1 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from jsonschema-spec<0.3.0,>=0.2.3->openapi-core) (0.4.3)
Requirement already satisfied: requests<3.0.0,>=2.31.0 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from jsonschema-spec<0.3.0,>=0.2.3->openapi-core) (2.31.0)
Requirement already satisfied: rfc3339-validator in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from openapi-schema-validator<0.7.0,>=0.6.0->openapi-core) (0.1.4)
Requirement already satisfied: jsonschema-path<0.4.0,>=0.3.1 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from openapi-spec-validator<0.8.0,>=0.7.1->openapi-core) (0.3.2)
Requirement already satisfied: lazy-object-proxy<2.0.0,>=1.7.1 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from openapi-spec-validator<0.8.0,>=0.7.1->openapi-core) (1.9.0)
Requirement already satisfied: six in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from isodate->openapi-core) (1.16.0)
Requirement already satisfied: MarkupSafe>=2.1.1 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from werkzeug->openapi-core) (2.1.3)
Requirement already satisfied: charset-normalizer<4,>=2 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from requests<3.0.0,>=2.31.0->jsonschema-spec<0.3.0,>=0.2.3->openapi-core) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from requests<3.0.0,>=2.31.0->jsonschema-spec<0.3.0,>=0.2.3->openapi-core) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from requests<3.0.0,>=2.31.0->jsonschema-spec<0.3.0,>=0.2.3->openapi-core) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\user-name\appdata\local\programs\python\python312\lib\site-packages (from requests<3.0.0,>=2.31.0->jsonschema-spec<0.3.0,>=0.2.3->openapi-core) (2023.11.17)
Using cached openapi_core-0.18.2-py3-none-any.whl (82 kB)
Installing collected packages: openapi-core
Successfully installed openapi-core-0.18.2

OpenAPI Core Version

0.18.2

OpenAPI Core Integration

none

Affected Area(s)

No response

References

No response

Anything else we need to know?

No response

Would you like to implement a fix?

None

I ran into this too - looks like the OpenAPI object was added in v0.19, which is unreleased. If you go back to v0.18.2 of the docs the code to load a specification is:

from openapi_core import Spec

spec = Spec.from_file_path('openapi.json')