Skip to content

Commit

Permalink
Revert "Nullable transformer is obsolete (#68)"
Browse files Browse the repository at this point in the history
This reverts commit d6c120d.
  • Loading branch information
mkon committed Sep 15, 2023
1 parent d6c120d commit 9e4b97d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/openapi_contracts/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module OpenapiContracts
class Parser
autoload :Transformers, 'openapi_contracts/parser/transformers'

TRANSFORMERS = [Transformers::Pointer].freeze
TRANSFORMERS = [Transformers::Nullable, Transformers::Pointer].freeze

def self.call(dir, filename)
new(dir.join(filename)).parse
Expand Down
10 changes: 10 additions & 0 deletions lib/openapi_contracts/parser/transformers/nullable.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module OpenapiContracts::Parser::Transformers
class Nullable < Base
def call(object)
return unless object['type'].present? && object['nullable'] == true

object.delete('nullable')
object['type'] = [object['type'], 'null']
end
end
end

0 comments on commit 9e4b97d

Please sign in to comment.