Handle LemmyTime fields
This commit is contained in:
parent
44dbe8c934
commit
4bc9ac9276
@ -52,7 +52,7 @@ func (s *StructGenerator) Generate(items []extractor.Struct) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getType(f extractor.Field) string {
|
func getType(f extractor.Field) string {
|
||||||
t := transformType(f.Type)
|
t := transformType(f.Name, f.Type)
|
||||||
if f.IsArray {
|
if f.IsArray {
|
||||||
t = "[]" + t
|
t = "[]" + t
|
||||||
}
|
}
|
||||||
@ -62,14 +62,21 @@ func getType(f extractor.Field) string {
|
|||||||
return t
|
return t
|
||||||
}
|
}
|
||||||
|
|
||||||
func transformType(s string) string {
|
func transformType(name, t string) string {
|
||||||
switch s {
|
// Some time fields are strings in the JS client,
|
||||||
|
// use LemmyTime for those
|
||||||
|
switch name {
|
||||||
|
case "published", "updated":
|
||||||
|
return "LemmyTime"
|
||||||
|
}
|
||||||
|
|
||||||
|
switch t {
|
||||||
case "number":
|
case "number":
|
||||||
return "float64"
|
return "float64"
|
||||||
case "boolean":
|
case "boolean":
|
||||||
return "bool"
|
return "bool"
|
||||||
default:
|
default:
|
||||||
return s
|
return t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +88,7 @@ func transformFieldName(s string) string {
|
|||||||
"Nsfw", "NSFW",
|
"Nsfw", "NSFW",
|
||||||
"Jwt", "JWT",
|
"Jwt", "JWT",
|
||||||
"Crud", "CRUD",
|
"Crud", "CRUD",
|
||||||
|
"Pm", "PM",
|
||||||
).Replace(s)
|
).Replace(s)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
2824
types/types.gen.go
2824
types/types.gen.go
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user