From 77e84881da3fd8cc66a662f7c7d1ca66a068729d Mon Sep 17 00:00:00 2001 From: Adam Grare Date: Tue, 15 Jun 2021 16:31:04 -0400 Subject: [PATCH] Improve wsdl to vmodl type handling --- devel/verify-vim-wsdl.rb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/devel/verify-vim-wsdl.rb b/devel/verify-vim-wsdl.rb index 074fe56..695544a 100755 --- a/devel/verify-vim-wsdl.rb +++ b/devel/verify-vim-wsdl.rb @@ -45,11 +45,16 @@ def dump_vmodl(vmodl, path) File.write(path, Marshal.dump(vmodl)) end -def wsdl_to_vmodl_type(wsdl_type) - vmodl_type = 'ManagedObject' if wsdl_type == 'ManagedObjectReference' - vmodl_type ||= "xsd:#{wsdl_type}" if %w[boolean byte dateTime int long string].include?(wsdl_type) - vmodl_type ||= wsdl_type if "RbVmomi::BasicTypes::#{wsdl_type}".safe_constantize || "RbVmomi::VIM::#{wsdl_type}".safe_constantize - raise if vmodl_type.nil? +def wsdl_to_vmodl_type(type) + case type.source + when /vim25:/ + vmodl_type = type.name + vmodl_type = 'ManagedObject' if vmodl_type == 'ManagedObjectReference' + when /xsd:/ + vmodl_type = type.source + else + raise ArgumentError, "Unrecognized wsdl type: [#{type}]" + end vmodl_type end @@ -103,7 +108,7 @@ def wsdl_constantize(type) 'is-optional' => element.minoccurs == 0, 'is-array' => element.maxoccurs != 1, 'version-id-ref' => nil, - 'wsdl_type' => wsdl_to_vmodl_type(element.type.name) + 'wsdl_type' => wsdl_to_vmodl_type(element.type) } end, 'wsdl_base' => type.complexcontent.extension.base.name