You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use two schemas in oneOf with discriminator. I have several enum values for each discriminator fields in schemas. So can I use discriminator like this?
Now after generating types I get switch with only two cases in ValueByDiscriminator(). Furthermore, for case with ConfigHttp variable value selecting randomly from ConfigHttp keys
I found this break in generateUnion, if remove it and make len assertion by len(discriminator.Mapping) instead len(elements) my case will work. It is will fine?
if discriminator != nil {
if len(discriminator.Mapping) != 0 && element.Ref == "" {
return errors.New("ambiguous discriminator.mapping: please replace inlined object with $ref")
}
// Explicit mapping.
var mapped bool
for k, v := range discriminator.Mapping {
if v == element.Ref {
outSchema.Discriminator.Mapping[k] = elementSchema.GoType
mapped = true
break <------
}
}
// Implicit mapping.
if !mapped {
outSchema.Discriminator.Mapping[RefPathToObjName(element.Ref)] = elementSchema.GoType
}
}
The text was updated successfully, but these errors were encountered:
jKiler
added a commit
to jKiler/oapi-codegen
that referenced
this issue
Apr 8, 2024
I would like to use two schemas in oneOf with discriminator. I have several enum values for each discriminator fields in schemas. So can I use discriminator like this?
Now after generating types I get switch with only two cases in ValueByDiscriminator(). Furthermore, for case with ConfigHttp variable value selecting randomly from ConfigHttp keys
I found this break in
generateUnion
, if remove it and make len assertion by len(discriminator.Mapping) instead len(elements) my case will work. It is will fine?The text was updated successfully, but these errors were encountered: