wsdl_validator 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -2
- data/lib/wsdl_validator/version.rb +1 -1
- data/lib/wsdl_validator/wsdl_validator.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e61229620248d68120457e216e9bf637a668f173
|
4
|
+
data.tar.gz: 11248c53b4e99f0b9390738e19713f15b69716e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eddd3f7e6bd2c42e26fb448bcad7b22d71fd8aafcc731d7b564e9f158cfb4fee3940b7b972685f5f91a96fc85f6f38ff9251cc6e9a54d703407679d58e2ff06a
|
7
|
+
data.tar.gz: 2514dd49a99e037ad0eceb47bd0edfb9f0c94e647809d9f30b172fe9de33e2a83f872ad4eb0106b32712a8dae217572d7e5f62bd1c4df008b38e604079595b56
|
data/README.md
CHANGED
@@ -30,6 +30,11 @@ wsdl.valid? xml_message
|
|
30
30
|
```
|
31
31
|
=> Returns true or false
|
32
32
|
|
33
|
+
# TODO
|
34
|
+
* Exception returned for invalid xsd
|
35
|
+
* Look up schemas that need to be imported
|
36
|
+
* Basic authentication for reading schemas
|
37
|
+
|
33
38
|
## Development
|
34
39
|
|
35
40
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -38,7 +43,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
38
43
|
|
39
44
|
## Contributing
|
40
45
|
|
41
|
-
Bug reports and pull requests are welcome on
|
46
|
+
Bug reports and pull requests are welcome on GitLab at https://gitlab.com/samuel-garratt/wsdl_validator. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
42
47
|
|
43
48
|
## License
|
44
49
|
|
@@ -46,4 +51,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
46
51
|
|
47
52
|
## Code of Conduct
|
48
53
|
|
49
|
-
Everyone interacting in the WsdlValidator project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://
|
54
|
+
Everyone interacting in the WsdlValidator project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/samuel-garratt/wsdl_validator/blob/master/CODE_OF_CONDUCT.md).
|
@@ -6,11 +6,23 @@ class WsdlValidator
|
|
6
6
|
@schemas = @doc.parser.schemas.collect(&:to_s).join
|
7
7
|
end
|
8
8
|
|
9
|
+
# This is not the ideal approach. Ideally Nokogiri parser would be able to understand SOAP xsd as well
|
10
|
+
# @return [Nokogiri::XML::Document] Retrieve root element from SOAP
|
11
|
+
def extract_root_from_soap(envelope)
|
12
|
+
body = envelope.children.find { |child| child.name == 'Body' }
|
13
|
+
root_element = body.children.reject { |child| child.is_a?(Nokogiri::XML::Text) }.first
|
14
|
+
envelope.namespaces.each { |namespace, value| root_element[namespace] = value }
|
15
|
+
body.namespaces.each { |namespace, value| root_element[namespace] = value }
|
16
|
+
Nokogiri::XML root_element.to_s # Convert to Xml Document
|
17
|
+
end
|
18
|
+
|
9
19
|
# @param [String, Nokogiri::XML::NodeSet] xml
|
10
20
|
# @return [Boolean] Whether xml is valid according to WSDL of class
|
11
21
|
def valid?(xml)
|
12
22
|
raise "Incorrect type #{xml.class}" unless [String, Nokogiri::XML::Document, Nokogiri::XML::NodeSet].include? xml.class
|
13
23
|
xml_under_test = Nokogiri::XML(xml.to_s)
|
24
|
+
soap_envelope = xml_under_test.children.find { |e| e.name == 'Envelope' }
|
25
|
+
xml_under_test = extract_root_from_soap(soap_envelope) if soap_envelope
|
14
26
|
xsd = Nokogiri::XML::Schema(@schemas)
|
15
27
|
validator = xsd.validate(xml_under_test)
|
16
28
|
validator.each { |error| puts error.message }
|
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.
|
4
|
+
version: 0.1.3
|
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-
|
11
|
+
date: 2018-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|