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

File tree

22 files changed

+28
-43
lines changed

22 files changed

+28
-43
lines changed

README.rst

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 10 deletions
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

Lines changed: 2 additions & 4 deletions
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

Lines changed: 3 additions & 8 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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")

0 commit comments

Comments
 (0)