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

fix: Add json_tags_id_uppercase functionality to the JSON style PascalCase #3747

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions internal/codegen/golang/field.go
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ func SetJSONCaseStyle(name string, style string, idUppercase bool) string {
case "camel":
return toJsonCamelCase(name, idUppercase)
case "pascal":
return toPascalCase(name)
return toJsonPascalCase(name, idUppercase)
case "snake":
return toSnakeCase(name)
default:
@@ -95,6 +95,9 @@ func toCamelCase(s string) string {
func toPascalCase(s string) string {
return toCamelInitCase(s, true)
}
func toJsonPascalCase(s string, idUppercase bool) string {
return toJsonCamelInitCase(s, true, idUppercase)
}

func toCamelInitCase(name string, initUpper bool) string {
out := ""
@@ -113,6 +116,10 @@ func toCamelInitCase(name string, initUpper bool) string {
}

func toJsonCamelCase(name string, idUppercase bool) string {
return toJsonCamelInitCase(name, false, idUppercase)
}

func toJsonCamelInitCase(name string, initUpper bool, idUppercase bool) string {
out := ""
idStr := "Id"

@@ -121,7 +128,7 @@ func toJsonCamelCase(name string, idUppercase bool) string {
}

for i, p := range strings.Split(name, "_") {
if i == 0 {
if !initUpper && i == 0 {
out += p
continue
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Oops, something went wrong.