lutaml-model 0.8.56 → 0.8.57
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: 6c9021265ddf0425193ec4ce5656b3209e73291534bac83f7863494ca5dd2f55
|
|
4
|
+
data.tar.gz: d389a3ad85a1d8b72d953df5cf3ff6b0728625aeabc9ebd6563163ee44374071
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8580ac7ac155d6d72a008b7f29c1f6e8001b45f1e19235c863d53b8f23bf84cf7953b5bbdd2e1b57f9056e583cb49fad114f9487b82eb331172a88a3b071fcd2
|
|
7
|
+
data.tar.gz: c74e408cc7a50c3b7badc51cd3ca3711a54c41dfe0fdedf2f37f3a3232a6ec615a92539befc891b9d3235c0ed873aadc674f58fcc8d542032da03d436baba9a6
|
|
@@ -103,7 +103,8 @@ module Lutaml
|
|
|
103
103
|
|
|
104
104
|
register = Lutaml::Model::Config.default_register
|
|
105
105
|
plan = Lutaml::Xml::PlanCompiler.compile(self, register)
|
|
106
|
-
return nil unless plan &&
|
|
106
|
+
return nil unless plan && !plan[:namespaced] &&
|
|
107
|
+
Lutaml::Xml::PlanSerializer.serializable?(plan)
|
|
107
108
|
|
|
108
109
|
Lutaml::Xml::PlanSerializer.call(instance, plan)
|
|
109
110
|
end
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -213,6 +213,12 @@ module Lutaml
|
|
|
213
213
|
|
|
214
214
|
row_tags = partition_row_tags!(compiled, rows, tag)
|
|
215
215
|
|
|
216
|
+
# The plan serializer does not emit namespace declarations —
|
|
217
|
+
# namespaced models serialize through the interpretive
|
|
218
|
+
# writer (lutaml-model#847: standalone to_xml under leptris
|
|
219
|
+
# dropped the element xmlns entirely).
|
|
220
|
+
namespaced = !model_ns.nil? || rows.any? { |r| r[:ns] }
|
|
221
|
+
|
|
216
222
|
flags = []
|
|
217
223
|
flags << :cdata if cdata
|
|
218
224
|
flags << :mixed_content if mixed_content
|
|
@@ -233,7 +239,7 @@ module Lutaml
|
|
|
233
239
|
|
|
234
240
|
{ descriptor: descriptor, tree: tree, rows: compiled,
|
|
235
241
|
attr_rows: attr_rows, mapping: mapping,
|
|
236
|
-
row_tags: row_tags,
|
|
242
|
+
row_tags: row_tags, namespaced: namespaced,
|
|
237
243
|
ordered: mapping.ordered? || mapping.mixed_content?,
|
|
238
244
|
needs_nodes: needs_nodes,
|
|
239
245
|
collection_defaults: collection_defaults }
|
|
@@ -688,4 +688,29 @@ RSpec.describe "XML plan fast path" do
|
|
|
688
688
|
expect(parsed.to_xml).to eq(xml)
|
|
689
689
|
end
|
|
690
690
|
end
|
|
691
|
+
|
|
692
|
+
# lutaml-model#847: the plan serializer does not emit namespace
|
|
693
|
+
# declarations — namespaced models must serialize through the
|
|
694
|
+
# interpretive writer even standalone, or the element xmlns is lost.
|
|
695
|
+
it "falls back to the interpretive writer for namespaced models" do
|
|
696
|
+
ns = Class.new(Lutaml::Xml::Namespace) do
|
|
697
|
+
uri "http://example.com/ord847"
|
|
698
|
+
end
|
|
699
|
+
stub_const("PlanFastPath::Ord847Ns", ns)
|
|
700
|
+
klass = Class.new(Lutaml::Model::Serializable) do
|
|
701
|
+
attribute :value, :boolean
|
|
702
|
+
xml do
|
|
703
|
+
element "updateFields"
|
|
704
|
+
namespace PlanFastPath::Ord847Ns
|
|
705
|
+
map_attribute "val", to: :value
|
|
706
|
+
end
|
|
707
|
+
end
|
|
708
|
+
stub_const("PlanFastPath::UpdateFields847", klass)
|
|
709
|
+
|
|
710
|
+
expect(klass.new(value: false).to_xml).to include("http://example.com/ord847")
|
|
711
|
+
plan = Lutaml::Xml::PlanCompiler.compile(
|
|
712
|
+
klass, Lutaml::Model::Config.default_register
|
|
713
|
+
)
|
|
714
|
+
expect(plan[:namespaced]).to be(true)
|
|
715
|
+
end
|
|
691
716
|
end
|