Skip to content

Commit

Permalink
fix(gen): merge discriminator
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Nov 17, 2022
1 parent df1dbe2 commit 31063c2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gen/schema_gen_sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ func mergeSchemes(s1, s2 *jsonschema.Schema) (_ *jsonschema.Schema, err error) {
Format: s1.Format,
Enum: enum,
Nullable: s1.Nullable || s2.Nullable,
Description: "Merged schema",
Description: "Merged schema", // TODO(tdakkota): handle in a better way.
}

switch {
Expand All @@ -546,6 +546,15 @@ func mergeSchemes(s1, s2 *jsonschema.Schema) (_ *jsonschema.Schema, err error) {
r.DefaultSet = true
}

switch d1, d2 := s1.Discriminator, s2.Discriminator; {
case d1 != nil && d2 != nil:
return nil, &ErrNotImplemented{"merge discriminator"} // TODO(tdakkota): implement
case d1 != nil:
r.Discriminator = d1
case d2 != nil:
r.Discriminator = d2
}

// Helper functions for comparing validation fields.
var (
someU64 = func(n1, n2 *uint64, both func(n1, n2 uint64) uint64) *uint64 {
Expand Down Expand Up @@ -751,7 +760,7 @@ func mergeProperties(p1, p2 []jsonschema.Property) ([]jsonschema.Property, error

propmap[p.Name] = jsonschema.Property{
Name: p.Name,
Description: "Merged property",
Description: "Merged property", // TODO(tdakkota): handle in a better way.
Schema: s,
Required: p.Required || confP.Required,
}
Expand Down

0 comments on commit 31063c2

Please sign in to comment.