Skip to content

Commit

Permalink
make function private
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleader committed Feb 16, 2024
1 parent b8e870c commit 8bc2099
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 5 additions & 2 deletions schema/oneof.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (o OneOfSchema[KeyType]) ApplyScope(scope Scope) {
t.ApplyScope(scope)
}
// scope must be applied before we can access the subtypes' properties
err := o.ValidateSubtypeDiscriminatorInlineFields()
err := o.validateSubtypeDiscriminatorInlineFields()
if err != nil {
panic(err)
}
Expand Down Expand Up @@ -409,7 +409,10 @@ func (o OneOfSchema[KeyType]) findUnderlyingType(data any) (KeyType, Object, err
return *foundKey, o.TypesValue[*foundKey], nil
}

func (o OneOfSchema[KeyType]) ValidateSubtypeDiscriminatorInlineFields() error {
// validateSubtypeDiscriminatorInlineFields checks to see if a subtype's
// discriminator field has been written in accordance with the OneOfSchema's
// declaration.
func (o OneOfSchema[KeyType]) validateSubtypeDiscriminatorInlineFields() error {
for key, typeValue := range o.TypesValue {
typeValueDiscriminatorValue, hasDiscriminator := typeValue.Properties()[o.DiscriminatorFieldNameValue]
switch {
Expand Down
1 change: 0 additions & 1 deletion schema/oneof_string_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,6 @@ func TestOneOf_InlinedStructMapped(t *testing.T) {
"A": inlinedTestObjectAMappedSchema,
"B": inlinedTestObjectBMappedSchema,
}, "d_type", true)
assert.NoError(t, oneofSchema.ValidateSubtypeDiscriminatorInlineFields())
serializedData := map[string]any{
"d_type": "A",
"other_field_a": "test",
Expand Down

0 comments on commit 8bc2099

Please sign in to comment.