Copybara import of the project:

--
27b214df3e by Sumant Pangotra <sumantpangotra@gmail.com>:

Fixed Parameter required field and description

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/256 from sumant-pangotra:#247-OpenAPIToolSet-Considering-Required-parameters 42f87a9c94
PiperOrigin-RevId: 754050217
This commit is contained in:
sumant-pangotra 2025-05-02 10:23:18 -07:00 committed by Copybara-Service
parent d387ab0c38
commit e8fb4ed3fc
2 changed files with 5 additions and 1 deletions

View File

@ -100,6 +100,7 @@ class ApiParameter(BaseModel):
py_name: Optional[str] = '' py_name: Optional[str] = ''
type_value: type[Any] = Field(default=None, init_var=False) type_value: type[Any] = Field(default=None, init_var=False)
type_hint: str = 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): def model_post_init(self, _: Any):
self.py_name = ( self.py_name = (

View File

@ -76,6 +76,8 @@ class OperationParser:
description = param.description or '' description = param.description or ''
location = param.in_ or '' location = param.in_ or ''
schema = param.schema_ or {} # Use schema_ instead of .schema 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( self.params.append(
ApiParameter( ApiParameter(
@ -83,6 +85,7 @@ class OperationParser:
param_location=location, param_location=location,
param_schema=schema, param_schema=schema,
description=description, description=description,
required=required
) )
) )
@ -230,7 +233,7 @@ class OperationParser:
} }
return { return {
'properties': properties, '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", 'title': f"{self.operation.operationId or 'unnamed'}_Arguments",
'type': 'object', 'type': 'object',
} }