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

Remove field name decapitalization in the scheme #34

Merged
merged 2 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
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
9 changes: 2 additions & 7 deletions cmd/generator/scheme.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"go/types"
"io"
"strings"
"text/template"
)

Expand Down Expand Up @@ -42,10 +41,6 @@ func getAvroPrimitiveType(kind types.BasicKind) string {
}
}

func getAvroFieldName(name string) string {
return strings.ToLower(name[:1]) + name[1:]
}

type schemeGen struct {
Namespace string
Protocol string
Expand Down Expand Up @@ -78,15 +73,15 @@ func generateScheme(writer io.Writer, cfg schemeGenConfig) error {
schemeFields = append(schemeFields, schemeField{
Comment: f.docString,
Type: fmt.Sprintf("union {null, array<%s>}", getAvroPrimitiveType(f.fieldType)),
Name: getAvroFieldName(f.name),
Name: f.name,
})
} else if f.embeddedStruct {
createSchemeFields(f.embeddedStructFields)
} else {
schemeFields = append(schemeFields, schemeField{
Comment: f.docString,
Type: getAvroPrimitiveType(f.fieldType) + "?",
Name: getAvroFieldName(f.name),
Name: f.name,
})
}
}
Expand Down
32 changes: 16 additions & 16 deletions cmd/generator/tests/data.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -9,53 +9,53 @@


/** SomeString is a string field. */
string? someString = null;
string? SomeString = null;

/** SomeInt is an int64 field. */
long? someInt = null;
long? SomeInt = null;

/** SomeFloat is a float64 field.
More comments. */
double? someFloat = null;
double? SomeFloat = null;

/** SomeBool is a bool field. */
boolean? someBool = null;
boolean? SomeBool = null;

/** SomeStrings is a slice of strings. */
union {null, array<string>} someStrings = null;
union {null, array<string>} SomeStrings = null;

/** SomeInts is a slice of int64. */
union {null, array<long>} someInts = null;
union {null, array<long>} SomeInts = null;

/** SomeFloats is a slice of float64. */
union {null, array<double>} someFloats = null;
union {null, array<double>} SomeFloats = null;

/** SomeBools is a slice of bool. */
union {null, array<boolean>} someBools = null;
union {null, array<boolean>} SomeBools = null;

/** AnotherSomeString is a string field. */
string? anotherSomeString = null;
string? AnotherSomeString = null;

/** AnotherSomeInt is an int64 field. */
long? anotherSomeInt = null;
long? AnotherSomeInt = null;

/** AnotherSomeFloat is a float64 field. */
double? anotherSomeFloat = null;
double? AnotherSomeFloat = null;

/** AnotherSomeBool is a bool field. */
boolean? anotherSomeBool = null;
boolean? AnotherSomeBool = null;

/** AnotherSomeStrings is a slice of strings. */
union {null, array<string>} anotherSomeStrings = null;
union {null, array<string>} AnotherSomeStrings = null;

/** AnotherSomeInts is a slice of int64. */
union {null, array<long>} anotherSomeInts = null;
union {null, array<long>} AnotherSomeInts = null;

/** AnotherSomeFloats is a slice of float64. */
union {null, array<double>} anotherSomeFloats = null;
union {null, array<double>} AnotherSomeFloats = null;

/** AnotherSomeBools is a slice of bool. */
union {null, array<boolean>} anotherSomeBools = null;
union {null, array<boolean>} AnotherSomeBools = null;

}
}
Loading