Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion lib/soap/type.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ defmodule Soap.Type do

import SweetXml, except: [parse: 1]

@spec get_complex_types(String.t(), String.t()) :: map()
@spec get_complex_types(SweetXml.xmlElement() | String.t(), String.t()) :: map()
def get_complex_types(wsdl, x_path) do
wsdl
|> xpath(~x"#{x_path}"l)
Expand Down
22 changes: 11 additions & 11 deletions lib/soap/wsdl.ex
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ defmodule Soap.Wsdl do
{:ok, parsed_response}
end

@spec get_schema_namespace(String.t()) :: String.t()
@spec get_schema_namespace(SweetXml.xmlElement()) :: String.t()
defp get_schema_namespace(wsdl) do
{_, _, _, schema_namespace, _} =
wsdl
Expand All @@ -57,14 +57,14 @@ defmodule Soap.Wsdl do
schema_namespace
end

@spec get_namespaces(String.t(), String.t(), String.t()) :: map()
@spec get_namespaces(SweetXml.xmlElement(), String.t(), String.t()) :: map()
defp get_namespaces(wsdl, schema_namespace, protocol_ns) do
wsdl
|> xpath(~x"//#{ns("definitions", protocol_ns)}/namespace::*"l)
|> Enum.into(%{}, &get_namespace(&1, wsdl, schema_namespace, protocol_ns))
end

@spec get_namespace(tuple(), String.t(), String.t(), String.t()) :: tuple()
@spec get_namespace(tuple(), SweetXml.xmlElement(), String.t(), String.t()) :: tuple()
defp get_namespace(namespaces_node, wsdl, schema_namespace, protocol_ns) do
{_, _, _, key, value} = namespaces_node
string_key = key |> to_string
Expand All @@ -85,15 +85,15 @@ defmodule Soap.Wsdl do
end
end

@spec get_endpoint(String.t(), String.t(), String.t()) :: String.t()
@spec get_endpoint(SweetXml.xmlElement(), String.t(), String.t()) :: String.t()
def get_endpoint(wsdl, protocol_ns, soap_ns) do
wsdl
|> xpath(
~x"//#{ns("definitions", protocol_ns)}/#{ns("service", protocol_ns)}/#{ns("port", protocol_ns)}/#{ns("address", soap_ns)}/@location"s
)
end

@spec get_complex_types(String.t(), String.t(), String.t()) :: list()
@spec get_complex_types(SweetXml.xmlElement(), String.t(), String.t()) :: list()
defp get_complex_types(wsdl, namespace, protocol_ns) do
xpath(
wsdl,
Expand All @@ -103,7 +103,7 @@ defmodule Soap.Wsdl do
)
end

@spec get_validation_types(String.t(), String.t(), String.t(), String.t(), String.t(), keyword()) :: map()
@spec get_validation_types(SweetXml.xmlElement(), String.t(), String.t(), String.t(), String.t(), keyword()) :: map()
def get_validation_types(wsdl, file_path, protocol_ns, schema_ns, endpoint, opts \\ []) do
Map.merge(
Type.get_complex_types(
Expand All @@ -117,7 +117,7 @@ defmodule Soap.Wsdl do
)
end

@spec get_schema_imports(String.t(), String.t(), String.t()) :: list()
@spec get_schema_imports(SweetXml.xmlElement(), String.t(), String.t()) :: list()
def get_schema_imports(wsdl, protocol_ns, schema_ns) do
xpath(
wsdl,
Expand All @@ -126,7 +126,7 @@ defmodule Soap.Wsdl do
)
end

@spec get_full_paths(String.t(), String.t(), String.t(), String.t(), String.t()) :: list(String.t())
@spec get_full_paths(SweetXml.xmlElement(), String.t(), String.t(), String.t(), String.t()) :: list(String.t())
defp get_full_paths(wsdl, path, protocol_ns, schema_namespace, endpoint) do
wsdl
|> get_schema_imports(protocol_ns, schema_namespace)
Expand Down Expand Up @@ -209,15 +209,15 @@ defmodule Soap.Wsdl do
xpath(element, ~x"./#{ns("part", protocol_ns)}"l, name: ~x"./@name"s, element: ~x"./@element"s)
end

@spec get_protocol_namespace(String.t()) :: String.t()
@spec get_protocol_namespace(SweetXml.xmlElement()) :: String.t()
defp get_protocol_namespace(wsdl) do
wsdl
|> xpath(~x"//namespace::*"l)
|> Enum.find(fn {_, _, _, _, url} -> url == :"http://schemas.xmlsoap.org/wsdl/" end)
|> elem(3)
end

@spec get_soap_namespace(String.t(), list()) :: String.t()
@spec get_soap_namespace(SweetXml.xmlElement(), list()) :: String.t()
defp get_soap_namespace(wsdl, opts) when is_list(opts) do
version = soap_version(opts)
namespace = @soap_version_namespaces[version]
Expand All @@ -228,7 +228,7 @@ defmodule Soap.Wsdl do
|> elem(3)
end

@spec get_schema_attributes(String.t()) :: map()
@spec get_schema_attributes(SweetXml.xmlElement()) :: map()
defp get_schema_attributes(wsdl) do
case xpath(wsdl, ~x"//*[local-name() = 'schema']") do
nil ->
Expand Down