lutaml-model 0.8.175 → 0.8.177
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 +4 -4
- data/.github/workflows/release.yml +7 -0
- data/bench/baselines/main_mml.json +20 -20
- data/bench/baselines/main_niso.json +12 -12
- data/bench/baselines/main_sts.json +17 -17
- data/bench/baselines/main_unitsml.json +4 -4
- data/bench/baselines/main_xmi.json +20 -20
- data/lib/lutaml/json/generator_options.rb +10 -3
- data/lib/lutaml/model/schema/xml_compiler/spec_builder/members.rb +3 -1
- data/lib/lutaml/model/schema/xml_compiler/supported_data_types.rb +23 -0
- data/lib/lutaml/model/version.rb +1 -1
- data/lib/lutaml/xml/leptris/plan_compiler.rb +10 -0
- data/spec/lutaml/json/adapter/standard_adapter_spec.rb +11 -1
- data/spec/lutaml/model/generator_defaults_spec.rb +9 -2
- data/spec/lutaml/model/map_all_spec.rb +53 -0
- data/spec/lutaml/model/schema/xml_compiler_runtime_spec.rb +37 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 13419629c459d2ee88077db274555ff9fdca0e8bc316a108c807ebb7419a58b1
|
|
4
|
+
data.tar.gz: fc9b9f1d442fdcd8fa0055be53f6268467c7122e8c916962e40b8a622321807f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6175ce456fc919dd13b3eed5f081664a7bdd4326490d8a3cea79e95c848cefd670fbd39d523266410bc19861ca248f4091c2de0c945e48109352e7303ce29024
|
|
7
|
+
data.tar.gz: 3cf9f3519e927d623567b85b232a2407ae3e9454bed140feed8e2bf9f84cf47389803c5e01383f848a3accc39cc7d0f2ef4b57b1cc3dc4903c995f5a8f6305e3
|
|
@@ -12,6 +12,12 @@ on:
|
|
|
12
12
|
default: 'skip'
|
|
13
13
|
repository_dispatch:
|
|
14
14
|
types: [ do-release ]
|
|
15
|
+
# The publish leg: when the release PR (head branch release/v*) merges,
|
|
16
|
+
# metanorma/ci tags the merge commit and publishes (metanorma/ci#515).
|
|
17
|
+
# Ordinary PR closes are skipped inside the reusable workflow.
|
|
18
|
+
pull_request:
|
|
19
|
+
types:
|
|
20
|
+
- closed
|
|
15
21
|
|
|
16
22
|
# Least-privilege ceiling for the called rubygems-release.yml: its release job
|
|
17
23
|
# needs contents:write (git tag push) and id-token:write (OIDC Trusted Publishing).
|
|
@@ -19,6 +25,7 @@ on:
|
|
|
19
25
|
permissions:
|
|
20
26
|
contents: write
|
|
21
27
|
id-token: write
|
|
28
|
+
pull-requests: write
|
|
22
29
|
|
|
23
30
|
# One release at a time: concurrent bumps race the version commit
|
|
24
31
|
# and half-published gems are worse than a queued release.
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"complex1-46KB": {
|
|
3
|
-
"avg_time": 0.
|
|
4
|
-
"min_time": 0.
|
|
5
|
-
"max_time": 0.
|
|
6
|
-
"allocations":
|
|
7
|
-
"ips":
|
|
3
|
+
"avg_time": 0.038987152000004244,
|
|
4
|
+
"min_time": 0.03892064699999764,
|
|
5
|
+
"max_time": 0.0390598830000215,
|
|
6
|
+
"allocations": 51960,
|
|
7
|
+
"ips": 25.649475499002623
|
|
8
8
|
},
|
|
9
9
|
"complex4-50KB": {
|
|
10
|
-
"avg_time": 0.
|
|
11
|
-
"min_time": 0.
|
|
12
|
-
"max_time": 0.
|
|
13
|
-
"allocations":
|
|
14
|
-
"ips":
|
|
10
|
+
"avg_time": 0.054956423999991934,
|
|
11
|
+
"min_time": 0.054518438000002334,
|
|
12
|
+
"max_time": 0.055492561999983536,
|
|
13
|
+
"allocations": 73271,
|
|
14
|
+
"ips": 18.1962348933065
|
|
15
15
|
},
|
|
16
16
|
"size1000-245KB": {
|
|
17
|
-
"avg_time": 0.
|
|
18
|
-
"min_time": 0.
|
|
19
|
-
"max_time": 0.
|
|
20
|
-
"allocations":
|
|
21
|
-
"ips":
|
|
17
|
+
"avg_time": 0.30703477966667,
|
|
18
|
+
"min_time": 0.3045259649999821,
|
|
19
|
+
"max_time": 0.30771317600002135,
|
|
20
|
+
"allocations": 414471,
|
|
21
|
+
"ips": 3.2569600130826957
|
|
22
22
|
},
|
|
23
23
|
"complex3-567KB": {
|
|
24
|
-
"avg_time": 0.
|
|
25
|
-
"min_time": 0.
|
|
26
|
-
"max_time": 0.
|
|
27
|
-
"allocations":
|
|
28
|
-
"ips":
|
|
24
|
+
"avg_time": 0.42949195166667664,
|
|
25
|
+
"min_time": 0.4193377539999972,
|
|
26
|
+
"max_time": 0.433647494000013,
|
|
27
|
+
"allocations": 594058,
|
|
28
|
+
"ips": 2.3283323380552834
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"metrology-4KB": {
|
|
3
|
-
"avg_time": 0.
|
|
4
|
-
"min_time": 0.
|
|
5
|
-
"max_time": 0.
|
|
3
|
+
"avg_time": 0.014322055000017523,
|
|
4
|
+
"min_time": 0.01403489000006175,
|
|
5
|
+
"max_time": 0.014681618999929924,
|
|
6
6
|
"allocations": 7544,
|
|
7
|
-
"ips":
|
|
7
|
+
"ips": 69.82238233261752
|
|
8
8
|
},
|
|
9
9
|
"bmj-49KB": {
|
|
10
|
-
"avg_time": 0.
|
|
11
|
-
"min_time": 0.
|
|
12
|
-
"max_time": 0.
|
|
10
|
+
"avg_time": 0.135603055000009,
|
|
11
|
+
"min_time": 0.13427724500002114,
|
|
12
|
+
"max_time": 0.136363015000029,
|
|
13
13
|
"allocations": 72378,
|
|
14
|
-
"ips":
|
|
14
|
+
"ips": 7.374465125434923
|
|
15
15
|
},
|
|
16
16
|
"pnas-152KB": {
|
|
17
|
-
"avg_time": 0.
|
|
18
|
-
"min_time": 0.
|
|
19
|
-
"max_time": 0.
|
|
17
|
+
"avg_time": 0.6455222233333492,
|
|
18
|
+
"min_time": 0.6338481379999621,
|
|
19
|
+
"max_time": 0.6546388550000302,
|
|
20
20
|
"allocations": 259437,
|
|
21
|
-
"ips":
|
|
21
|
+
"ips": 1.5491333432894032
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"feature-doc-23KB": {
|
|
3
|
-
"avg_time": 0.
|
|
4
|
-
"min_time": 0.
|
|
5
|
-
"max_time": 0.
|
|
3
|
+
"avg_time": 0.04434376266667073,
|
|
4
|
+
"min_time": 0.04373320800002034,
|
|
5
|
+
"max_time": 0.04516191199999753,
|
|
6
6
|
"allocations": 32998,
|
|
7
|
-
"ips":
|
|
7
|
+
"ips": 22.55108587687827
|
|
8
8
|
},
|
|
9
9
|
"tbx-nisosts-101KB": {
|
|
10
|
-
"avg_time": 0.
|
|
11
|
-
"min_time": 0.
|
|
12
|
-
"max_time": 0.
|
|
10
|
+
"avg_time": 0.12491149966665678,
|
|
11
|
+
"min_time": 0.12318977799998265,
|
|
12
|
+
"max_time": 0.12502275199997825,
|
|
13
13
|
"allocations": 134786,
|
|
14
|
-
"ips":
|
|
14
|
+
"ips": 8.005668034317377
|
|
15
15
|
},
|
|
16
16
|
"iso-13849-1MB": {
|
|
17
|
-
"avg_time":
|
|
18
|
-
"min_time":
|
|
19
|
-
"max_time":
|
|
17
|
+
"avg_time": 4.2393353286666695,
|
|
18
|
+
"min_time": 4.14070454900002,
|
|
19
|
+
"max_time": 4.346694972999984,
|
|
20
20
|
"allocations": 1733464,
|
|
21
|
-
"ips": 0.
|
|
21
|
+
"ips": 0.23588603459554922
|
|
22
22
|
},
|
|
23
23
|
"din-iso-1.1MB": {
|
|
24
|
-
"avg_time": 0.
|
|
25
|
-
"min_time": 0.
|
|
26
|
-
"max_time": 0.
|
|
27
|
-
"allocations":
|
|
28
|
-
"ips": 1.
|
|
24
|
+
"avg_time": 0.553708032666672,
|
|
25
|
+
"min_time": 0.5457309070000065,
|
|
26
|
+
"max_time": 0.5579077530000234,
|
|
27
|
+
"allocations": 890629,
|
|
28
|
+
"ips": 1.8060059471847907
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"800-expressions": {
|
|
3
|
-
"avg_time": 0.
|
|
4
|
-
"min_time": 0.
|
|
5
|
-
"max_time": 0.
|
|
3
|
+
"avg_time": 0.20656500466666708,
|
|
4
|
+
"min_time": 0.20511490399999843,
|
|
5
|
+
"max_time": 0.20850260099999218,
|
|
6
6
|
"allocations": 134002,
|
|
7
|
-
"ips":
|
|
7
|
+
"ips": 4.84109107258364
|
|
8
8
|
}
|
|
9
9
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"ea251": {
|
|
3
|
-
"avg_time": 0.
|
|
4
|
-
"min_time": 0.
|
|
5
|
-
"max_time": 0.
|
|
6
|
-
"allocations":
|
|
7
|
-
"ips": 5.
|
|
3
|
+
"avg_time": 0.19469534333334573,
|
|
4
|
+
"min_time": 0.19171984600001224,
|
|
5
|
+
"max_time": 0.19764657100000704,
|
|
6
|
+
"allocations": 183576,
|
|
7
|
+
"ips": 5.136229674933004
|
|
8
8
|
},
|
|
9
9
|
"medium": {
|
|
10
|
-
"avg_time": 0.
|
|
11
|
-
"min_time": 0.
|
|
12
|
-
"max_time": 0.
|
|
13
|
-
"allocations":
|
|
14
|
-
"ips": 2.
|
|
10
|
+
"avg_time": 0.48711105866667026,
|
|
11
|
+
"min_time": 0.4837137160000111,
|
|
12
|
+
"max_time": 0.4910841039999809,
|
|
13
|
+
"allocations": 475118,
|
|
14
|
+
"ips": 2.052919929055233
|
|
15
15
|
},
|
|
16
16
|
"citygml": {
|
|
17
|
-
"avg_time": 0.
|
|
18
|
-
"min_time": 0.
|
|
19
|
-
"max_time": 0.
|
|
20
|
-
"allocations":
|
|
21
|
-
"ips": 1.
|
|
17
|
+
"avg_time": 0.5485396233333404,
|
|
18
|
+
"min_time": 0.5461445280000135,
|
|
19
|
+
"max_time": 0.5517981899999995,
|
|
20
|
+
"allocations": 587519,
|
|
21
|
+
"ips": 1.8230223624015454
|
|
22
22
|
},
|
|
23
23
|
"large": {
|
|
24
|
-
"avg_time": 4.
|
|
25
|
-
"min_time": 4.
|
|
26
|
-
"max_time": 4.
|
|
27
|
-
"allocations":
|
|
28
|
-
"ips": 0.
|
|
24
|
+
"avg_time": 4.595026431666658,
|
|
25
|
+
"min_time": 4.556988206999989,
|
|
26
|
+
"max_time": 4.632750786000003,
|
|
27
|
+
"allocations": 4538888,
|
|
28
|
+
"ips": 0.2176266045192891
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -13,11 +13,18 @@ module Lutaml
|
|
|
13
13
|
# JSON.generate.
|
|
14
14
|
module GeneratorOptions
|
|
15
15
|
# Options the generator accepts on both json 2.x and 3.x. Measured
|
|
16
|
-
# against 2.9.1, 2.15.2, 2.19.9, 2.20.0, 2.21.1, 2.21.2
|
|
17
|
-
# :escape_slash is NOT here because json 3.0 removed it
|
|
18
|
-
#
|
|
16
|
+
# against 2.9.1, 2.15.2, 2.19.9, 2.20.0, 2.21.1, 2.21.2, 3.0.0 and
|
|
17
|
+
# 3.2.0. :escape_slash is NOT here because json 3.0 removed it (and
|
|
18
|
+
# json 3.2 raises on it); on 2.x it still arrives via
|
|
19
|
+
# DERIVED_PERMITTED. :allow_duplicate_key IS here because the
|
|
19
20
|
# generator accepts it on every version while JSON::State never exposed
|
|
20
21
|
# it as an accessor, so the derived half alone would miss it.
|
|
22
|
+
#
|
|
23
|
+
# json 3.2 changed script_safe semantics: <, > and the line
|
|
24
|
+
# separators escape as \uXXXX (ECMAScript-conformant, same XSS
|
|
25
|
+
# protection) and the historical \/ slash escaping is dropped. The
|
|
26
|
+
# escape_slash translation stays load-bearing regardless - raw
|
|
27
|
+
# escape_slash raises on json 3.0+.
|
|
21
28
|
BASE_PERMITTED = %i[
|
|
22
29
|
allow_duplicate_key allow_nan array_nl as_json ascii_only
|
|
23
30
|
buffer_initial_length depth indent max_nesting object_nl script_safe
|
|
@@ -219,7 +219,9 @@ module Lutaml
|
|
|
219
219
|
when NilClass then 1
|
|
220
220
|
else max_occurs.to_i
|
|
221
221
|
end
|
|
222
|
-
|
|
222
|
+
# Optional singletons (minOccurs=0, maxOccurs=1) stay scalar:
|
|
223
|
+
# collections are for genuinely repeating members only.
|
|
224
|
+
return false if max == 1
|
|
223
225
|
|
|
224
226
|
(min..max)
|
|
225
227
|
end
|
|
@@ -53,6 +53,29 @@ module Lutaml
|
|
|
53
53
|
int: { skippable: true, class_name: TC[:integer] },
|
|
54
54
|
id: { skippable: false, class_name: TC[:string],
|
|
55
55
|
validations: { pattern: /\A[a-zA-Z_][\w.-]*\z/ } },
|
|
56
|
+
gYear: { skippable: true, class_name: TC[:string] },
|
|
57
|
+
gYearMonth: { skippable: true, class_name: TC[:string] },
|
|
58
|
+
gMonth: { skippable: true, class_name: TC[:string] },
|
|
59
|
+
gMonthDay: { skippable: true, class_name: TC[:string] },
|
|
60
|
+
gDay: { skippable: true, class_name: TC[:string] },
|
|
61
|
+
duration: { skippable: true, class_name: TC[:duration] },
|
|
62
|
+
dayTimeDuration: { skippable: true, class_name: TC[:day_time_duration] },
|
|
63
|
+
yearMonthDuration: { skippable: true, class_name: TC[:year_month_duration] },
|
|
64
|
+
negativeInteger: { skippable: false, class_name: TC[:integer],
|
|
65
|
+
validations: { max_inclusive: -1 } },
|
|
66
|
+
nonPositiveInteger: { skippable: false, class_name: TC[:integer],
|
|
67
|
+
validations: { max_inclusive: 0 } },
|
|
68
|
+
short: { skippable: false, class_name: TC[:integer],
|
|
69
|
+
validations: { min_inclusive: -32768, max_inclusive: 32767 } },
|
|
70
|
+
Name: { skippable: false, class_name: TC[:string],
|
|
71
|
+
validations: { pattern: /\A[a-zA-Z_:][\w.:-]*\z/ } },
|
|
72
|
+
QName: { skippable: true, class_name: TC[:qname] },
|
|
73
|
+
IDREF: { skippable: false, class_name: TC[:string],
|
|
74
|
+
validations: { pattern: /\A[a-zA-Z_][\w.-]*\z/ } },
|
|
75
|
+
IDREFS: { skippable: true, class_name: TC[:string] },
|
|
76
|
+
NMTOKEN: { skippable: false, class_name: TC[:string],
|
|
77
|
+
validations: { pattern: /\A[\w.:-]+\z/ } },
|
|
78
|
+
NMTOKENS: { skippable: true, class_name: TC[:string] },
|
|
56
79
|
}.freeze
|
|
57
80
|
|
|
58
81
|
module_function
|
data/lib/lutaml/model/version.rb
CHANGED
|
@@ -125,6 +125,16 @@ module Lutaml
|
|
|
125
125
|
# Wildcard attribute families ride the interpretive path too
|
|
126
126
|
return opt_out!(:all_attributes) if mapping.all_attributes_rule
|
|
127
127
|
|
|
128
|
+
# map_all (map_all_content) under a declared element
|
|
129
|
+
# hydrates content nil on the plan lane: the engine
|
|
130
|
+
# materializes raw captures only for element-less models,
|
|
131
|
+
# so the shape silently dropped content (lutaml-model#1167).
|
|
132
|
+
# The interpretive path's scoped capture handles it;
|
|
133
|
+
# per-element raw captures (map_element with raw: :element)
|
|
134
|
+
# keep the fast lane.
|
|
135
|
+
return opt_out!(:element_with_raw) if mapping.element_name &&
|
|
136
|
+
mapping.raw_mapping
|
|
137
|
+
|
|
128
138
|
rows = []
|
|
129
139
|
attr_rows = [] # [[rule, attr, row_name]] hydration metadata
|
|
130
140
|
plan_attrs = [] # [{name:, kind:}] rows for the engine plan
|
|
@@ -45,9 +45,19 @@ RSpec.describe Lutaml::Json::Adapter::StandardAdapter do
|
|
|
45
45
|
|
|
46
46
|
# json 3.0 removed :escape_slash. Dropping it would silently stop escaping
|
|
47
47
|
# slashes; it is the old alias of :script_safe, so it is translated.
|
|
48
|
+
# json 3.2's script_safe (the translation target) no longer escapes
|
|
49
|
+
# slashes - it escapes <, > and the line separators as \uXXXX, which
|
|
50
|
+
# is the same XSS protection in ECMAScript form. The translation to
|
|
51
|
+
# script_safe stays load-bearing: raw escape_slash raises on json
|
|
52
|
+
# 3.0+.
|
|
48
53
|
it "honours escape_slash on every json version" do
|
|
54
|
+
expected = if Gem::Version.new(JSON::VERSION) >= Gem::Version.new("3.2.0")
|
|
55
|
+
'{"a":"x/y"}'
|
|
56
|
+
else
|
|
57
|
+
'{"a":"x\\/y"}'
|
|
58
|
+
end
|
|
49
59
|
expect(described_class.new({ "a" => "x/y" }).to_json(escape_slash: true))
|
|
50
|
-
.to eq(
|
|
60
|
+
.to eq(expected)
|
|
51
61
|
end
|
|
52
62
|
|
|
53
63
|
# The filter is an allowlist, not a passthrough: genuine generator options
|
|
@@ -22,9 +22,16 @@ RSpec.describe "generator options reaching a nested model" do
|
|
|
22
22
|
let(:model) { EscapeProbe.new(s: "</script>é") }
|
|
23
23
|
|
|
24
24
|
describe "the stdlib adapter" do
|
|
25
|
+
# json 3.2 changed script_safe semantics: <, > and the line
|
|
26
|
+
# separators escape as \uXXXX (ECMAScript-conformant, same XSS
|
|
27
|
+
# protection) and the historical \/ slash escaping is dropped.
|
|
25
28
|
it "honours script_safe" do
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
expected = if Gem::Version.new(JSON::VERSION) >= Gem::Version.new("3.2.0")
|
|
30
|
+
'{"m":{"s":"\\u003c/script>é"}}'
|
|
31
|
+
else
|
|
32
|
+
'{"m":{"s":"<\\/script>é"}}'
|
|
33
|
+
end
|
|
34
|
+
expect(JSON.generate({ "m" => model }, script_safe: true)).to eq(expected)
|
|
28
35
|
end
|
|
29
36
|
|
|
30
37
|
it "honours ascii_only" do
|
|
@@ -185,6 +185,59 @@ module MapAllSpec
|
|
|
185
185
|
end
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
+
# lutaml-model#1167: a root model declaring element + map_all_content
|
|
189
|
+
# hydrates its content and round-trips exactly. The plan lane
|
|
190
|
+
# materializes raw captures only for element-less models, so this
|
|
191
|
+
# shape refuses the plan and rides the interpretive scoped capture.
|
|
192
|
+
it "captures content on a root model declaring element + map_all_content (#1167)" do
|
|
193
|
+
stubbed = Class.new(Lutaml::Model::Serializable) do
|
|
194
|
+
attribute :content, :string
|
|
195
|
+
|
|
196
|
+
xml do
|
|
197
|
+
element "body"
|
|
198
|
+
map_all_content to: :content
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
source = %(<body>hello <b>world</b></body>)
|
|
203
|
+
parsed = stubbed.from_xml(source)
|
|
204
|
+
expect(parsed.content).to eq("hello <b>world</b>")
|
|
205
|
+
|
|
206
|
+
out = stubbed.to_xml(parsed)
|
|
207
|
+
expect(out).to eq(source)
|
|
208
|
+
|
|
209
|
+
reparsed = stubbed.from_xml(out)
|
|
210
|
+
expect(reparsed.content).to eq(parsed.content)
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
it "captures content on an element+raw model embedded through a parent (#1167)" do
|
|
214
|
+
embedded = Class.new(Lutaml::Model::Serializable) do
|
|
215
|
+
attribute :content, :string
|
|
216
|
+
|
|
217
|
+
xml do
|
|
218
|
+
element "body"
|
|
219
|
+
map_all_content to: :content
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
holder = Class.new(Lutaml::Model::Serializable) do
|
|
224
|
+
attribute :body, embedded
|
|
225
|
+
|
|
226
|
+
xml do
|
|
227
|
+
element "holder"
|
|
228
|
+
map_element "body", to: :body
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
source = %(<holder><body>embedded & fine</body></holder>)
|
|
233
|
+
parsed = holder.from_xml(source)
|
|
234
|
+
expect(parsed.body.content).to eq("embedded & fine")
|
|
235
|
+
|
|
236
|
+
out = holder.to_xml(parsed)
|
|
237
|
+
expect(out).to include("embedded & fine")
|
|
238
|
+
expect(out).not_to include("<body/>")
|
|
239
|
+
end
|
|
240
|
+
|
|
188
241
|
describe "coexistence with other mappings (#223)" do
|
|
189
242
|
it "captures only unclaimed content alongside mapped elements" do
|
|
190
243
|
doc_class = Class.new(Lutaml::Model::Serializable) do
|
|
@@ -130,4 +130,41 @@ RSpec.describe "runtime XSD class loading" do
|
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
end
|
|
133
|
+
|
|
134
|
+
describe "builtin types and cardinality" do
|
|
135
|
+
let(:xsd) do
|
|
136
|
+
<<~XSD
|
|
137
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
138
|
+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
|
139
|
+
<xs:complexType name="ItemType">
|
|
140
|
+
<xs:sequence>
|
|
141
|
+
<xs:element name="title" type="xs:string"/>
|
|
142
|
+
<xs:element name="issued" type="xs:gYearMonth" minOccurs="0"/>
|
|
143
|
+
<xs:element name="note" type="xs:string" minOccurs="0"/>
|
|
144
|
+
</xs:sequence>
|
|
145
|
+
</xs:complexType>
|
|
146
|
+
<xs:element name="item" type="ItemType"/>
|
|
147
|
+
</xs:schema>
|
|
148
|
+
XSD
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
it "maps XSD builtins absent from the table (gYearMonth) and keeps
|
|
152
|
+
optional singletons scalar" do
|
|
153
|
+
sources = Lutaml::Model::Schema.from_xml(
|
|
154
|
+
xsd, output_dir: "builtin_types_models", load_classes: true
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
model_name = sources.keys.find { |n| n.include?("Item") }
|
|
158
|
+
doc = Object.const_get("BuiltinTypesModels::#{model_name}")
|
|
159
|
+
|
|
160
|
+
parsed = doc.from_xml("<item><title>T1</title><issued>2026-11</issued></item>")
|
|
161
|
+
expect(parsed.title).to eq("T1")
|
|
162
|
+
expect(parsed.issued).to eq("2026-11")
|
|
163
|
+
|
|
164
|
+
minimal = doc.from_xml("<item><title>T2</title></item>")
|
|
165
|
+
expect(minimal.title).to eq("T2")
|
|
166
|
+
# minOccurs=0, maxOccurs=1: scalar optional, not a collection
|
|
167
|
+
expect(minimal.note).to be_nil
|
|
168
|
+
end
|
|
169
|
+
end
|
|
133
170
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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.177
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-11-
|
|
11
|
+
date: 2026-11-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|