Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated field name casing is wrong in some cases #252

Open
swalkerhppr opened this issue Apr 22, 2024 · 0 comments
Open

Generated field name casing is wrong in some cases #252

swalkerhppr opened this issue Apr 22, 2024 · 0 comments

Comments

@swalkerhppr
Copy link

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",
	}

From: https://github.com/ogen-go/ogen/blob/425b5bb1ce73a9e48065457b7abcd9e424f8b2b5/internal/naming/rules.go#L14

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant