Skip to content

Commit

Permalink
Fix handling of result types used in bodies
Browse files Browse the repository at this point in the history
Only Collection result types need to be added to the generated roots.
Adding other result types to it causes their DSL to run twice and therefore
their views to get defined twice which causes the generation to fail.
  • Loading branch information
raphael committed Jul 12, 2024
1 parent 1b21c5a commit 5851c6f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions dsl/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,8 +959,8 @@ func Body(args ...any) {
}
attr = expr.DupAtt(attr)
attr.AddMeta("origin:attribute", a)
if rt, ok := attr.Type.(*expr.ResultTypeExpr); ok {
// If the attribute type is a result type add the type to the
if rt, ok := attr.Type.(*expr.ResultTypeExpr); ok && expr.IsArray(rt.Type) {
// If the attribute type is a result type collection add the type to the
// GeneratedTypes so that the type's DSLFunc is executed.
*expr.Root.GeneratedTypes = append(*expr.Root.GeneratedTypes, rt)
}
Expand Down

0 comments on commit 5851c6f

Please sign in to comment.