Skip to content

Commit 365caf3

Browse files
committed
Properties are default optional but can be set to required. Fixes tests
1 parent 99c6720 commit 365caf3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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 << "optional" 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)