Skip to content

Commit 6572bb4

Browse files
committed
Merge openapi:typename Meta keys into the Payload and Result DSL calls if none is provided. This seems like quite a big hammer approach to this problem and this is reflected in the number of tests that are failing as a result of this.
1 parent f0108a7 commit 6572bb4

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

dsl/payload.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package dsl
22

33
import (
4+
"fmt"
5+
46
"goa.design/goa/v3/eval"
57
"goa.design/goa/v3/expr"
68
)
@@ -78,7 +80,16 @@ func Payload(val any, args ...any) {
7880
eval.IncompatibleDSL()
7981
return
8082
}
83+
84+
// Set the result openapi:typename key explicitly from the method name
85+
if v, ok := val.(expr.UserType); ok {
86+
if v.Attribute().Meta == nil {
87+
v.Attribute().Meta = make(expr.MetaExpr)
88+
}
89+
v.Attribute().Meta.Merge(expr.MetaExpr{"openapi:typename": []string{fmt.Sprintf("%sRequestBody", e.Name)}})
90+
}
8191
e.Payload = methodDSL(e, "Payload", val, args...)
92+
8293
}
8394

8495
// StreamingPayload defines a method that accepts a stream of instances of the

dsl/result.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package dsl
22

33
import (
4+
"fmt"
5+
46
"goa.design/goa/v3/eval"
57
"goa.design/goa/v3/expr"
68
)
@@ -80,6 +82,13 @@ func Result(val any, args ...any) {
8082
eval.IncompatibleDSL()
8183
return
8284
}
85+
// Set the result openapi:typename key explicitly from the method name
86+
if v, ok := val.(expr.UserType); ok {
87+
if v.Attribute().Meta == nil {
88+
v.Attribute().Meta = make(expr.MetaExpr)
89+
}
90+
v.Attribute().Meta.Merge(expr.MetaExpr{"openapi:typename": []string{fmt.Sprintf("%sRequestBody", e.Name)}})
91+
}
8392
e.Result = methodDSL(e, "Result", val, args...)
8493
}
8594

0 commit comments

Comments
 (0)