Skip to content

Commit

Permalink
FEAT: #61 configurable additionalProperties default value
Browse files Browse the repository at this point in the history
  • Loading branch information
hikari-desu committed Feb 8, 2020
1 parent 60c7485 commit 6dcd64e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/oas_objs/schema_obj.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ def recg_schema_type(t = self.type)
end

def additional_properties
return if processed[:type] != 'object' || _addProp.nil?
return if processed[:type] != 'object'
default = Config.additional_properties_default_value_of_type_object
return { additionalProperties: default } if _addProp.nil? && !default.nil?

value = _addProp.in?([true, false]) ? _addProp : SchemaObj.new(_addProp, { }).process
{ additionalProperties: value }
end
Expand Down
2 changes: 2 additions & 0 deletions lib/open_api/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ module Config

cattr_accessor(:file_format) { 'binary' }

cattr_accessor(:additional_properties_default_value_of_type_object) { nil }

def self.docs
open_api_docs
end
Expand Down

0 comments on commit 6dcd64e

Please sign in to comment.