polyxml 0.34.5__tar.gz → 0.34.6__tar.gz
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.
- {polyxml-0.34.5 → polyxml-0.34.6}/Cargo.lock +6 -6
- {polyxml-0.34.5 → polyxml-0.34.6}/Cargo.toml +1 -1
- {polyxml-0.34.5 → polyxml-0.34.6}/PKG-INFO +1 -1
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/rust/mod.rs +27 -4
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_rust_codegen.rs +44 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/pyproject.toml +1 -1
- {polyxml-0.34.5 → polyxml-0.34.6}/README.md +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/Cargo.toml +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/README.md +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/benches/core_benchmarks.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/benches/support/tag_dispatch_fixtures.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/benches/tag_dispatch.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/cpp/mod.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/csharp/mod.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/go/mod.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/java/codec.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/java/mod.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/java/models.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/mod.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/python/aot.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/python/mod.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/codegen/typescript/mod.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/converters.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/error.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/integer.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/ir/chunker.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/ir/mod.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/ir/particle.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/ir/tarjan.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/json.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/lib.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/parser.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/schema.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/schema_parser/mod.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/schema_parser/upa.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/serializer.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/transcoder.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/src/value.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/fixtures/lexical_union.xsd +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/fixtures/mixed_content.xsd +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/fixtures/ts_mixed_content_inheritance.xsd +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_adversarial_identifiers.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_any_attribute.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_any_element.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_conformance.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_core.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_cpp_codegen.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_csharp_codegen.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_go_codegen.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_java_codegen.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_json.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_lexical_lists.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_lexical_union_codegen.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_mixed_content.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_pattern_codegen.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_python_codegen.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_qualified_attributes.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_rust_codecs.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_schema_audit.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_schema_ir.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_security.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_temporal_union.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_transcoder.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_ts_codegen.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_ubl_csharp.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_unbounded_choice.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_upa.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_value_constraints.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/tests/test_xsi_type.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/Cargo.toml +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/README.md +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/benches/aot_vs_dataclass.py +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/src/lib.rs +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_conformance.py +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_generated_models.py +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_json.py +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_mixed_content.py +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_polyxml.py +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-python/tests/test_xsi_type.py +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/python/polyxml/AGENT_GUIDE.md +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/python/polyxml/__init__.py +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/python/polyxml/compat/__init__.py +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/python/polyxml/compat/xsdata.py +0 -0
- {polyxml-0.34.5 → polyxml-0.34.6}/python/polyxml/py.typed +0 -0
|
@@ -608,7 +608,7 @@ dependencies = [
|
|
|
608
608
|
|
|
609
609
|
[[package]]
|
|
610
610
|
name = "polyxml"
|
|
611
|
-
version = "0.34.
|
|
611
|
+
version = "0.34.6"
|
|
612
612
|
dependencies = [
|
|
613
613
|
"criterion",
|
|
614
614
|
"heck",
|
|
@@ -629,14 +629,14 @@ dependencies = [
|
|
|
629
629
|
|
|
630
630
|
[[package]]
|
|
631
631
|
name = "polyxml-c"
|
|
632
|
-
version = "0.34.
|
|
632
|
+
version = "0.34.6"
|
|
633
633
|
dependencies = [
|
|
634
634
|
"polyxml",
|
|
635
635
|
]
|
|
636
636
|
|
|
637
637
|
[[package]]
|
|
638
638
|
name = "polyxml-cli"
|
|
639
|
-
version = "0.34.
|
|
639
|
+
version = "0.34.6"
|
|
640
640
|
dependencies = [
|
|
641
641
|
"clap",
|
|
642
642
|
"glob",
|
|
@@ -650,7 +650,7 @@ dependencies = [
|
|
|
650
650
|
|
|
651
651
|
[[package]]
|
|
652
652
|
name = "polyxml-js"
|
|
653
|
-
version = "0.34.
|
|
653
|
+
version = "0.34.6"
|
|
654
654
|
dependencies = [
|
|
655
655
|
"napi",
|
|
656
656
|
"napi-build",
|
|
@@ -660,7 +660,7 @@ dependencies = [
|
|
|
660
660
|
|
|
661
661
|
[[package]]
|
|
662
662
|
name = "polyxml-python"
|
|
663
|
-
version = "0.34.
|
|
663
|
+
version = "0.34.6"
|
|
664
664
|
dependencies = [
|
|
665
665
|
"lexical-core",
|
|
666
666
|
"polyxml",
|
|
@@ -670,7 +670,7 @@ dependencies = [
|
|
|
670
670
|
|
|
671
671
|
[[package]]
|
|
672
672
|
name = "polyxml-wasm"
|
|
673
|
-
version = "0.34.
|
|
673
|
+
version = "0.34.6"
|
|
674
674
|
dependencies = [
|
|
675
675
|
"polyxml",
|
|
676
676
|
"quick-xml",
|
|
@@ -928,9 +928,31 @@ impl RustCodegen {
|
|
|
928
928
|
let _ = writeln!(out, "{} {{", struct_decl);
|
|
929
929
|
|
|
930
930
|
let mut seen_fields = HashSet::new();
|
|
931
|
-
|
|
931
|
+
let mut seen_json_names = HashSet::new();
|
|
932
|
+
let fields = flatten_fields(s, ir);
|
|
933
|
+
let wire_names: HashSet<_> = fields.iter().map(|field| field.xml_name.as_str()).collect();
|
|
934
|
+
for field in fields {
|
|
932
935
|
let rust_name = self.unique_rust_field_name(&field.name, &mut seen_fields);
|
|
933
|
-
|
|
936
|
+
let mut json_name = field.xml_name.clone();
|
|
937
|
+
if !seen_json_names.insert(json_name.clone()) {
|
|
938
|
+
let base = rust_name.strip_prefix("r#").unwrap_or(&rust_name);
|
|
939
|
+
json_name = base.to_string();
|
|
940
|
+
let mut suffix = 2;
|
|
941
|
+
while wire_names.contains(json_name.as_str())
|
|
942
|
+
|| !seen_json_names.insert(json_name.clone())
|
|
943
|
+
{
|
|
944
|
+
json_name = format!("{base}_{suffix}");
|
|
945
|
+
suffix += 1;
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
self.emit_struct_field(
|
|
949
|
+
out,
|
|
950
|
+
field,
|
|
951
|
+
&rust_name,
|
|
952
|
+
&json_name,
|
|
953
|
+
types_with_lifetime,
|
|
954
|
+
has_boxed,
|
|
955
|
+
);
|
|
934
956
|
}
|
|
935
957
|
|
|
936
958
|
out.push_str("}\n");
|
|
@@ -960,6 +982,7 @@ impl RustCodegen {
|
|
|
960
982
|
out: &mut String,
|
|
961
983
|
field: &FieldDef,
|
|
962
984
|
rust_name: &str,
|
|
985
|
+
json_name: &str,
|
|
963
986
|
types_with_lifetime: &HashSet<QName>,
|
|
964
987
|
has_boxed: bool,
|
|
965
988
|
) {
|
|
@@ -984,8 +1007,8 @@ impl RustCodegen {
|
|
|
984
1007
|
// Serde attribute
|
|
985
1008
|
if self.options.derive_serde {
|
|
986
1009
|
let mut serde_parts = Vec::new();
|
|
987
|
-
if
|
|
988
|
-
serde_parts.push(format!("rename = \"{}\"",
|
|
1010
|
+
if json_name != rust_name.strip_prefix("r#").unwrap_or(rust_name) {
|
|
1011
|
+
serde_parts.push(format!("rename = \"{}\"", json_name));
|
|
989
1012
|
}
|
|
990
1013
|
if is_optional {
|
|
991
1014
|
serde_parts.push("default".to_string());
|
|
@@ -1461,3 +1461,47 @@ fn empty_modules_compile_without_unused_reexports() {
|
|
|
1461
1461
|
);
|
|
1462
1462
|
}
|
|
1463
1463
|
}
|
|
1464
|
+
|
|
1465
|
+
#[test]
|
|
1466
|
+
fn duplicate_wire_names_keep_distinct_json_values() {
|
|
1467
|
+
let schema = r#"<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:complexType name="Payload"><xs:sequence><xs:any namespace="urn:first" minOccurs="0" maxOccurs="unbounded"/><xs:any namespace="urn:second" minOccurs="0" maxOccurs="unbounded"/><xs:element name="any_2" type="xs:string" minOccurs="0"/></xs:sequence></xs:complexType></xs:schema>"#;
|
|
1468
|
+
let ir = XsdParser::new().parse_str(schema).unwrap();
|
|
1469
|
+
let core = std::path::Path::new(env!("CARGO_MANIFEST_DIR"));
|
|
1470
|
+
for zero_copy in [true, false] {
|
|
1471
|
+
let dir = tempfile::tempdir().unwrap();
|
|
1472
|
+
std::fs::create_dir(dir.path().join("src")).unwrap();
|
|
1473
|
+
std::fs::write(
|
|
1474
|
+
dir.path().join("src/models.rs"),
|
|
1475
|
+
RustCodegen::new(RustOptions {
|
|
1476
|
+
zero_copy,
|
|
1477
|
+
emit_codecs: false,
|
|
1478
|
+
..Default::default()
|
|
1479
|
+
})
|
|
1480
|
+
.generate_module(&ir),
|
|
1481
|
+
)
|
|
1482
|
+
.unwrap();
|
|
1483
|
+
std::fs::write(dir.path().join("Cargo.toml"),format!("[package]\nname=\"duplicate-json-test\"\nversion=\"0.0.0\"\nedition=\"2021\"\n[dependencies]\npolyxml={{path={core:?}}}\nserde={{version=\"1\",features=[\"derive\"]}}\nserde_json=\"1\"\n")).unwrap();
|
|
1484
|
+
std::fs::write(dir.path().join("src/main.rs"),r#"mod models;use models::*;
|
|
1485
|
+
fn main(){
|
|
1486
|
+
let mut value=Payload::default();value.any.push("first".into());value.any_2.push("second".into());value.any_2_2=Some("named".into());
|
|
1487
|
+
let json=serde_json::to_string(&value).unwrap();let parsed:Payload=serde_json::from_str(&json).unwrap();
|
|
1488
|
+
assert_eq!(parsed,value);let object:serde_json::Value=serde_json::from_str(&json).unwrap();assert_eq!(object.as_object().unwrap().len(),3);
|
|
1489
|
+
}
|
|
1490
|
+
"#).unwrap();
|
|
1491
|
+
let output = std::process::Command::new("cargo")
|
|
1492
|
+
.args(["run", "--quiet", "--offline"])
|
|
1493
|
+
.env("RUSTFLAGS", "-D unreachable-patterns")
|
|
1494
|
+
.env(
|
|
1495
|
+
"CARGO_TARGET_DIR",
|
|
1496
|
+
core.join("../../target/binary-lexical-tests"),
|
|
1497
|
+
)
|
|
1498
|
+
.current_dir(dir.path())
|
|
1499
|
+
.output()
|
|
1500
|
+
.unwrap();
|
|
1501
|
+
assert!(
|
|
1502
|
+
output.status.success(),
|
|
1503
|
+
"borrowed={zero_copy}: {}",
|
|
1504
|
+
String::from_utf8_lossy(&output.stderr)
|
|
1505
|
+
);
|
|
1506
|
+
}
|
|
1507
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{polyxml-0.34.5 → polyxml-0.34.6}/crates/polyxml-core/benches/support/tag_dispatch_fixtures.rs
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|