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
Grape 3.2+ introduced breaking changes that raise when Grape.deprecator.behavior
= :raise: desc rejects a positional options Hash, params blocks reject string type
names and classes without .parse, and type: [A, B] params are serialised via
VariantCollectionCoercer#to_s, leaking the coercer's inspect string into swagger
output instead of the declared type.
- Pass keyword arguments to both desc calls in doc_methods.rb. Accept string-keyed
api_documentation hashes and :description as an alias for :desc.
- Add .parse shims to NestedModule::ApiResponse in the mock and representable
parsers. Move type: 'Object' in params_example_spec into documentation: {}.
- Recover the actual type list from VariantCollectionCoercer via
stackable_values[:validations] in the Route param parser. Handles both the
Hash-entry shape (Grape 3.2+) and the CoerceValidator object shape (older
versions). Canary tests guard the private-ivar contract.
- Bump minimum Grape to >= 2.1 (1.8/2.0 fail on Ruby 3.3+ upstream) and expand
upper bound to < 5.0 for Grape 4.x. Update CI matrix accordingly.
api_documentation: { desc:'Reticulated splines API swagger-compatible documentation.' }
499
500
```
500
501
502
+
`:description` is accepted as an alias for `:desc` (when both are supplied, `:desc` wins; an explicit `desc: nil` is respected and does not fall through). String keys (e.g. when loading from YAML/JSON) are accepted too.
503
+
501
504
#### specific_api_documentation
502
505
503
506
Customize the Swagger API specific documentation route, typically contains a `desc` field. The default description is "Swagger compatible API description for specific API".
Copy file name to clipboardExpand all lines: UPGRADING.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,26 @@
1
1
## Upgrading Grape-swagger
2
2
3
+
### Upgrading to >= 2.2.0
4
+
5
+
-**Minimum Grape version is now `>= 2.1`** (was `>= 1.7`). Grape 1.8.0 and 2.0.0 cannot be used on Ruby 3.3+ because of an upstream Mustermann/forwardable incompatibility; the CI rows for those combinations were already failing on `master` and have been removed.
6
+
-**`type: 'Object'` (and other string type names) in `params` blocks**: Grape 3.2+ rejects string type names. If you previously declared a swagger-only documentation hint via `params { optional :foo, type: 'Object' }`, move the type under `documentation:`:
7
+
8
+
```ruby
9
+
optional :foo, documentation: { type:'Object' }
10
+
```
11
+
12
+
grape-swagger picks the type up from the merged settings unchanged, so the swagger output is identical.
13
+
-**Custom type classes** used via `type: MyClass` must implement `MyClass.parse(value)` (arity 1) on Grape 3.2+; otherwise Grape's dry-types lookup raises `ArgumentError`. `Grape::Entity` already provides `parse`; `Representable::Decorator` and plain Ruby classes need to define it explicitly:
14
+
15
+
```ruby
16
+
classMyType
17
+
defself.parse(value) =new(value)
18
+
# ...
19
+
end
20
+
```
21
+
22
+
-**Multi-type params (`type: [A, B]`) on Grape 3.2+**: swagger output now reflects the first declared type (e.g. `type: [Integer, Float]` produces `"integer"`). Previously, Grape 3.2+ serialized the `VariantCollectionCoercer` wrapper via `#to_s`, leaking `"#<Grape::Validations::Types::VariantCollectionCoercer:0x...>"` into the documentation. No action required, but if you were programmatically post-processing that string, the fix will change the output.
23
+
3
24
### Upgrading to >= x.y.z
4
25
5
26
- Grape-swagger now documents array parameters within an object schema in Swagger. This aligns with grape's JSON structure requirements and ensures the documentation is correct.
0 commit comments