Summary
When identifiers that differ only by case (e.g., "mHz" vs "MHz"), the generator emits duplicate identifiers names. This causes a compilation error for redeclared identifiers.
Minimal repro
Minimal Schema:
{
"title": "Frequency",
"unit": {
"type": "string",
"enum": ["mHz", "MHz"]
}
}
Command:
go-jsonschema -p main schema.json
Observed output
Generated constants include both of the following, which collide (redeclared identifier):
const SchemaJsonMHz SchemaJson = "mHz"
const SchemaJsonMHz SchemaJson = "MHz"
Expected behavior
Identifiers should be uniquely named even when values differ only by case.
Why this happens (preliminary analysis)
In internal/x/text/cases.go Identifierize() is calling c.Capitalize(Part)in order to normalizes the case, so both "mHz" and "MHz" become "MHz".
Environment
- go-jsonschema version: v0.22.0
- Go version: 1.25.5
Summary
When identifiers that differ only by case (e.g., "mHz" vs "MHz"), the generator emits duplicate identifiers names. This causes a compilation error for redeclared identifiers.
Minimal repro
Minimal Schema:
{ "title": "Frequency", "unit": { "type": "string", "enum": ["mHz", "MHz"] } }Command:
Observed output
Generated constants include both of the following, which collide (redeclared identifier):
Expected behavior
Identifiers should be uniquely named even when values differ only by case.
Why this happens (preliminary analysis)
In
internal/x/text/cases.goIdentifierize()is callingc.Capitalize(Part)in order to normalizes the case, so both "mHz" and "MHz" become "MHz".Environment