Skip to content

Commit

Permalink
Merge pull request #933 from tdakkota/fix/merge-subschemas
Browse files Browse the repository at this point in the history
fix(gen): merge `allOf`  subschemas recursively
  • Loading branch information
ernado authored Jun 4, 2023
2 parents ff5ce51 + a921e37 commit c9a1eb9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions gen/schema_gen_sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,19 @@ func mergeSchemes(s1, s2 *jsonschema.Schema) (_ *jsonschema.Schema, err error) {
return s2, nil
}

if allOf := s1.AllOf; len(allOf) > 0 {
s1, err = mergeNSchemes(allOf)
if err != nil {
return nil, errors.Wrap(err, "merge subschemas")
}
}
if allOf := s2.AllOf; len(allOf) > 0 {
s2, err = mergeNSchemes(allOf)
if err != nil {
return nil, errors.Wrap(err, "merge subschemas")
}
}

containsValidators := func(s *jsonschema.Schema) bool {
if s.Type != "" || s.Format != "" || s.Nullable || len(s.Enum) > 0 || s.DefaultSet {
return true
Expand Down

0 comments on commit c9a1eb9

Please sign in to comment.