lutaml-model 0.8.142 → 0.8.143
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 27c27a6e43a54c69e89e08cdeb8f749992155bc6ea072d5ccb1ba9867de9fc92
|
|
4
|
+
data.tar.gz: aab282e0b42b4a811529b58ab6b2dd5e8ab40287498802683c5283cfc6b55bdc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5b6b43e0792d190536c648d6eebf21d7021e1a4f5c84f687f02394ee98b02dc255fd628c9cf07c130dab442a6f19eada2afaab7f1f7172806cb03cbff38ff836
|
|
7
|
+
data.tar.gz: 492f737e7ebddc49e140e454a78a01b4c240ef463de21cd0a0040b4b9048657125642eb7a9f2211a5842fe9311a9dfd627506209acbd9b17656fc6f27c4d4ad5
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -17,8 +17,8 @@ module Lutaml
|
|
|
17
17
|
namespace Lutaml::Xml::Schema::XsdNamespace
|
|
18
18
|
|
|
19
19
|
map_attribute :id, to: :id
|
|
20
|
-
map_attribute :
|
|
21
|
-
map_attribute :
|
|
20
|
+
map_attribute :maxOccurs, to: :max_occurs
|
|
21
|
+
map_attribute :minOccurs, to: :min_occurs
|
|
22
22
|
map_element :annotation, to: :annotation
|
|
23
23
|
map_element :element, to: :element
|
|
24
24
|
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "../../../../spec_helper"
|
|
4
|
+
require "lutaml/xml/schema/xsd"
|
|
5
|
+
|
|
6
|
+
# #1046: xs:all carried its occurrence bounds mapped by their Ruby names
|
|
7
|
+
# (min_occurs/max_occurs), so minOccurs="0" was silently dropped at parse
|
|
8
|
+
# and never re-emitted. Sequence, choice and group already map the XML
|
|
9
|
+
# names; all now does too.
|
|
10
|
+
RSpec.describe "Xsd::All occurrence attributes" do
|
|
11
|
+
let(:xsd) do
|
|
12
|
+
<<~XSD
|
|
13
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
|
14
|
+
<xsd:element name="elt1">
|
|
15
|
+
<xsd:complexType>
|
|
16
|
+
<xsd:all minOccurs="0" maxOccurs="1">
|
|
17
|
+
<xsd:element name="elt2"/>
|
|
18
|
+
</xsd:all>
|
|
19
|
+
</xsd:complexType>
|
|
20
|
+
</xsd:element>
|
|
21
|
+
</xsd:schema>
|
|
22
|
+
XSD
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "reads the occurrence bounds" do
|
|
26
|
+
doc = Lutaml::Xml::Schema::Xsd.parse(xsd)
|
|
27
|
+
all = doc.element.first.complex_type.all
|
|
28
|
+
|
|
29
|
+
expect(all.min_occurs).to eq("0")
|
|
30
|
+
expect(all.max_occurs).to eq("1")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "round-trips them as the XML attribute names" do
|
|
34
|
+
xml = Lutaml::Xml::Schema::Xsd.parse(xsd).to_xml
|
|
35
|
+
|
|
36
|
+
expect(xml).to include('minOccurs="0"')
|
|
37
|
+
expect(xml).to include('maxOccurs="1"')
|
|
38
|
+
expect(xml).not_to include("min_occurs")
|
|
39
|
+
expect(xml).not_to include("max_occurs")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "keeps an xs:all without bounds boundless" do
|
|
43
|
+
doc = Lutaml::Xml::Schema::Xsd.parse(
|
|
44
|
+
<<~XSD,
|
|
45
|
+
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
|
|
46
|
+
<xsd:element name="elt1">
|
|
47
|
+
<xsd:complexType>
|
|
48
|
+
<xsd:all><xsd:element name="elt2"/></xsd:all>
|
|
49
|
+
</xsd:complexType>
|
|
50
|
+
</xsd:element>
|
|
51
|
+
</xsd:schema>
|
|
52
|
+
XSD
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
all = doc.element.first.complex_type.all
|
|
56
|
+
|
|
57
|
+
expect(all.min_occurs).to be_nil
|
|
58
|
+
expect(all.max_occurs).to be_nil
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -14,6 +14,15 @@ require "lutaml/xml/schema/xsd"
|
|
|
14
14
|
# registered model's element and attribute rules to declared attributes
|
|
15
15
|
# so the whole typo family fails here, at spec time.
|
|
16
16
|
RSpec.describe "XSD schema model mapping integrity" do
|
|
17
|
+
# The registry fills at class-definition time and Xsd.parse is what
|
|
18
|
+
# force-loads the classes; without this hook the sweeps below see an
|
|
19
|
+
# empty register whenever they run before any parsing spec.
|
|
20
|
+
before do
|
|
21
|
+
Lutaml::Xml::Schema::Xsd::XSD_AUTOLOAD_CLASSES.each do |name|
|
|
22
|
+
Lutaml::Xml::Schema::Xsd.const_get(name) unless name == :VERSION
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
17
26
|
it "maps every element rule of every registered model to a declared attribute" do
|
|
18
27
|
broken = []
|
|
19
28
|
|
|
@@ -60,6 +69,34 @@ RSpec.describe "XSD schema model mapping integrity" do
|
|
|
60
69
|
MSG
|
|
61
70
|
end
|
|
62
71
|
|
|
72
|
+
# #1046 family: xs:all mapped its occurrence bounds by their Ruby names
|
|
73
|
+
# (min_occurs/max_occurs), so minOccurs="0" was dropped at parse. The
|
|
74
|
+
# XSD vocabulary has no snake_case attribute names — every multi-word
|
|
75
|
+
# XML attribute is camelCase — so a snake_case rule name is always a
|
|
76
|
+
# Ruby name that leaked into the wire.
|
|
77
|
+
it "spells every multi-word XML attribute name in camelCase" do
|
|
78
|
+
broken = []
|
|
79
|
+
|
|
80
|
+
Lutaml::Xml::Schema::Xsd.register.models.each_value do |klass|
|
|
81
|
+
next unless klass.is_a?(Class) && klass.include?(Lutaml::Model::Serialize)
|
|
82
|
+
|
|
83
|
+
mapping = klass.mappings_for(:xml)
|
|
84
|
+
mapping.mapping_attributes_hash.each_value do |rule_or_array|
|
|
85
|
+
Array(rule_or_array).each do |rule|
|
|
86
|
+
next unless rule.name.to_s.include?("_")
|
|
87
|
+
|
|
88
|
+
broken << "#{klass.name}: map_attribute #{rule.name.inspect} -> " \
|
|
89
|
+
"#{rule.to.inspect}"
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
expect(broken).to be_empty, <<~MSG
|
|
95
|
+
attribute rules spelled with snake_case wire names:
|
|
96
|
+
#{broken.join("\n")}
|
|
97
|
+
MSG
|
|
98
|
+
end
|
|
99
|
+
|
|
63
100
|
# #1025: the regression that motivated the sweep — a redefine with a
|
|
64
101
|
# group child parses, and each redefined member kind lands on its
|
|
65
102
|
# declared attribute.
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lutaml-model
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.143
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -2047,6 +2047,7 @@ files:
|
|
|
2047
2047
|
- spec/lutaml/xml/schema/facet_round_trip_spec.rb
|
|
2048
2048
|
- spec/lutaml/xml/schema/rnc_compiler_spec.rb
|
|
2049
2049
|
- spec/lutaml/xml/schema/rng_compiler_spec.rb
|
|
2050
|
+
- spec/lutaml/xml/schema/xsd/all_occurrence_attributes_spec.rb
|
|
2050
2051
|
- spec/lutaml/xml/schema/xsd/any_attribute_spec.rb
|
|
2051
2052
|
- spec/lutaml/xml/schema/xsd/errors/error_context_spec.rb
|
|
2052
2053
|
- spec/lutaml/xml/schema/xsd/errors/suggestion_spec.rb
|