Skip to content

Commit e8fb4ed

Browse files
sumant-pangotracopybara-github
authored andcommitted
Copybara import of the project:
-- 27b214d by Sumant Pangotra <sumantpangotra@gmail.com>: Fixed Parameter required field and description COPYBARA_INTEGRATE_REVIEW=#256 from sumant-pangotra:#247-OpenAPIToolSet-Considering-Required-parameters 42f87a9 PiperOrigin-RevId: 754050217
1 parent d387ab0 commit e8fb4ed

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/google/adk/tools/openapi_tool/common/common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class ApiParameter(BaseModel):
100100
py_name: Optional[str] = ''
101101
type_value: type[Any] = Field(default=None, init_var=False)
102102
type_hint: str = Field(default=None, init_var=False)
103+
required: Optional[bool] = None
103104

104105
def model_post_init(self, _: Any):
105106
self.py_name = (

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,16 @@ def _process_operation_parameters(self):
7676
description = param.description or ''
7777
location = param.in_ or ''
7878
schema = param.schema_ or {} # Use schema_ instead of .schema
79+
schema.description = description if schema.description is None and description != '' else schema.description
80+
required = param.required
7981

8082
self.params.append(
8183
ApiParameter(
8284
original_name=original_name,
8385
param_location=location,
8486
param_schema=schema,
8587
description=description,
88+
required=required
8689
)
8790
)
8891

@@ -230,7 +233,7 @@ def get_json_schema(self) -> Dict[str, Any]:
230233
}
231234
return {
232235
'properties': properties,
233-
'required': [p.py_name for p in self.params],
236+
'required': [p.py_name for p in self.params if p.required is not False],
234237
'title': f"{self.operation.operationId or 'unnamed'}_Arguments",
235238
'type': 'object',
236239
}

0 commit comments

Comments
 (0)