Skip to content

Commit 5cb2057

Browse files
committed
Compatibility with apispec v1.0.0b3
1 parent 0981819 commit 5cb2057

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ language: python
22
cache: pip
33
sudo: false
44
env:
5-
- APISPEC_VERSION="==0.39.0"
5+
- APISPEC_VERSION="==1.0.0b3"
66
- APISPEC_VERSION=""
77
- MARSHMALLOW_VERSION="==2.13.0"
88
- MARSHMALLOW_VERSION=""

flask_apispec/extension.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class FlaskApiSpec(object):
2121
'APISPEC_SPEC': APISpec(
2222
title='pets',
2323
version='v1',
24+
openapi_version='2.0',
2425
plugins=[MarshmallowPlugin()],
2526
),
2627
'APISPEC_SWAGGER_URL': '/swagger/',
@@ -51,7 +52,8 @@ def init_app(self, app):
5152
self.app = app
5253
self.spec = self.app.config.get('APISPEC_SPEC') or \
5354
make_apispec(self.app.config.get('APISPEC_TITLE', 'flask-apispec'),
54-
self.app.config.get('APISPEC_VERSION', 'v1'))
55+
self.app.config.get('APISPEC_VERSION', 'v1'),
56+
self.app.config.get('APISPEC_OAS_VERSION', '2.0'))
5557
self.add_swagger_routes()
5658
self.resource_converter = ResourceConverter(self.app, spec=self.spec)
5759
self.view_converter = ViewConverter(app=self.app, spec=self.spec)
@@ -146,9 +148,10 @@ def _register(self, target, endpoint=None, blueprint=None,
146148
self.spec.add_path(**path)
147149

148150

149-
def make_apispec(title='flask-apispec', version='v1'):
151+
def make_apispec(title='flask-apispec', version='v1', openapi_version='2.0'):
150152
return APISpec(
151153
title=title,
152154
version=version,
155+
openapi_version=openapi_version,
153156
plugins=[MarshmallowPlugin()],
154157
)

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
'flask>=0.10.1',
1010
'marshmallow>=2.0.0',
1111
'webargs>=0.18.0',
12-
'apispec>=0.17.0,<1.0.0b1',
12+
'apispec==1.0.0b3',
1313
]
1414

1515
def find_version(fname):

tests/test_extension.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def test_serve_swagger_ui_custom_url(self, app, client):
9292
def test_apispec_config(self, app):
9393
app.config['APISPEC_TITLE'] = 'test-extension'
9494
app.config['APISPEC_VERSION'] = '2.1'
95+
app.config['APISPEC_OAS_VERSION'] = '2.0'
9596
docs = FlaskApiSpec(app)
9697

97-
assert docs.spec.info == {
98-
'title': 'test-extension',
99-
'version': '2.1',
100-
}
98+
assert docs.spec.title == 'test-extension'
99+
assert docs.spec.version == '2.1'
100+
assert docs.spec.openapi_version == '2.0'

tests/test_openapi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def spec(marshmallow_plugin):
2020
return APISpec(
2121
title='title',
2222
version='v1',
23+
openapi_version='2.0',
2324
plugins=[marshmallow_plugin],
2425
)
2526

@@ -32,6 +33,7 @@ def test_error_if_spec_does_not_have_marshmallow_plugin(app):
3233
bad_spec = APISpec(
3334
title='title',
3435
version='v1',
36+
openapi_version='2.0',
3537
plugins=[], # oh no! no MarshmallowPlugin
3638
)
3739
with pytest.raises(RuntimeError):

0 commit comments

Comments
 (0)