Skip to content

Commit

Permalink
fix: incorrect json key on enum variants with numbers (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk authored Jun 22, 2024
1 parent cac4d56 commit 08860bd
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pkg/codegen/properties.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ func generateFieldFromSchema(name, jsonKey string, schema *schemas.JSONSchema, r
panic(fmt.Errorf("cannot determine the name of the field for schema %v", schema))
}
pascalName := strcase.ToCamel(name)
snakeName := strcase.ToSnake(jsonKey)

typeStr, err := getType(pascalName, schema, required, typePrefix, true)
if err != nil {
Expand All @@ -38,9 +37,9 @@ func generateFieldFromSchema(name, jsonKey string, schema *schemas.JSONSchema, r
if useTags {
tags := map[string]string{}
if strings.HasPrefix(typeStr, "*") {
tags["json"] = snakeName + ",omitempty"
tags["json"] = jsonKey + ",omitempty"
} else {
tags["json"] = snakeName
tags["json"] = jsonKey
}

return jen.Id(pascalName).Op(typeStr).Tag(tags)
Expand Down

0 comments on commit 08860bd

Please sign in to comment.