Skip to content

API Blueprint view object respects required: false for parameters now #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions features/api_blueprint_documentation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,12 @@ Feature: Generate API Blueprint documentation from test examples

+ Parameters
+ id: 1 (required, string) - Order id
+ optional
+ optional (optional)

+ Attributes (object)
+ name: a name (required) - The order name
+ amount
+ description: a description (string) - The order description
+ amount (optional)
+ description: a description (optional, string) - The order description

### Deletes a specific order [DELETE]

Expand Down
6 changes: 5 additions & 1 deletion lib/rspec_api_documentation/views/api_blueprint_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ def fields(property_name, examples)
.uniq { |property| property[:name] }
.map do |property|
properties = []
properties << "required" if property[:required]
if property[:required] == true
properties << 'required'
else
properties << 'optional'
end
properties << property[:type] if property[:type]
if properties.count > 0
property[:properties_description] = properties.join(", ")
Expand Down
4 changes: 2 additions & 2 deletions spec/views/api_blueprint_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
}, {
name: "option",
description: nil,
properties_description: nil
properties_description: 'optional'
}]
expect(post_route_with_optionals[:has_attributes?]).to eq false
expect(post_route_with_optionals[:attributes]).to eq []
Expand All @@ -159,7 +159,7 @@
required: false,
name: "description",
description: nil,
properties_description: nil
properties_description: "optional"
}]
end
end
Expand Down