Skip to content

Commit b69e268

Browse files
committed
Response dereference support
1 parent 12dcc8c commit b69e268

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

openapi_core/responses.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,10 @@ def __init__(self, dereferencer, schemas_registry):
3535

3636
def generate(self, responses):
3737
for http_status, response in iteritems(responses):
38-
description = response['description']
39-
headers = response.get('headers')
40-
content = response.get('content')
38+
response_deref = self.dereferencer.dereference(response)
39+
description = response_deref['description']
40+
headers = response_deref.get('headers')
41+
content = response_deref.get('content')
4142

4243
media_types = None
4344
if content:

tests/integration/data/v3.0/petstore.yaml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,7 @@ paths:
103103
schema:
104104
$ref: "#/components/schemas/Pets"
105105
default:
106-
description: unexpected error
107-
content:
108-
application/json:
109-
schema:
110-
$ref: "#/components/schemas/Error"
106+
$ref: "#/components/responses/ErrorResponse"
111107
components:
112108
schemas:
113109
Address:
@@ -174,4 +170,11 @@ components:
174170
type: integer
175171
format: int32
176172
message:
177-
type: string
173+
type: string
174+
responses:
175+
ErrorResponse:
176+
description: unexpected error
177+
content:
178+
application/json:
179+
schema:
180+
$ref: "#/components/schemas/Error"

tests/integration/test_petstore.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ def test_spec(self, spec, spec_dict):
6969
assert response.http_status == http_status
7070

7171
response_spec = responses_spec[http_status]
72+
73+
if not response_spec:
74+
continue
75+
76+
# @todo: test with defererence
77+
if '$ref' in response_spec:
78+
continue
79+
7280
description_spec = response_spec['description']
7381

7482
assert response.description == description_spec

0 commit comments

Comments
 (0)