Skip to content

Commit

Permalink
refactor: replace deprecated Spec
Browse files Browse the repository at this point in the history
Refs: python-openapi/openapi-core#690

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
miketheman authored and zupo committed Mar 7, 2024
1 parent 379324d commit 50c4ac8
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ exclude = ["pyramid_openapi3/tests/"]
python = "^3.8"

openapi-core = ">=0.19.0"
jsonschema-path = ">=0.3.0"
pyramid = ">=1.10.7"


Expand Down
10 changes: 5 additions & 5 deletions pyramid_openapi3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .exceptions import RequestValidationError
from .exceptions import ResponseValidationError
from .wrappers import PyramidOpenAPIRequest
from openapi_core import Spec
from jsonschema_path import SchemaPath
from openapi_core.unmarshalling.request import V30RequestUnmarshaller
from openapi_core.unmarshalling.response import V30ResponseUnmarshaller
from openapi_core.validation.request.exceptions import SecurityValidationError
Expand Down Expand Up @@ -235,7 +235,7 @@ def register() -> None:
spec_dict, _ = read_from_filename(filepath)

validate(spec_dict)
spec = Spec.from_dict(spec_dict)
spec = SchemaPath.from_dict(spec_dict)

def spec_view(request: Request) -> FileResponse:
return FileResponse(filepath, request=request, content_type="text/yaml")
Expand Down Expand Up @@ -287,7 +287,7 @@ def register() -> None:
spec_dict, _ = read_from_filename(str(path))
spec_url = path.as_uri()
validate(spec_dict, base_uri=spec_url)
spec = Spec.from_dict(spec_dict, base_uri=spec_url)
spec = SchemaPath.from_dict(spec_dict, base_uri=spec_url)

config.add_static_view(route, str(path.parent), permission=permission)
config.add_route(route_name, f"{route}/{path.name}")
Expand All @@ -303,7 +303,7 @@ def register() -> None:


def _create_api_settings(
config: Configurator, filepath: str, route_name: str, spec: Spec
config: Configurator, filepath: str, route_name: str, spec: SchemaPath
) -> t.Dict:
custom_formatters = config.registry.settings.get("pyramid_openapi3_formatters")
custom_deserializers = config.registry.settings.get(
Expand Down Expand Up @@ -438,7 +438,7 @@ def remove_prefixes(path: str) -> str:
settings["pyramid_openapi3"]["routes"][route_name] = name


def _get_server_prefixes(spec: Spec) -> t.List[str]:
def _get_server_prefixes(spec: SchemaPath) -> t.List[str]:
"""Build a set of possible route prefixes from the api spec.
Api routes may optionally be prefixed using servers (e.g: `/api/v1`).
Expand Down

0 comments on commit 50c4ac8

Please sign in to comment.