@@ -46,7 +46,7 @@ type GeneratorOption func(*jsonSchemaGenerator)
46
46
// WithJSONNames sets the generator to use JSON field names as the primary name.
47
47
func WithJSONNames () GeneratorOption {
48
48
return func (p * jsonSchemaGenerator ) {
49
- p .useJsonNames = true
49
+ p .useJSONNames = true
50
50
}
51
51
}
52
52
@@ -66,11 +66,11 @@ func Generate(input protoreflect.MessageDescriptor, opts ...GeneratorOption) map
66
66
type jsonSchemaGenerator struct {
67
67
result map [protoreflect.FullName ]map [string ]interface {}
68
68
custom map [protoreflect.FullName ]func (map [string ]interface {}, protoreflect.MessageDescriptor )
69
- useJsonNames bool
69
+ useJSONNames bool
70
70
}
71
71
72
72
func (p * jsonSchemaGenerator ) getID (desc protoreflect.Descriptor ) string {
73
- if p .useJsonNames {
73
+ if p .useJSONNames {
74
74
return string (desc .FullName ()) + ".jsonschema.json"
75
75
}
76
76
return string (desc .FullName ()) + ".schema.json"
@@ -110,18 +110,19 @@ func (p *jsonSchemaGenerator) generateDefault(result map[string]interface{}, des
110
110
// TODO: Add an option to include custom alias.
111
111
aliases := make ([]string , 0 , 1 )
112
112
113
- if visibility == FieldHide {
113
+ switch {
114
+ case visibility == FieldHide :
114
115
aliases = append (aliases , string (field .Name ()))
115
116
if field .JSONName () != string (field .Name ()) {
116
117
aliases = append (aliases , field .JSONName ())
117
118
}
118
- } else if p . useJsonNames {
119
+ case p . useJSONNames :
119
120
// Use the JSON name as the primary name.
120
- properties [string ( field .JSONName () )] = fieldSchema
121
+ properties [field .JSONName ()] = fieldSchema
121
122
if field .JSONName () != string (field .Name ()) {
122
123
aliases = append (aliases , string (field .Name ()))
123
124
}
124
- } else {
125
+ default :
125
126
// Use the proto name as the primary name.
126
127
properties [string (field .Name ())] = fieldSchema
127
128
if field .JSONName () != string (field .Name ()) {
0 commit comments