@@ -23,25 +23,25 @@ class Schema(ma.Schema):
2323 class Meta :
2424 unknown = EXCLUDE
2525
26- id = ma .Integer (default = 123 )
26+ id = ma .Integer (load_default = 123 , dump_default = 123 )
2727 name = ma .Str (required = True )
2828
2929
3030class Schema2 (ma .Schema ):
3131 class Meta :
3232 unknown = EXCLUDE
3333
34- id2 = ma .Integer (default = 123 )
34+ id2 = ma .Integer (load_default = 123 , dump_default = 123 )
3535 name2 = ma .Str (required = True )
3636
3737
3838class FooSchema (ma .Schema ):
39- id = ma .Integer (default = 123 )
39+ id = ma .Integer (load_default = 123 , dump_default = 123 )
4040 name = ma .Str ()
4141
4242
4343class QuerySchema (ma .Schema ):
44- id = ma .Integer (missing = 1 )
44+ id = ma .Integer (load_default = 1 )
4545
4646
4747class FormSchema (ma .Schema ):
@@ -140,6 +140,26 @@ def test_no_apispec_path(self):
140140 rv = client .get ('/apispec.json' )
141141 assert rv .status_code == 404
142142
143+ def test_custom_apispec_version (self ):
144+ app , _ = self .create_app (config = {'APIFAIRY_APISPEC_VERSION' : '3.1.0' })
145+
146+ client = app .test_client ()
147+ rv = client .get ('/apispec.json' )
148+ assert rv .status_code == 200
149+ assert set (rv .json .keys ()) == {
150+ 'openapi' , 'info' , 'servers' , 'paths' , 'tags' }
151+ assert rv .json ['openapi' ] == '3.1.0'
152+
153+ def test_custom_apispec_no_version (self ):
154+ app , _ = self .create_app (config = {'APIFAIRY_APISPEC_VERSION' : None })
155+
156+ client = app .test_client ()
157+ rv = client .get ('/apispec.json' )
158+ assert rv .status_code == 200
159+ assert set (rv .json .keys ()) == {
160+ 'openapi' , 'info' , 'servers' , 'paths' , 'tags' }
161+ assert rv .json ['openapi' ] == '3.0.3'
162+
143163 def test_ui (self ):
144164 app , _ = self .create_app (config = {'APIFAIRY_UI' : 'swagger_ui' })
145165
@@ -230,7 +250,7 @@ def foo(schema):
230250
231251 rv = client .post ('/foo' , json = {'name' : 'bar' })
232252 assert rv .status_code == 200
233- assert rv .json == {'name' : 'bar' }
253+ assert rv .json == {'id' : 123 , ' name' : 'bar' }
234254
235255 def test_body_form (self ):
236256 app , _ = self .create_app ()
0 commit comments