wsdl_validator 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5721216e68fd329ead13d82fec5844311619ca1
4
- data.tar.gz: 664b2b8714a805638a1a007abfe4b99074017346
3
+ metadata.gz: d2ec12d204a349daf90dc9839b67b986079dd304
4
+ data.tar.gz: 2aa63bbe06189c30fe0edcf05ffa87cb2ae27b76
5
5
  SHA512:
6
- metadata.gz: 99de3efea0b7c0eb1ab80ba1197dc478eee9aed2b2986ed16d7538d8a093867842637fdc45d03d128d10e990b50b461ffc6319b2baeb203bb84db669c6045f30
7
- data.tar.gz: 3dde01fa78cb78f157d245e2b2af649320cd45a30fd6c608e5e6b91950491864cfad3805e00d6fe0c1f7e799f4459d02e9112bdfcc43bc1784c483fe6bf6934d
6
+ metadata.gz: fdad29cc37bf6f4b7d90f2a76a56df60be4b786678aec21374df1bbf1ccf258dc5dbd9b13a2fae62d085f28687645db05c8fd14f0b003110283b7085566f2b6d
7
+ data.tar.gz: 4733883570c6f93f93d730fbd755d13467acfe7b74c498e81153b0e2e4784eb939c0b8dab12a7a675b750a71ef5d035ad4beae2ec14563bb42c3fc47ecc87250
@@ -1,3 +1,3 @@
1
1
  class WsdlValidator
2
- VERSION = '0.1.7'.freeze
2
+ VERSION = '0.1.8'.freeze
3
3
  end
@@ -17,9 +17,12 @@ class WsdlValidator
17
17
  self.doc = Wasabi.document wsdl_url
18
18
  self.show_schemas = parse_wsdl_schemas
19
19
  self.schemas = Nokogiri::XML::Schema(show_schemas)
20
- rescue Wasabi::Resolver::HTTPError => e
21
- raise WsdlValidator::Error, "Unauthorized for basic auth #{basic_auth}" if e.response.code == 401
22
- raise e
20
+ rescue Wasabi::Resolver::HTTPError => resolver
21
+ raise WsdlValidator::Error, "Unauthorized for basic auth #{basic_auth}" if resolver.response.code == 401
22
+ raise resolver
23
+ rescue Nokogiri::XML::SyntaxError => syntax_error
24
+ puts "Error for " + show_schemas
25
+ raise syntax_error
23
26
  end
24
27
 
25
28
  # Gets the namespaces from the SOAP Envelope & Body element, adds them to the root element underneath the body
@@ -70,18 +73,31 @@ class WsdlValidator
70
73
  end
71
74
 
72
75
  # Join all the schemas within the WSDL, importing schemas if necessary
73
- # @return [String] Schemas contained within WSDL
76
+ # @return [String] Schema XML contained within WSDL
74
77
  def parse_wsdl_schemas
75
78
  doc.parser.schemas.collect do |schema|
76
79
  imports = schema.children.select { |child| child.name == 'import' }
77
80
  imported_xsds = imports.collect do |import|
78
81
  extract_schema_for(import)
79
82
  end.join
80
- schema = Nokogiri::XML(imported_xsds).children unless imported_xsds.empty?
81
- schema.to_s
83
+ if imported_xsds.empty?
84
+ add_global_namespace_to(schema)
85
+ else
86
+ imported_schemas = Nokogiri::XML(imported_xsds).children
87
+ updated_set = imported_schemas.collect { |imported_schema| add_global_namespace_to(imported_schema) }
88
+ updated_set.join
89
+ end.to_s
82
90
  end.join
83
91
  end
84
92
 
93
+ # Add namespaces from wsdl document to each schema
94
+ # Sometimes schemas are defined there and referenced within the types
95
+ # @return [String] String representing XML with global schemas added
96
+ def add_global_namespace_to(schema)
97
+ doc.parser.document.collect_namespaces.each { |namespace, value| schema[namespace] = value }
98
+ schema.to_s
99
+ end
100
+
85
101
  # Makes a GET request returning the xsd from the defined location
86
102
  # @return [String] Schema from location defined in 'schemaLocation' attribute
87
103
  def extract_schema_for(import)
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency 'bundler', '~> 1.16'
30
30
  spec.add_development_dependency 'rake', '~> 10.0'
31
31
  spec.add_development_dependency 'rspec', '~> 3.0'
32
+ spec.add_development_dependency 'savon'
32
33
  spec.add_development_dependency 'simplecov'
33
34
  spec.add_development_dependency 'sinatra'
34
35
  spec.add_development_dependency 'sinatra-basic-auth'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wsdl_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-30 00:00:00.000000000 Z
11
+ date: 2018-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpi
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: savon
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: simplecov
99
113
  requirement: !ruby/object:Gem::Requirement