@@ -151,7 +151,7 @@ def test_custom_apispec_version(self):
151151 assert rv .json ['openapi' ] == '3.1.0'
152152
153153 def test_custom_apispec_no_version (self ):
154- app , _ = self .create_app (config = { 'APIFAIRY_APISPEC_VERSION' : None } )
154+ app , _ = self .create_app ()
155155
156156 client = app .test_client ()
157157 rv = client .get ('/apispec.json' )
@@ -160,6 +160,22 @@ def test_custom_apispec_no_version(self):
160160 'openapi' , 'info' , 'servers' , 'paths' , 'tags' }
161161 assert rv .json ['openapi' ] == '3.0.3'
162162
163+ def test_custom_apispec_invalid_version (self ):
164+ app , _ = self .create_app (
165+ config = {'APIFAIRY_APISPEC_VERSION' : '4.0.0' })
166+
167+ client = app .test_client ()
168+ rv = client .get ('/apispec.json' )
169+ assert rv .status_code == 500
170+
171+ def test_custom_apispec_non_semver_version (self ):
172+ app , _ = self .create_app (
173+ config = {'APIFAIRY_APISPEC_VERSION' : 'invalid' })
174+
175+ client = app .test_client ()
176+ rv = client .get ('/apispec.json' )
177+ assert rv .status_code == 500
178+
163179 def test_ui (self ):
164180 app , _ = self .create_app (config = {'APIFAIRY_UI' : 'swagger_ui' })
165181
@@ -1014,7 +1030,8 @@ async def foo(query, body):
10141030 assert rv .json == {'id' : 2 , 'name' : 'foo' }
10151031
10161032 def test_webhook (self ):
1017- app , apifairy = self .create_app ()
1033+ app , apifairy = self .create_app (
1034+ config = {'APIFAIRY_APISPEC_VERSION' : '3.1.0' })
10181035 bp = Blueprint ('bp' , __name__ )
10191036
10201037 @webhook
@@ -1060,6 +1077,19 @@ def blueprint_webhook():
10601077 assert 'blueprint_webhook' in rv .json ['webhooks' ]
10611078 assert 'get' in rv .json ['webhooks' ]['blueprint_webhook' ]
10621079
1080+ def test_webhook_invalid_apispec_version (self ):
1081+ app , apifairy = self .create_app (
1082+ config = {'APIFAIRY_APISPEC_VERSION' : '3.0.3' })
1083+
1084+ @webhook
1085+ @body (Schema )
1086+ def unsupported_webhook ():
1087+ pass
1088+
1089+ client = app .test_client ()
1090+ rv = client .get ('/apispec.json' )
1091+ assert rv .status_code == 500
1092+
10631093 def test_webhook_duplicate (self ):
10641094 app , apifairy = self .create_app ()
10651095
0 commit comments