Skip to content

Commit 08860bd

Browse files
authored
fix: incorrect json key on enum variants with numbers (#95)
1 parent cac4d56 commit 08860bd

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

pkg/codegen/properties.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ func generateFieldFromSchema(name, jsonKey string, schema *schemas.JSONSchema, r
2828
panic(fmt.Errorf("cannot determine the name of the field for schema %v", schema))
2929
}
3030
pascalName := strcase.ToCamel(name)
31-
snakeName := strcase.ToSnake(jsonKey)
3231

3332
typeStr, err := getType(pascalName, schema, required, typePrefix, true)
3433
if err != nil {
@@ -38,9 +37,9 @@ func generateFieldFromSchema(name, jsonKey string, schema *schemas.JSONSchema, r
3837
if useTags {
3938
tags := map[string]string{}
4039
if strings.HasPrefix(typeStr, "*") {
41-
tags["json"] = snakeName + ",omitempty"
40+
tags["json"] = jsonKey + ",omitempty"
4241
} else {
43-
tags["json"] = snakeName
42+
tags["json"] = jsonKey
4443
}
4544

4645
return jen.Id(pascalName).Op(typeStr).Tag(tags)

0 commit comments

Comments
 (0)