Skip to content

Commit f55a486

Browse files
author
Antoine Pelisse
committed
Rename discriminatedBy into discriminatorValue
1 parent 09abe0b commit f55a486

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

merge/union_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ var unionFieldsParser = func() typed.ParseableType {
5050
deduceInvalidDiscriminator: true
5151
fields:
5252
- fieldName: numeric
53-
discriminatedBy: Numeric
53+
discriminatorValue: Numeric
5454
- fieldName: string
55-
discriminatedBy: String
55+
discriminatorValue: String
5656
- fields:
5757
- fieldName: fieldA
58-
discriminatedBy: FieldA
58+
discriminatorValue: FieldA
5959
- fieldName: fieldB
60-
discriminatedBy: FieldB`)
60+
discriminatorValue: FieldB`)
6161
if err != nil {
6262
panic(err)
6363
}

schema/elements.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@ type UnionField struct {
126126
// FieldName is the name of the field that is part of the union. This
127127
// is the serialized form of the field.
128128
FieldName string `yaml:"fieldName"`
129-
// DiscriminatedBy is the value of the discriminator to select that
130-
// field. If the union doesn't have a discriminator, this field is
131-
// ignored.
132-
DiscriminatedBy string `yaml:"discriminatedBy"`
129+
// Discriminatorvalue is the value of the discriminator to
130+
// select that field. If the union doesn't have a discriminator,
131+
// this field is ignored.
132+
DiscriminatorValue string `yaml:"discriminatorValue"`
133133
}
134134

135135
// Union, or oneof, means that only one of multiple fields of a structure can be

schema/schemaschema.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ var SchemaSchemaYAML = `types:
9696
- name: fieldName
9797
type:
9898
scalar: string
99-
- name: discriminatedBy
99+
- name: discriminatorValue
100100
type:
101101
scalar: string
102102
- name: union

typed/union.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func newUnion(su *schema.Union) *union {
203203
f2d := map[field]discriminated{}
204204
for _, f := range su.Fields {
205205
u.f = append(u.f, field(f.FieldName))
206-
f2d[field(f.FieldName)] = discriminated(f.DiscriminatedBy)
206+
f2d[field(f.FieldName)] = discriminated(f.DiscriminatorValue)
207207
}
208208
u.dn = newDiscriminatedName(f2d)
209209
u.deduceInvalidDiscriminator = su.DeduceInvalidDiscriminator

typed/union_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,17 @@ var unionParser = func() typed.ParseableType {
5353
deduceInvalidDiscriminator: true
5454
fields:
5555
- fieldName: one
56-
discriminatedBy: One
56+
discriminatorValue: One
5757
- fieldName: two
58-
discriminatedBy: TWO
58+
discriminatorValue: TWO
5959
- fieldName: three
60-
discriminatedBy: three
60+
discriminatorValue: three
6161
- discriminator: letter
6262
fields:
6363
- fieldName: a
64-
discriminatedBy: A
64+
discriminatorValue: A
6565
- fieldName: b
66-
discriminatedBy: b`)
66+
discriminatorValue: b`)
6767
if err != nil {
6868
panic(err)
6969
}

0 commit comments

Comments
 (0)