Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#### Fixes

* Your contribution here.
* [#82](https://github.com/ruby-grape/grape-swagger-entity/pull/82): Fix: recognize grape::api::boolean as a primitive type - [@numbata](https://github.com/numbata).

### 0.6.1 (2025/05/06)

Expand Down
2 changes: 1 addition & 1 deletion lib/grape-swagger/entity/attribute_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class AttributeParser
attr_reader :endpoint

# The list of that doesn't handled by `GrapeSwagger::DocMethods::DataType.primitive?` method
ADDITIONAL_PRIMITIVE_TYPES = %w[string array].freeze
ADDITIONAL_PRIMITIVE_TYPES = %w[boolean string array].freeze

def initialize(endpoint)
@endpoint = endpoint
Expand Down
18 changes: 18 additions & 0 deletions spec/grape-swagger/entity/attribute_parser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,24 @@ def self.to_s
it { is_expected.not_to include('$ref') }
end

context 'when it is exposed as a Boolean class' do
let(:entity_options) do
{ documentation: { type: Grape::API::Boolean, example: example_value, default: example_value } }
end

context 'when the example value is true' do
let(:example_value) { true }

it { is_expected.to include(type: 'boolean', example: example_value, default: example_value) }
end

context 'when the example value is false' do
let(:example_value) { false }

it { is_expected.to include(type: 'boolean', example: example_value, default: example_value) }
end
end

context 'when it is exposed as a boolean' do
let(:entity_options) { { documentation: { type: 'boolean', example: example_value, default: example_value } } }

Expand Down