File tree Expand file tree Collapse file tree 4 files changed +15
-3
lines changed
golden-record/my_test_api_client/models
openapi_python_client/parser/properties Expand file tree Collapse file tree 4 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 28232823 "propertyName" : " modelType" ,
28242824 "mapping" : {
28252825 "type1" : " #/components/schemas/ADiscriminatedUnionType1" ,
2826- "type2" : " #/components/schemas/ADiscriminatedUnionType2"
2826+ "type2" : " #/components/schemas/ADiscriminatedUnionType2" ,
2827+ "type2-another-value" : " #/components/schemas/ADiscriminatedUnionType2"
28272828 }
28282829 },
28292830 "oneOf" : [
Original file line number Diff line number Diff line change @@ -2817,7 +2817,8 @@ info:
28172817 " propertyName " : " modelType" ,
28182818 " mapping " : {
28192819 " type1 " : " #/components/schemas/ADiscriminatedUnionType1" ,
2820- " type2 " : " #/components/schemas/ADiscriminatedUnionType2"
2820+ " type2 " : " #/components/schemas/ADiscriminatedUnionType2" ,
2821+ " type2-another-value " : " #/components/schemas/ADiscriminatedUnionType2"
28212822 }
28222823 },
28232824 " oneOf " : [
Original file line number Diff line number Diff line change @@ -78,9 +78,17 @@ def _parse_2(data: object) -> ADiscriminatedUnionType2:
7878
7979 return componentsschemas_a_discriminated_union_type_1
8080
81+ def _parse_3 (data : object ) -> ADiscriminatedUnionType2 :
82+ if not isinstance (data , dict ):
83+ raise TypeError ()
84+ componentsschemas_a_discriminated_union_type_1 = ADiscriminatedUnionType2 .from_dict (data )
85+
86+ return componentsschemas_a_discriminated_union_type_1
87+
8188 _discriminator_mapping = {
8289 "type1" : _parse_1 ,
8390 "type2" : _parse_2 ,
91+ "type2-another-value" : _parse_3 ,
8492 }
8593 if _parse_fn := _discriminator_mapping .get (_discriminator_value ):
8694 return cast (
Original file line number Diff line number Diff line change @@ -308,7 +308,9 @@ def _get_model_name(model: ModelProperty) -> str | None:
308308 detail = f'Discriminator mapping referred to "{ name } " which is not one of the schema variants' ,
309309 )
310310 mapping [discriminator_value ] = mapped_model
311- unspecified_models .remove (mapped_model )
311+ if mapped_model in unspecified_models :
312+ # could've already been removed if more than one value is mapped to the same model
313+ unspecified_models .remove (mapped_model )
312314 for model in unspecified_models :
313315 if name := _get_model_name (model ):
314316 mapping [name ] = model
You can’t perform that action at this time.
0 commit comments