1212
1313
1414@with_generated_client_fixture (
15- """
15+ """
1616components:
1717 schemas:
1818 MyModel:
2929 properties:
3030 req3: {"type": "string"}
3131 required: ["req3"]
32- """ )
32+ """
33+ )
3334@with_generated_code_imports (
3435 ".models.MyModel" ,
3536 ".models.DerivedModel" ,
@@ -74,7 +75,7 @@ def test_type_hints(self, MyModel, Unset):
7475
7576
7677@with_generated_client_fixture (
77- """
78+ """
7879components:
7980 schemas:
8081 MyModel:
@@ -89,7 +90,8 @@ def test_type_hints(self, MyModel, Unset):
8990 anyProp: {}
9091 AnyObject:
9192 type: object
92- """ )
93+ """
94+ )
9395@with_generated_code_imports (
9496 ".models.MyModel" ,
9597 ".models.AnyObject" ,
@@ -104,7 +106,7 @@ def test_decode_encode(self, MyModel, AnyObject):
104106 "intProp" : 2 ,
105107 "anyObjectProp" : {"d" : 3 },
106108 "nullProp" : None ,
107- "anyProp" : "e"
109+ "anyProp" : "e" ,
108110 }
109111 expected_any_object = AnyObject ()
110112 expected_any_object .additional_properties = {"d" : 3 }
@@ -116,10 +118,10 @@ def test_decode_encode(self, MyModel, AnyObject):
116118 string_prop = "a" ,
117119 number_prop = 1.5 ,
118120 int_prop = 2 ,
119- any_object_prop = expected_any_object ,
121+ any_object_prop = expected_any_object ,
120122 null_prop = None ,
121123 any_prop = "e" ,
122- )
124+ ),
123125 )
124126
125127 @pytest .mark .parametrize (
@@ -144,7 +146,7 @@ def test_type_hints(self, MyModel, Unset):
144146
145147
146148@with_generated_client_fixture (
147- """
149+ """
148150components:
149151 schemas:
150152 MyModel:
@@ -154,7 +156,8 @@ def test_type_hints(self, MyModel, Unset):
154156 dateTimeProp: {"type": "string", "format": "date-time"}
155157 uuidProp: {"type": "string", "format": "uuid"}
156158 unknownFormatProp: {"type": "string", "format": "weird"}
157- """ )
159+ """
160+ )
158161@with_generated_code_imports (
159162 ".models.MyModel" ,
160163 ".types.Unset" ,
@@ -184,3 +187,59 @@ def test_type_hints(self, MyModel, Unset):
184187 assert_model_property_type_hint (MyModel , "date_time_prop" , Union [datetime .datetime , Unset ])
185188 assert_model_property_type_hint (MyModel , "uuid_prop" , Union [uuid .UUID , Unset ])
186189 assert_model_property_type_hint (MyModel , "unknown_format_prop" , Union [str , Unset ])
190+
191+
192+ @with_generated_client_fixture (
193+ """
194+ components:
195+ schemas:
196+ MyModel:
197+ type: object
198+ properties:
199+ booleanProp: {"type": "boolean"}
200+ stringProp: {"type": "string"}
201+ numberProp: {"type": "number"}
202+ intProp: {"type": "integer"}
203+ anyObjectProp: {"$ref": "#/components/schemas/AnyObject"}
204+ nullProp: {"type": "null"}
205+ anyProp: {}
206+ AnyObject:
207+ $ref: "#/components/schemas/OtherObject"
208+ OtherObject:
209+ $ref: "#/components/schemas/AnotherObject"
210+ AnotherObject:
211+ type: object
212+ properties:
213+ booleanProp: {"type": "boolean"}
214+
215+ """
216+ )
217+ @with_generated_code_imports (
218+ ".models.MyModel" ,
219+ ".models.AnyObject" ,
220+ ".types.Unset" ,
221+ )
222+ class TestReferenceSchemaProperties :
223+ def test_decode_encode (self , MyModel , AnyObject ):
224+ json_data = {
225+ "booleanProp" : True ,
226+ "stringProp" : "a" ,
227+ "numberProp" : 1.5 ,
228+ "intProp" : 2 ,
229+ "anyObjectProp" : {"booleanProp" : False },
230+ "nullProp" : None ,
231+ "anyProp" : "e" ,
232+ }
233+ assert_model_decode_encode (
234+ MyModel ,
235+ json_data ,
236+ MyModel (
237+ boolean_prop = True ,
238+ string_prop = "a" ,
239+ number_prop = 1.5 ,
240+ int_prop = 2 ,
241+ any_object_prop = AnyObject (boolean_prop = False ),
242+ null_prop = None ,
243+ any_prop = "e" ,
244+ ),
245+ )
0 commit comments