-
Notifications
You must be signed in to change notification settings - Fork 350
[Bug]: http-client-java, difference on serialization of XML with namespace #10208
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingemitter:client:javaIssue for the Java client emitter: @typespec/http-client-javaIssue for the Java client emitter: @typespec/http-client-java
Description
Describe the bug
test scenario https://github.com/microsoft/typespec/blob/main/packages/http-specs/specs/payload/xml/main.tsp#L461-L504
Java SDK serialize XML as e.g.
<ModelWithNamespaceOnProperties xmlns="http://example.com/schema" xmlns:smp="http://example.com/schema" xmlns:ns2="http://example.com/ns2">
<id>123</id>
<title>The Great Gatsby</title>
<ns2:author>F. Scott Fitzgerald</ns2:author>
</ModelWithNamespaceOnProperties>Validation is
<smp:ModelWithNamespaceOnProperties xmlns:smp="http://example.com/schema" xmlns:ns2="http://example.com/ns2">
<id>123</id>
<smp:title>The Great Gatsby</smp:title>
<ns2:author>F. Scott Fitzgerald</ns2:author>
</smp:ModelWithNamespaceOnProperties>The most disagreement is on the id property.
In Java serialization, id is in "http://example.com/schema" namespace.
While in test scenario, id is in null namespace.
code-model.yaml contains the info
- &ref_86
language:
default:
name: ModelWithNamespaceOnProperties
description: >-
§6.2, §7.2 — Contains fields with different XML namespaces on
individual properties.
namespace: Payload.Xml
crossLanguageDefinitionId: Payload.Xml.ModelWithNamespaceOnProperties
java:
namespace: payload.xml
protocol: {}
type: object
properties:
- language:
default:
name: id
description: ''
protocol: {}
schema: *ref_3
serializedName: id
required: true
nullable: false
readOnly: false
serialization:
xml:
name: id
attribute: false
wrapped: false
text: false
- language:
default:
name: title
description: ''
protocol: {}
schema: *ref_0
serializedName: title
required: true
nullable: false
readOnly: false
serialization:
xml:
name: title
namespace: http://example.com/schema
prefix: smp
attribute: false
wrapped: false
text: false
- language:
default:
name: author
description: ''
protocol: {}
schema: *ref_0
serializedName: author
required: true
nullable: false
readOnly: false
serialization:
xml:
name: author
namespace: http://example.com/ns2
prefix: ns2
attribute: false
wrapped: false
text: false
serialization:
xml:
name: ModelWithNamespaceOnProperties
namespace: http://example.com/schema
prefix: smp
attribute: false
wrapped: false
text: false
usage:
- output
- public
- inputReproduction
Start the spector in "/packages/http-client-java/generator/http-client-generator-clientcore-test"
- Setup.ps1
- npm run spector-serve
Run the test
Checklist
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingemitter:client:javaIssue for the Java client emitter: @typespec/http-client-javaIssue for the Java client emitter: @typespec/http-client-java