From 94ed111df706497a11ff52a1ff0246c1248c0d74 Mon Sep 17 00:00:00 2001 From: aemous Date: Fri, 23 Jan 2026 12:18:22 -0500 Subject: [PATCH] Update ParamShorthand DocGen to fix the case of a structure within a map. --- .../bugfix-documentation-51673.json | 5 +++++ awscli/argprocess.py | 6 +++++- tests/unit/test_argprocess.py | 18 ++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 .changes/next-release/bugfix-documentation-51673.json diff --git a/.changes/next-release/bugfix-documentation-51673.json b/.changes/next-release/bugfix-documentation-51673.json new file mode 100644 index 000000000000..a90b5418c224 --- /dev/null +++ b/.changes/next-release/bugfix-documentation-51673.json @@ -0,0 +1,5 @@ +{ + "type": "bugfix", + "category": "documentation", + "description": "Fixed shorthand example generation in documentation." +} diff --git a/awscli/argprocess.py b/awscli/argprocess.py index af59b08adb37..445fc652ee17 100644 --- a/awscli/argprocess.py +++ b/awscli/argprocess.py @@ -536,7 +536,11 @@ def _list_docs(self, argument_model, stack): def _map_docs(self, argument_model, stack): k = argument_model.key - value_docs = self._shorthand_docs(argument_model.value, stack) + stack.append(argument_model.value.name) + try: + value_docs = self._shorthand_docs(argument_model.value, stack) + finally: + stack.pop() start = 'KeyName1=%s,KeyName2=%s' % (value_docs, value_docs) if k.enum and not stack: start += '\n\nWhere valid key names are:\n' diff --git a/tests/unit/test_argprocess.py b/tests/unit/test_argprocess.py index e37398d82145..fd9e6e063908 100644 --- a/tests/unit/test_argprocess.py +++ b/tests/unit/test_argprocess.py @@ -803,6 +803,24 @@ def test_skip_deeply_nested_shorthand(self): generated_example = self.get_generated_example_for(argument) self.assertEqual(generated_example, '') + def test_structure_within_map(self): + argument = self.create_argument( + { + 'A': { + 'type': 'map', + 'key': {'type': 'string'}, + 'value': { + 'type': 'structure', + 'members': { + 'B': {'type': 'string'}, + }, + }, + }, + } + ) + generated_example = self.get_generated_example_for(argument) + self.assertEqual('A={KeyName1={B=string},KeyName2={B=string}}', generated_example) + class TestUnpackJSONParams(BaseArgProcessTest): def setUp(self):