Skip to content

Commit

Permalink
Use array items type from validator
Browse files Browse the repository at this point in the history
  • Loading branch information
PanosCodes committed Dec 19, 2023
1 parent 05e3e0e commit acd8fc4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/apipie/generator/swagger/param_description/type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,15 @@ def for_array_type
'$ref' => reference_name
}
else
items = { type: 'string' }
type = Apipie::Generator::Swagger::TypeExtractor::TYPES[items_type.downcase.to_sym]

type = if type.present?
type
else
Apipie::Generator::Swagger::TypeExtractor::TYPES[:string]
end

items = { type: type.to_s }
end

enum = @param_description.options[:in]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,15 @@
it 'returns the reference' do
expect(subject).to eq({ '$ref' => reference })
end

end
end

context 'of a Swagger type' do
let(:validator_options) { { of: Integer } }

it { is_expected.to eq({ type: 'integer' }) }
end

describe 'enum' do
subject { items[:enum] }

Expand Down

0 comments on commit acd8fc4

Please sign in to comment.