Generated field name casing is wrong in some cases
swalkerhppr opened this issue · 0 comments
swalkerhppr commented
Ogen has different casing rules than ent/entoas. If you have a field with any of the following, generation will fail because the ent/entoas casing is different.
rules = [...]string{
"ACL", "API", "ASCII", "AWS", "CPU", "CSS", "DNS", "EOF", "GB", "GUID",
"HTML", "HTTP", "HTTPS", "ID", "IP", "JSON", "KB", "LHS", "MAC", "MB",
"QPS", "RAM", "RHS", "RPC", "SLA", "SMTP", "SQL", "SSH", "SSO", "TLS",
"TTL", "UI", "UID", "URI", "URL", "UTF8", "UUID", "VM", "XML", "XMPP",
"XSRF", "XSS", "SMS", "CDN", "TCP", "UDP", "DC", "PFS", "P2P",
"SHA256", "SHA1", "MD5", "SRP", "2FA", "OAuth", "OAuth2",
"PNG", "JPG", "GIF", "MP4", "WEBP",
}
For instance, having a field called "md5" results in ret.Md5 = e.Md5
, but it should generate ret.MD5 = e.Md5
.
I looked for an easy way to convert a string to the ogen format, but it doesn't seem like there are any exported functions from ogen to apply the naming rules.
I am going to work around it by adding a lookup table in my fork, but I'm not sure if that is the full solution to the issue.