Skip to content

Commit e3a2f2e

Browse files
authored
Add UnwrapXmlOutput Customization for GetBucketLocation (#3907)
1 parent 70ef4e1 commit e3a2f2e

File tree

4 files changed

+72
-45
lines changed

4 files changed

+72
-45
lines changed

generator/ServiceClientGeneratorLib/Customizations.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ public class CustomizationsModel
426426
public const string OriginalMemberKey = "originalMember";
427427
public const string OverrideTreatEnumsAsStringKey = "overrideTreatEnumsAsString";
428428
public const string ExcludeMembersKey = "excludeMembers";
429+
public const string UnwrapXmlOutputKey = "unwrapXmlOutput";
429430

430431
JsonData _documentRoot;
431432

@@ -596,6 +597,29 @@ public List<string> ExcludeMembers(string shapeName)
596597

597598
}
598599

600+
/// <summary>
601+
/// This customization is used to unwrap the response, and is only used for Xml services.
602+
/// This is currently only used for GetBucketLocation
603+
/// where the output is not wrapped in a top-level output xml tag and only includes the member at the root level
604+
/// example usage:
605+
/// "unwrapOutput:{
606+
/// "GetBucketLocationOutput": true
607+
/// }
608+
/// </summary>
609+
/// <param name="shapeName">The shape to unwrap</param>
610+
/// <returns></returns>
611+
/// <exception cref="InvalidCastException"></exception>
612+
public bool UnwrapXmlOutput(string shapeName)
613+
{
614+
var data = _documentRoot[UnwrapXmlOutputKey];
615+
// if the customization doesn't exist, the default is false
616+
if (data == null || data[shapeName] == null) return false;
617+
if (!data[shapeName].IsBoolean)
618+
throw new InvalidCastException("The value for the UnwrapOutput customization must be a boolean");
619+
620+
return (bool)data[shapeName];
621+
}
622+
599623
/// <summary>
600624
/// A list of uri properties for the service where we should not do validation for presence.
601625
/// </summary>

0 commit comments

Comments
 (0)