@@ -614,7 +614,7 @@ impl FieldType {
614
614
Self :: List ( field_type) | Self :: Set ( field_type) => {
615
615
format ! ( "List<{}>" , field_type. to_csharp_typename( ) ) . into ( )
616
616
}
617
- Self :: SchemaRef ( name) => name . clone ( ) . into ( ) ,
617
+ Self :: SchemaRef ( name) => filter_schema_ref ( name , "Object" ) ,
618
618
Self :: StringConst ( _) => "string" . into ( ) ,
619
619
}
620
620
}
@@ -634,7 +634,7 @@ impl FieldType {
634
634
Self :: List ( field_type) | Self :: Set ( field_type) => {
635
635
format ! ( "[]{}" , field_type. to_go_typename( ) ) . into ( )
636
636
}
637
- Self :: SchemaRef ( name) => name . clone ( ) . into ( ) ,
637
+ Self :: SchemaRef ( name) => filter_schema_ref ( name , "map[string]any" ) ,
638
638
Self :: StringConst ( _) => "string" . into ( ) ,
639
639
}
640
640
}
@@ -655,7 +655,7 @@ impl FieldType {
655
655
Self :: JsonObject => "Map<String,Any>" . into ( ) ,
656
656
Self :: List ( field_type) => format ! ( "List<{}>" , field_type. to_kotlin_typename( ) ) . into ( ) ,
657
657
Self :: Set ( field_type) => format ! ( "Set<{}>" , field_type. to_kotlin_typename( ) ) . into ( ) ,
658
- Self :: SchemaRef ( name) => name . clone ( ) . into ( ) ,
658
+ Self :: SchemaRef ( name) => filter_schema_ref ( name , "Map<String,Any>" ) ,
659
659
Self :: StringConst ( _) => "String" . into ( ) ,
660
660
}
661
661
}
@@ -675,7 +675,7 @@ impl FieldType {
675
675
Self :: Map { value_ty } => {
676
676
format ! ( "{{ [key: string]: {} }}" , value_ty. to_js_typename( ) ) . into ( )
677
677
}
678
- Self :: SchemaRef ( name) => name . clone ( ) . into ( ) ,
678
+ Self :: SchemaRef ( name) => filter_schema_ref ( name , "any" ) ,
679
679
Self :: StringConst ( _) => "string" . into ( ) ,
680
680
}
681
681
}
@@ -702,14 +702,23 @@ impl FieldType {
702
702
value_ty. to_rust_typename( ) ,
703
703
)
704
704
. into ( ) ,
705
- Self :: SchemaRef ( name) => name . clone ( ) . into ( ) ,
705
+ Self :: SchemaRef ( name) => filter_schema_ref ( name , "serde_json::Value" ) ,
706
706
Self :: StringConst ( _) => "String" . into ( )
707
707
}
708
708
}
709
709
710
710
pub ( crate ) fn referenced_schema ( & self ) -> Option < & str > {
711
711
match self {
712
- Self :: SchemaRef ( v) => Some ( v) ,
712
+ Self :: SchemaRef ( v) => {
713
+ // TODO: the `BackgroundTaskFinishedEvent2` struct has a field with type of `Data`
714
+ // this corresponds to a `#[serde(untagged)]` enum `svix_server::v1::endpoints::background_tasks::Data`
715
+ // we should change this server side, but for now I am changing it here
716
+ if v == "Data" {
717
+ None
718
+ } else {
719
+ Some ( v)
720
+ }
721
+ }
713
722
Self :: List ( ty) | Self :: Set ( ty) | Self :: Map { value_ty : ty } => ty. referenced_schema ( ) ,
714
723
_ => None ,
715
724
}
@@ -721,7 +730,7 @@ impl FieldType {
721
730
Self :: Int16 | Self :: UInt16 | Self :: Int32 | Self :: Int64 | Self :: UInt64 => "int" . into ( ) ,
722
731
Self :: String => "str" . into ( ) ,
723
732
Self :: DateTime => "datetime" . into ( ) ,
724
- Self :: SchemaRef ( name) => name. clone ( ) . into ( ) ,
733
+ Self :: SchemaRef ( name) => filter_schema_ref ( name, "t.Dict[str, t.Any]" ) ,
725
734
Self :: Uri => "str" . into ( ) ,
726
735
Self :: JsonObject => "t.Dict[str, t.Any]" . into ( ) ,
727
736
Self :: Set ( field_type) | Self :: List ( field_type) => {
@@ -752,7 +761,7 @@ impl FieldType {
752
761
FieldType :: Map { value_ty } => {
753
762
format ! ( "Map<String,{}>" , value_ty. to_java_typename( ) ) . into ( )
754
763
}
755
- FieldType :: SchemaRef ( name) => name . clone ( ) . into ( ) ,
764
+ FieldType :: SchemaRef ( name) => filter_schema_ref ( name , "Object" ) ,
756
765
// backwards compat
757
766
FieldType :: StringConst ( _) => "TypeEnum" . into ( ) ,
758
767
}
@@ -902,3 +911,14 @@ impl serde::Serialize for FieldType {
902
911
minijinja:: Value :: from_object ( self . clone ( ) ) . serialize ( serializer)
903
912
}
904
913
}
914
+
915
+ fn filter_schema_ref < ' a > ( name : & ' a String , json_obj_typename : & ' a str ) -> Cow < ' a , str > {
916
+ // TODO: the `BackgroundTaskFinishedEvent2` struct has a field with type of `Data`
917
+ // this corresponds to a `#[serde(untagged)]` enum `svix_server::v1::endpoints::background_tasks::Data`
918
+ // we should change this server side, but for now I am changing it here
919
+ if name == "Data" {
920
+ json_obj_typename. into ( )
921
+ } else {
922
+ name. clone ( ) . into ( )
923
+ }
924
+ }
0 commit comments