From 5cc388cc162be3b76309a968e38b26c992d1e6e7 Mon Sep 17 00:00:00 2001 From: James Kent Date: Tue, 20 Feb 2024 19:57:50 -0600 Subject: [PATCH] replicate swagger-ui problem and hacky solution --- connexion/spec.py | 5 ++++- tests/fixtures/simple/foo.yaml | 7 +++++++ tests/fixtures/simple/openapi.yaml | 7 +------ 3 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 tests/fixtures/simple/foo.yaml diff --git a/connexion/spec.py b/connexion/spec.py index 40fe46d70..ca40714f2 100644 --- a/connexion/spec.py +++ b/connexion/spec.py @@ -204,7 +204,10 @@ def enforce_string_keys(obj): return OpenAPISpecification(spec, base_uri=base_uri) def clone(self): - return type(self)(copy.deepcopy(self._raw_spec)) + try: + return type(self)(copy.deepcopy(self._raw_spec)) + except jsonschema.exceptions.RefResolutionError: + return type(self)(copy.deepcopy(self._spec)) @classmethod def load(cls, spec, *, arguments=None): diff --git a/tests/fixtures/simple/foo.yaml b/tests/fixtures/simple/foo.yaml new file mode 100644 index 000000000..80cd1bd1c --- /dev/null +++ b/tests/fixtures/simple/foo.yaml @@ -0,0 +1,7 @@ +title: foo +type: object +properties: + foo: + type: string + foo4: + type: string diff --git a/tests/fixtures/simple/openapi.yaml b/tests/fixtures/simple/openapi.yaml index c4ce61773..4eb59aab1 100644 --- a/tests/fixtures/simple/openapi.yaml +++ b/tests/fixtures/simple/openapi.yaml @@ -180,12 +180,7 @@ paths: content: application/json: schema: - type: object - properties: - foo: - type: string - foo4: - type: string + $ref: ./foo.yaml /exploded-deep-object-param-additional-properties: get: summary: Returns dict response with flexible properties