Commit 54465f4
committed
Recover actual types from VariantCollectionCoercer in multi-type params
In Grape >= 3.3 `type: [A, B]` is wrapped in a VariantCollectionCoercer,
and Grape's documentation pipeline serialises that wrapper via #to_s
before storing it in route.params, which discards the original type
list. The previous behaviour exposed the coercer's #inspect string
(e.g. "#<Grape::Validations::Types::VariantCollectionCoercer:0x...>")
as the swagger type.
The live coercer is still reachable via the matching CoerceValidator's
@converter, so collect_variant_types walks namespace_stackable[:validations]
and builds a name => [types] lookup. When fulfill_params sees the
VariantCollectionCoercer signature in the serialised type, it substitutes
the real type list and lets the existing Array handling in
DataType.parse_multi_type pick the primary type, matching how older Grape
versions behaved when they passed the type array through directly.1 parent c7458b4 commit 54465f4
1 file changed
Lines changed: 37 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | | - | |
| 24 | + | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
51 | 78 | | |
52 | 79 | | |
53 | 80 | | |
| |||
57 | 84 | | |
58 | 85 | | |
59 | 86 | | |
| 87 | + | |
60 | 88 | | |
61 | 89 | | |
62 | 90 | | |
63 | 91 | | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
64 | 99 | | |
65 | 100 | | |
66 | 101 | | |
0 commit comments