Skip to content

Commit 72c2461

Browse files
committed
Preparing for release, 0.7.0
1 parent 2ba3ae3 commit 72c2461

File tree

3 files changed

+56
-7
lines changed

3 files changed

+56
-7
lines changed

CHANGELOG.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
### 0.6.3 (Next)
1+
### 0.7.0 (2025/07/30)
22

33
#### Features
44

55
* [#81](https://github.com/ruby-grape/grape-swagger-entity/pull/81): Make entity fields required by default - [@olivier-thatch](https://github.com/olivier-thatch).
66
* [#85](https://github.com/ruby-grape/grape-swagger-entity/pull/85): Use rubocop plugins, use ruby 3.0 as minimum version everywhere - [@olivier-thatch](https://github.com/olivier-thatch).
7-
* Your contribution here.
8-
9-
#### Fixes
10-
11-
* Your contribution here.
127

138
### 0.6.2 (2025/05/10)
149

UPGRADING.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
## Upgrading grape-swagger-entity
2+
3+
### Upgrading to >= 0.7.0
4+
5+
#### Entity Fields Required by Default
6+
7+
This release changes how `grape-swagger-entity` determines if an entity field is
8+
**required** in the generated Swagger documentation. This is a **breaking change**
9+
and may require updates to your API documentation and any tools or tests that rely
10+
on the previous behavior.
11+
12+
**Previous Behavior:**
13+
Fields were considered optional by default unless explicitly marked as `required: true`
14+
in their `documentation` options.
15+
16+
**New Behavior:**
17+
Fields are now considered **required by default** unless one of the following
18+
conditions is met:
19+
20+
1. **`documentation: { required: false }` is explicitly set:** If you want a field to
21+
be optional, you must now explicitly set `required: false` within its
22+
`documentation` hash.
23+
```ruby
24+
expose :field_name,
25+
documentation: { type: String, required: false, desc: 'An optional field' }
26+
```
27+
2. **`if` or `unless` options are present:** If a field uses `if` or `unless` for
28+
conditional exposure, it will be considered optional.
29+
```ruby
30+
expose :conditional_field,
31+
if: -> { some_condition? },
32+
documentation: { type: String, desc: 'Exposed only if condition is met' }
33+
```
34+
3. **`expose_nil: false` is set:** If `expose_nil` is set to `false`, the field will
35+
be considered optional.
36+
```ruby
37+
expose :non_nil_field,
38+
expose_nil: false,
39+
documentation: { type: String, desc: 'Not exposed if nil' }
40+
```
41+
42+
This change aligns `grape-swagger-entity`'s behavior with `grape-entity`'s rendering
43+
logic, where fields are always exposed unless `if` or `unless` is provided.
44+
45+
**Action Required:**
46+
Review your existing Grape entities. If you have fields that were implicitly
47+
considered optional but did not explicitly set `required: false`, `if`, `unless`, or
48+
`expose_nil: false`, they will now be marked as required in your Swagger
49+
documentation.Adjust your `documentation` options accordingly to maintain the desired
50+
optionality for these fields.
51+
52+
For more details, refer to GitHub Pull Request
53+
[#81](https://github.com/ruby-grape/grape-swagger-entity/pull/81).
54+
````

lib/grape-swagger/entity/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module GrapeSwagger
44
module Entity
5-
VERSION = '0.6.3'
5+
VERSION = '0.7.0'
66
end
77
end

0 commit comments

Comments
 (0)