Skip to content

Commit fea3f70

Browse files
committed
lint
1 parent 43fbaeb commit fea3f70

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

internal/protoschema/jsonschema/jsonschema.go

+8-7
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type GeneratorOption func(*jsonSchemaGenerator)
4646
// WithJSONNames sets the generator to use JSON field names as the primary name.
4747
func WithJSONNames() GeneratorOption {
4848
return func(p *jsonSchemaGenerator) {
49-
p.useJsonNames = true
49+
p.useJSONNames = true
5050
}
5151
}
5252

@@ -66,11 +66,11 @@ func Generate(input protoreflect.MessageDescriptor, opts ...GeneratorOption) map
6666
type jsonSchemaGenerator struct {
6767
result map[protoreflect.FullName]map[string]interface{}
6868
custom map[protoreflect.FullName]func(map[string]interface{}, protoreflect.MessageDescriptor)
69-
useJsonNames bool
69+
useJSONNames bool
7070
}
7171

7272
func (p *jsonSchemaGenerator) getID(desc protoreflect.Descriptor) string {
73-
if p.useJsonNames {
73+
if p.useJSONNames {
7474
return string(desc.FullName()) + ".jsonschema.json"
7575
}
7676
return string(desc.FullName()) + ".schema.json"
@@ -110,18 +110,19 @@ func (p *jsonSchemaGenerator) generateDefault(result map[string]interface{}, des
110110
// TODO: Add an option to include custom alias.
111111
aliases := make([]string, 0, 1)
112112

113-
if visibility == FieldHide {
113+
switch {
114+
case visibility == FieldHide:
114115
aliases = append(aliases, string(field.Name()))
115116
if field.JSONName() != string(field.Name()) {
116117
aliases = append(aliases, field.JSONName())
117118
}
118-
} else if p.useJsonNames {
119+
case p.useJSONNames:
119120
// Use the JSON name as the primary name.
120-
properties[string(field.JSONName())] = fieldSchema
121+
properties[field.JSONName()] = fieldSchema
121122
if field.JSONName() != string(field.Name()) {
122123
aliases = append(aliases, string(field.Name()))
123124
}
124-
} else {
125+
default:
125126
// Use the proto name as the primary name.
126127
properties[string(field.Name())] = fieldSchema
127128
if field.JSONName() != string(field.Name()) {

0 commit comments

Comments
 (0)