Skip to content

Commit e4f78ab

Browse files
Merge pull request #1 from AdWerx/bugfix/apidoc-optional-parameters
API Blueprint view object respects required: false for parameters now
2 parents 229fe27 + 77126cd commit e4f78ab

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

features/api_blueprint_documentation.feature

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,12 @@ Feature: Generate API Blueprint documentation from test examples
354354
355355
+ Parameters
356356
+ id: 1 (required, string) - Order id
357-
+ optional
357+
+ optional (optional)
358358
359359
+ Attributes (object)
360360
+ name: a name (required) - The order name
361-
+ amount
362-
+ description: a description (string) - The order description
361+
+ amount (optional)
362+
+ description: a description (optional, string) - The order description
363363
364364
### Deletes a specific order [DELETE]
365365

lib/rspec_api_documentation/views/api_blueprint_index.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ def fields(property_name, examples)
7474
.uniq { |property| property[:name] }
7575
.map do |property|
7676
properties = []
77-
properties << "required" if property[:required]
77+
if property[:required] == true
78+
properties << 'required'
79+
else
80+
properties << 'optional'
81+
end
7882
properties << property[:type] if property[:type]
7983
if properties.count > 0
8084
property[:properties_description] = properties.join(", ")

spec/views/api_blueprint_index_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
}, {
144144
name: "option",
145145
description: nil,
146-
properties_description: nil
146+
properties_description: 'optional'
147147
}]
148148
expect(post_route_with_optionals[:has_attributes?]).to eq false
149149
expect(post_route_with_optionals[:attributes]).to eq []
@@ -159,7 +159,7 @@
159159
required: false,
160160
name: "description",
161161
description: nil,
162-
properties_description: nil
162+
properties_description: "optional"
163163
}]
164164
end
165165
end

0 commit comments

Comments
 (0)