Skip to content

Commit 9b9554e

Browse files
committed
Update assertions to expect references
This obviates the `schema_name_resolver` argument
1 parent 5e6b684 commit 9b9554e

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

tests/test_openapi.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
@pytest.fixture()
1515
def marshmallow_plugin():
16-
return MarshmallowPlugin(schema_name_resolver=lambda x: None)
16+
return MarshmallowPlugin()
1717

1818
@pytest.fixture
1919
def spec(marshmallow_plugin):
@@ -28,6 +28,10 @@ def spec(marshmallow_plugin):
2828
def openapi(marshmallow_plugin):
2929
return marshmallow_plugin.openapi
3030

31+
def ref_path(spec):
32+
if spec.openapi_version.version[0] < 3:
33+
return "#/definitions/"
34+
return "#/components/schemas/"
3135

3236
def test_error_if_spec_does_not_have_marshmallow_plugin(app):
3337
bad_spec = APISpec(
@@ -79,8 +83,7 @@ def test_params(self, app, path):
7983
def test_responses(self, schemas, path, openapi):
8084
response = path['get']['responses']['default']
8185
assert response['description'] == 'a band'
82-
expected = openapi.schema2jsonschema(schemas.BandSchema)
83-
assert response['schema'] == expected
86+
assert response['schema'] == {'$ref': ref_path(openapi.spec) + 'Band'}
8487

8588
def test_tags(self, path):
8689
assert path['get']['tags'] == ['band']
@@ -190,8 +193,7 @@ def test_params(self, app, path, openapi):
190193
def test_responses(self, schemas, path, openapi):
191194
response = path['get']['responses']['default']
192195
assert response['description'] == 'a band'
193-
expected = openapi.schema2jsonschema(schemas.BandSchema)
194-
assert response['schema'] == expected
196+
assert response['schema'] == {'$ref': ref_path(openapi.spec) + 'Band'}
195197

196198
def test_tags(self, path):
197199
assert path['get']['tags'] == ['band']

0 commit comments

Comments
 (0)