Skip to content

Commit 59168e9

Browse files
authored
Merge pull request #413 from p1c2u/feature/get-rid-of-openapiv3-prefix-for-spec
get rid of openapiv3 prefix for spec
2 parents c838267 + 3c329c2 commit 59168e9

22 files changed

+28
-43
lines changed

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Firstly create your specification object:
6262
.. code-block:: python
6363
6464
from json import load
65-
from openapi_core import OpenAPISpec as Spec
65+
from openapi_core import Spec
6666
6767
with open('openapi.json', 'r') as spec_file:
6868
spec_dict = load(spec_file)

docs/customizations.rst

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ Customizations
44
Spec validation
55
---------------
66

7-
By default, spec dict is validated on spec creation time. Disabling the validation can improve the performance.
7+
By default, spec dict is validated on spec creation time. Disabling the validator can improve the performance.
88

99
.. code-block:: python
1010
11-
from openapi_core import OpenAPISpec as Spec
11+
from openapi_core import Spec
1212
13-
spec = Spec.create(spec_dict, validate=False)
13+
spec = Spec.create(spec_dict, validator=False)
1414
1515
Deserializers
1616
-------------

docs/integrations.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Django can be integrated by middleware. Add `DjangoOpenAPIMiddleware` to your `M
2121
.. code-block:: python
2222
2323
# settings.py
24-
from openapi_core import OpenAPISpec as Spec
24+
from openapi_core import Spec
2525
2626
MIDDLEWARE = [
2727
# ...

docs/usage.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Firstly create your specification: object
66
.. code-block:: python
77
88
from json import load
9-
from openapi_core import OpenAPISpec as Spec
9+
from openapi_core import Spec
1010
1111
with open('openapi.json', 'r') as spec_file:
1212
spec_dict = load(spec_file)

openapi_core/__init__.py

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""OpenAPI core module"""
2-
from openapi_core.spec import OpenAPIv30Spec
2+
from openapi_core.spec import Spec
33
from openapi_core.validation.request.validators import RequestBodyValidator
44
from openapi_core.validation.request.validators import (
55
RequestParametersValidator,
@@ -21,9 +21,7 @@
2121
__license__ = "BSD 3-Clause License"
2222

2323
__all__ = [
24-
"OpenAPIv30Spec",
25-
"OpenAPIv3Spec",
26-
"OpenAPISpec",
24+
"Spec",
2725
"validate_request",
2826
"validate_response",
2927
"RequestValidator",
@@ -34,9 +32,3 @@
3432
"ResponseDataValidator",
3533
"ResponseHeadersValidator",
3634
]
37-
38-
# aliases to the latest v3 version
39-
OpenAPIv3Spec = OpenAPIv30Spec
40-
41-
# aliases to the latest version
42-
OpenAPISpec = OpenAPIv3Spec

openapi_core/spec/__init__.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from openapi_core.spec.paths import OpenAPIv30Spec
1+
from openapi_core.spec.paths import Spec
22

3-
__all__ = [
4-
"OpenAPIv30Spec",
5-
]
3+
__all__ = ["Spec"]

openapi_core/spec/paths.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ def from_dict(
2424
accessor = SpecAccessor(data, dereferencer)
2525
return cls(accessor, *args, separator=separator)
2626

27-
28-
class OpenAPIv30Spec(Spec):
29-
30-
validator = openapi_v3_spec_validator
31-
3227
@classmethod
3328
def create(
3429
cls,
@@ -37,10 +32,10 @@ def create(
3732
url="",
3833
ref_resolver_handlers=default_handlers,
3934
separator=SPEC_SEPARATOR,
40-
validate=True,
35+
validator=openapi_v3_spec_validator,
4136
):
42-
if validate:
43-
cls.validator.validate(data, spec_url=url)
37+
if validator is not None:
38+
validator.validate(data, spec_url=url)
4439

4540
return cls.from_dict(
4641
data,

openapi_core/templating/paths/util.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from typing import Tuple
22

3-
from openapi_core.spec.paths import OpenAPIv30Spec as Spec
3+
from openapi_core.spec.paths import Spec
44
from openapi_core.templating.datatypes import TemplateResult
55

66

tests/integration/contrib/django/data/v3.0/djangoproject/settings.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
import yaml
1717

18-
from openapi_core import OpenAPISpec as Spec
18+
from openapi_core import Spec
1919

2020
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
2121
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

tests/integration/contrib/falcon/data/v3.0/falconproject/openapi.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import yaml
44

5-
from openapi_core import OpenAPISpec as Spec
5+
from openapi_core import Spec
66
from openapi_core.contrib.falcon.middlewares import FalconOpenAPIMiddleware
77

88
openapi_spec_path = Path("tests/integration/data/v3.0/petstore.yaml")

tests/integration/contrib/flask/test_flask_decorator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from flask import make_response
55

66
from openapi_core.contrib.flask.decorators import FlaskOpenAPIViewDecorator
7-
from openapi_core.spec import OpenAPIv30Spec as Spec
7+
from openapi_core.spec import Spec
88
from openapi_core.validation.request.datatypes import Parameters
99

1010

tests/integration/contrib/flask/test_flask_views.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from flask import make_response
55

66
from openapi_core.contrib.flask.views import FlaskOpenAPIView
7-
from openapi_core.spec import OpenAPIv30Spec as Spec
7+
from openapi_core.spec import Spec
88

99

1010
class TestFlaskOpenAPIView:

tests/integration/contrib/requests/test_requests_validation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from openapi_core.contrib.requests import RequestsOpenAPIRequest
66
from openapi_core.contrib.requests import RequestsOpenAPIResponse
7-
from openapi_core.spec import OpenAPIv30Spec as Spec
7+
from openapi_core.spec import Spec
88
from openapi_core.validation.request import openapi_request_validator
99
from openapi_core.validation.response import openapi_response_validator
1010

tests/integration/schema/test_empty.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from jsonschema.exceptions import ValidationError
33

4-
from openapi_core.spec import OpenAPIv30Spec as Spec
4+
from openapi_core.spec import Spec
55

66

77
class TestEmpty:

tests/integration/schema/test_link_spec.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from openapi_core.spec import OpenAPIv30Spec as Spec
1+
from openapi_core.spec import Spec
22

33

44
class TestLinkSpec:

tests/integration/schema/test_path_params.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from openapi_core.spec import OpenAPIv30Spec as Spec
3+
from openapi_core.spec import Spec
44

55

66
class TestMinimal:

tests/integration/schema/test_spec.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from openapi_core.schema.servers import get_server_url
66
from openapi_core.schema.specs import get_spec_url
7-
from openapi_core.spec import OpenAPIv30Spec as Spec
7+
from openapi_core.spec import Spec
88
from openapi_core.validation.request.validators import RequestValidator
99
from openapi_core.validation.response.validators import ResponseValidator
1010

tests/integration/validation/test_minimal.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
22

3-
from openapi_core.spec import OpenAPIv30Spec as Spec
3+
from openapi_core.spec import Spec
44
from openapi_core.templating.paths.exceptions import OperationNotFound
55
from openapi_core.templating.paths.exceptions import PathNotFound
66
from openapi_core.testing import MockRequest

tests/integration/validation/test_petstore.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
EmptyQueryParameterValue,
1313
)
1414
from openapi_core.extensions.models.models import BaseModel
15-
from openapi_core.spec import OpenAPIv30Spec as Spec
15+
from openapi_core.spec import Spec
1616
from openapi_core.templating.media_types.exceptions import MediaTypeNotFound
1717
from openapi_core.templating.paths.exceptions import ServerNotFound
1818
from openapi_core.testing import MockRequest

tests/integration/validation/test_read_only_write_only.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from openapi_core.spec import OpenAPIv30Spec as Spec
5+
from openapi_core.spec import Spec
66
from openapi_core.testing import MockRequest
77
from openapi_core.testing import MockResponse
88
from openapi_core.unmarshalling.schemas.exceptions import InvalidSchemaValue

tests/integration/validation/test_security_override.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import pytest
44

5-
from openapi_core.spec import OpenAPIv30Spec as Spec
5+
from openapi_core.spec import Spec
66
from openapi_core.testing import MockRequest
77
from openapi_core.validation.exceptions import InvalidSecurity
88
from openapi_core.validation.request import openapi_request_validator

tests/integration/validation/test_validators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
MediaTypeDeserializeError,
99
)
1010
from openapi_core.extensions.models.models import BaseModel
11-
from openapi_core.spec import OpenAPIv30Spec as Spec
11+
from openapi_core.spec import Spec
1212
from openapi_core.templating.media_types.exceptions import MediaTypeNotFound
1313
from openapi_core.templating.paths.exceptions import OperationNotFound
1414
from openapi_core.templating.paths.exceptions import PathNotFound

0 commit comments

Comments
 (0)