Skip to content

Commit

Permalink
http-client-java, skip xml property of required and constant, on de-s…
Browse files Browse the repository at this point in the history
…erialization (#5369)

fix #5332

The property is required, and can have only 1 value. Therefore it is not
settable (as there is only 1 value to set), and de-serialization does
not need to set the value as well.

e2e test at Azure/autorest.java#2997
  • Loading branch information
weidongxu-microsoft authored Dec 17, 2024
1 parent 821b7f9 commit c09f252
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2312,10 +2312,20 @@ private void writeFromXmlDeserialization(JavaBlock methodBlock) {

// Loop over all properties and generate their deserialization handling.
AtomicReference<JavaIfBlock> ifBlockReference = new AtomicReference<>(ifBlock);
propertiesManager.forEachSuperXmlElement(
element -> handleXmlPropertyDeserialization(element, whileBlock, ifBlockReference, true));
propertiesManager.forEachXmlElement(
element -> handleXmlPropertyDeserialization(element, whileBlock, ifBlockReference, false));
propertiesManager.forEachSuperXmlElement(element -> {
if (element.isRequired() && element.isConstant()) {
return;
}
handleXmlPropertyDeserialization(element, whileBlock, ifBlockReference, true);
});
propertiesManager.forEachXmlElement(element -> {
if (element.isRequired() && element.isConstant()) {
// the element is element of a constant, which can only have one value
// skip de-serialize
return;
}
handleXmlPropertyDeserialization(element, whileBlock, ifBlockReference, false);
});

ifBlock = ifBlockReference.get();

Expand Down

0 comments on commit c09f252

Please sign in to comment.