Skip to content

Commit

Permalink
fix(gen): update generator due to schema parser changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tdakkota committed Nov 16, 2022
1 parent 4312761 commit d0efe6b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions gen/schema_gen_sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,14 +220,12 @@ func (g *schemaGen) oneOf(name string, schema *jsonschema.Schema) (*ir.Type, err
if !s.Is(ir.KindStruct, ir.KindMap) {
return nil, errors.Wrapf(&ErrNotImplemented{"unsupported sum type variant"}, "%q", s.Kind)
}
var ref string
if s.Schema != nil {
ref = s.Schema.Ref
} else {
ref = schema.OneOf[i].Ref
vschema := s.Schema
if vschema == nil {
vschema = schema.OneOf[i]
}

if ref == v || path.Base(ref) == v {
if vschema == v {
found = true
sum.SumSpec.Mapping = append(sum.SumSpec.Mapping, ir.SumSpecMap{
Key: k,
Expand All @@ -241,7 +239,7 @@ func (g *schemaGen) oneOf(name string, schema *jsonschema.Schema) (*ir.Type, err
}
}
if !found {
return nil, errors.Errorf("discriminator: unable to map %q to %q", k, v)
return nil, errors.Errorf("discriminator: unable to map %q to %q", k, v.Ref)
}
}
if len(sum.SumSpec.Mapping) == 0 {
Expand Down

0 comments on commit d0efe6b

Please sign in to comment.