Skip to content

get rid of openapiv3 prefix for spec #413

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

Merged
merged 1 commit into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Firstly create your specification object:
.. code-block:: python

from json import load
from openapi_core import OpenAPISpec as Spec
from openapi_core import Spec

with open('openapi.json', 'r') as spec_file:
spec_dict = load(spec_file)
Expand Down
6 changes: 3 additions & 3 deletions docs/customizations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Customizations
Spec validation
---------------

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

.. code-block:: python

from openapi_core import OpenAPISpec as Spec
from openapi_core import Spec

spec = Spec.create(spec_dict, validate=False)
spec = Spec.create(spec_dict, validator=False)

Deserializers
-------------
Expand Down
2 changes: 1 addition & 1 deletion docs/integrations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Django can be integrated by middleware. Add `DjangoOpenAPIMiddleware` to your `M
.. code-block:: python

# settings.py
from openapi_core import OpenAPISpec as Spec
from openapi_core import Spec

MIDDLEWARE = [
# ...
Expand Down
2 changes: 1 addition & 1 deletion docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Firstly create your specification: object
.. code-block:: python

from json import load
from openapi_core import OpenAPISpec as Spec
from openapi_core import Spec

with open('openapi.json', 'r') as spec_file:
spec_dict = load(spec_file)
Expand Down
12 changes: 2 additions & 10 deletions openapi_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""OpenAPI core module"""
from openapi_core.spec import OpenAPIv30Spec
from openapi_core.spec import Spec
from openapi_core.validation.request.validators import RequestBodyValidator
from openapi_core.validation.request.validators import (
RequestParametersValidator,
Expand All @@ -21,9 +21,7 @@
__license__ = "BSD 3-Clause License"

__all__ = [
"OpenAPIv30Spec",
"OpenAPIv3Spec",
"OpenAPISpec",
"Spec",
"validate_request",
"validate_response",
"RequestValidator",
Expand All @@ -34,9 +32,3 @@
"ResponseDataValidator",
"ResponseHeadersValidator",
]

# aliases to the latest v3 version
OpenAPIv3Spec = OpenAPIv30Spec

# aliases to the latest version
OpenAPISpec = OpenAPIv3Spec
6 changes: 2 additions & 4 deletions openapi_core/spec/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from openapi_core.spec.paths import OpenAPIv30Spec
from openapi_core.spec.paths import Spec

__all__ = [
"OpenAPIv30Spec",
]
__all__ = ["Spec"]
11 changes: 3 additions & 8 deletions openapi_core/spec/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ def from_dict(
accessor = SpecAccessor(data, dereferencer)
return cls(accessor, *args, separator=separator)


class OpenAPIv30Spec(Spec):

validator = openapi_v3_spec_validator

@classmethod
def create(
cls,
Expand All @@ -37,10 +32,10 @@ def create(
url="",
ref_resolver_handlers=default_handlers,
separator=SPEC_SEPARATOR,
validate=True,
validator=openapi_v3_spec_validator,
):
if validate:
cls.validator.validate(data, spec_url=url)
if validator is not None:
validator.validate(data, spec_url=url)

return cls.from_dict(
data,
Expand Down
2 changes: 1 addition & 1 deletion openapi_core/templating/paths/util.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Tuple

from openapi_core.spec.paths import OpenAPIv30Spec as Spec
from openapi_core.spec.paths import Spec
from openapi_core.templating.datatypes import TemplateResult


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import yaml

from openapi_core import OpenAPISpec as Spec
from openapi_core import Spec

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import yaml

from openapi_core import OpenAPISpec as Spec
from openapi_core import Spec
from openapi_core.contrib.falcon.middlewares import FalconOpenAPIMiddleware

openapi_spec_path = Path("tests/integration/data/v3.0/petstore.yaml")
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/contrib/flask/test_flask_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flask import make_response

from openapi_core.contrib.flask.decorators import FlaskOpenAPIViewDecorator
from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec
from openapi_core.validation.request.datatypes import Parameters


Expand Down
2 changes: 1 addition & 1 deletion tests/integration/contrib/flask/test_flask_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from flask import make_response

from openapi_core.contrib.flask.views import FlaskOpenAPIView
from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec


class TestFlaskOpenAPIView:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from openapi_core.contrib.requests import RequestsOpenAPIRequest
from openapi_core.contrib.requests import RequestsOpenAPIResponse
from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec
from openapi_core.validation.request import openapi_request_validator
from openapi_core.validation.response import openapi_response_validator

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/schema/test_empty.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
from jsonschema.exceptions import ValidationError

from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec


class TestEmpty:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/schema/test_link_spec.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec


class TestLinkSpec:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/schema/test_path_params.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec


class TestMinimal:
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/schema/test_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from openapi_core.schema.servers import get_server_url
from openapi_core.schema.specs import get_spec_url
from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec
from openapi_core.validation.request.validators import RequestValidator
from openapi_core.validation.response.validators import ResponseValidator

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/validation/test_minimal.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec
from openapi_core.templating.paths.exceptions import OperationNotFound
from openapi_core.templating.paths.exceptions import PathNotFound
from openapi_core.testing import MockRequest
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/validation/test_petstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
EmptyQueryParameterValue,
)
from openapi_core.extensions.models.models import BaseModel
from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec
from openapi_core.templating.media_types.exceptions import MediaTypeNotFound
from openapi_core.templating.paths.exceptions import ServerNotFound
from openapi_core.testing import MockRequest
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/validation/test_read_only_write_only.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec
from openapi_core.testing import MockRequest
from openapi_core.testing import MockResponse
from openapi_core.unmarshalling.schemas.exceptions import InvalidSchemaValue
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/validation/test_security_override.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec
from openapi_core.testing import MockRequest
from openapi_core.validation.exceptions import InvalidSecurity
from openapi_core.validation.request import openapi_request_validator
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/validation/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
MediaTypeDeserializeError,
)
from openapi_core.extensions.models.models import BaseModel
from openapi_core.spec import OpenAPIv30Spec as Spec
from openapi_core.spec import Spec
from openapi_core.templating.media_types.exceptions import MediaTypeNotFound
from openapi_core.templating.paths.exceptions import OperationNotFound
from openapi_core.templating.paths.exceptions import PathNotFound
Expand Down