fix unknown type not handled and add go interface as recognizable type

This commit is contained in:
Ruben Fiszel
2022-11-07 20:51:57 +01:00
parent 8af10b6247
commit ff40ce2943
2 changed files with 22 additions and 1 deletions
+20 -1
View File
@@ -99,6 +99,11 @@ fn parse_go_typ(typ: &parser_go_ast::Expr) -> (Option<String>, Typ) {
Typ::Object(typs),
)
}
Expr::InterfaceType(_) => (Some("interface{}".to_string()), Typ::Object(vec![])),
Expr::MapType(_) => (
Some("map[string]interface{}".to_string()),
Typ::Object(vec![]),
),
_ => (None, Typ::Unknown),
}
}
@@ -122,7 +127,7 @@ package main
import "fmt"
func main(x int, y string, z bool, l []string, o struct { Name string `json:"name"` }) {
func main(x int, y string, z bool, l []string, o struct { Name string `json:"name"` }, n interface{}, m map[string]interface{}) {
fmt.Println("hello world")
}
@@ -172,6 +177,20 @@ func main(x int, y string, z bool, l []string, o struct { Name string `json:"nam
default: None,
has_default: false
},
Arg {
otyp: Some("interface{}".to_string()),
name: "n".to_string(),
typ: Typ::Object(vec![]),
default: None,
has_default: false
},
Arg {
otyp: Some("map[string]interface{}".to_string()),
name: "m".to_string(),
typ: Typ::Object(vec![]),
default: None,
has_default: false
},
]
}
);
+2
View File
@@ -113,6 +113,8 @@ function argSigToJsonSchemaType(
} else {
newS.items = { type: 'string' }
}
} else {
newS.type = 'object'
}
if (oldS.type != newS.type) {
for (const prop of Object.getOwnPropertyNames(newS)) {