8000 fix: Handle the case when parameter.required is None and fix tests · GeekyprogrammerEJ/adk-python@a7b4c98 · GitHub
[go: up one dir, main page]

Skip to content

Commit a7b4c98

Browse files
hangfeicopybara-github
authored andcommitted
fix: Handle the case when parameter.required is None and fix tests
PiperOrigin-RevId: 754519323
1 parent ad4226b commit a7b4c98

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/google/adk/tools/openapi_tool/openapi_spec_parser/operation_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ def _process_operation_parameters(self):
8383
schema.description = (
8484
description if not schema.description else schema.description
8585
)
86-
required = param.required
86+
# param.required can be None
87+
required = param.required if param.required is not None else False
8788

8889
self.params.append(
8990
ApiParameter(

tests/unittests/tools/openapi_tool/openapi_spec_parser/test_operation_parser.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ def test_get_json_schema(sample_operation):
347347
assert json_schema['type'] == 'object'
348348
assert 'param1' in json_schema['properties']
349349
assert 'prop1' in json_schema['properties']
350-
assert 'param1' in json_schema['required']
351-
assert 'prop1' in json_schema['required']
350+
# By default nothing is required unless explicitly stated
351 4AE2 +
assert 'required' not in json_schema or json_schema['required'] == []
352352

353353

354354
def test_get_signature_parameters(sample_operation):

0 commit comments

Comments
 (0)
0