diff --git a/src/google/adk/tools/openapi_tool/common/common.py b/src/google/adk/tools/openapi_tool/common/common.py index cc3bca7..ffd7877 100644 --- a/src/google/adk/tools/openapi_tool/common/common.py +++ b/src/google/adk/tools/openapi_tool/common/common.py @@ -100,6 +100,7 @@ class ApiParameter(BaseModel): py_name: Optional[str] = '' type_value: type[Any] = Field(default=None, init_var=False) type_hint: str = Field(default=None, init_var=False) + required: Optional[bool] = None def model_post_init(self, _: Any): self.py_name = ( diff --git a/src/google/adk/tools/openapi_tool/openapi_spec_parser/operation_parser.py b/src/google/adk/tools/openapi_tool/openapi_spec_parser/operation_parser.py index 4d9fa6a..7c78eee 100644 --- a/src/google/adk/tools/openapi_tool/openapi_spec_parser/operation_parser.py +++ b/src/google/adk/tools/openapi_tool/openapi_spec_parser/operation_parser.py @@ -76,6 +76,8 @@ class OperationParser: description = param.description or '' location = param.in_ or '' schema = param.schema_ or {} # Use schema_ instead of .schema + schema.description = description if schema.description is None and description != '' else schema.description + required = param.required self.params.append( ApiParameter( @@ -83,6 +85,7 @@ class OperationParser: param_location=location, param_schema=schema, description=description, + required=required ) ) @@ -230,7 +233,7 @@ class OperationParser: } return { 'properties': properties, - 'required': [p.py_name for p in self.params], + 'required': [p.py_name for p in self.params if p.required is not False], 'title': f"{self.operation.operationId or 'unnamed'}_Arguments", 'type': 'object', }