Skip to content

Commit

Permalink
Specification use raw spec on clone (#1830)
Browse files Browse the repository at this point in the history
Fixes #1829.



Changes proposed in this pull request:

 - Use _raw_spec when cloning

---------

Co-authored-by: Robbe Sneyders <robbe.sneyders@gmail.com>
  • Loading branch information
nielsbox and RobbeSneyders committed Dec 7, 2023
1 parent dbca048 commit 6dc9436
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion connexion/spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def enforce_string_keys(obj):
return OpenAPISpecification(spec, base_uri=base_uri)

def clone(self):
return type(self)(copy.deepcopy(self._spec))
return type(self)(copy.deepcopy(self._raw_spec))

@classmethod
def load(cls, spec, *, arguments=None):
Expand Down
12 changes: 12 additions & 0 deletions tests/api/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest
from connexion.middleware import MiddlewarePosition
from connexion.options import SwaggerUIOptions
from starlette.middleware.cors import CORSMiddleware
from starlette.types import Receive, Scope, Send

Expand All @@ -22,6 +23,17 @@ def simple_openapi_app(app_class):
)


@pytest.fixture(scope="session")
def swagger_ui_app(app_class):
return build_app_from_fixture(
"simple",
app_class=app_class,
spec_file=OPENAPI3_SPEC,
validate_responses=True,
swagger_ui_options=SwaggerUIOptions(spec_path="/spec.json"),
)


@pytest.fixture(scope="session")
def cors_openapi_app(app_class):
app = build_app_from_fixture(
Expand Down
4 changes: 4 additions & 0 deletions tests/api/test_swagger_ui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
def test_simple(swagger_ui_app):
app_client = swagger_ui_app.test_client()
response = app_client.get("/v1.0/spec.json")
assert response.status_code == 200

0 comments on commit 6dc9436

Please sign in to comment.