Skip to content

Commit 5846b24

Browse files
seanzhougooglecopybara-github
authored andcommitted
set param required tag to False by default
PiperOrigin-RevId: 754382785
1 parent 24024f7 commit 5846b24

5 files changed

Lines changed: 57 additions & 57 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
### ⚠ BREAKING CHANGES
2828

2929
* Auth: expose `access_token` and `refresh_token` at top level of auth
30-
credentials, instead of a `dict`
30+
credentails, instead of a `dict`
3131
([commit](https://github.com/google/adk-python/commit/956fb912e8851b139668b1ccb8db10fd252a6990)).
3232

3333
### Features
@@ -50,7 +50,7 @@
5050

5151
### Miscellaneous Chores
5252

53-
* README.md improvements.
53+
* README.md impprovements.
5454
* Various code improvements.
5555
* Various typo fixes.
5656
* Bump min version of google-genai to 1.11.0.
@@ -108,4 +108,4 @@
108108
* Built-in evaluation support
109109
* Development UI that makes local development easy
110110
* Deploy to Google Cloud Run, Agent Engine
111-
* (Experimental) Live(Bidi) audio/video agent support and Compositional Function Calling(CFC) support
111+
* (Experimental) Live(Bidi) auido/video agent support and Compositional Function Calling(CFC) support

src/google/adk/sessions/database_session_service.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,9 @@ def append_event(self, session: Session, event: Event) -> Event:
484484

485485
if storage_session.update_time.timestamp() > session.last_update_time:
486486
raise ValueError(
487-
f"Session last_update_time "
488-
f"{datetime.fromtimestamp(session.last_update_time):%Y-%m-%d %H:%M:%S} "
489-
f"is later than the update_time in storage "
490-
f"{storage_session.update_time:%Y-%m-%d %H:%M:%S}"
491-
)
487+
f"Session last_update_time {session.last_update_time} is later than"
488+
f" the upate_time in storage {storage_session.update_time}"
489+
)
492490

493491
# Fetch states from storage
494492
storage_app_state = sessionFactory.get(

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,7 @@
1414

1515
import keyword
1616
import re
17-
from typing import Any
18-
from typing import Dict
19-
from typing import List
20-
from typing import Optional
21-
from typing import Union
17+
from typing import Any, Dict, List, Optional, Union
2218

2319
from fastapi.openapi.models import Response
2420
from fastapi.openapi.models import Schema
@@ -100,7 +96,7 @@ class ApiParameter(BaseModel):
10096
py_name: Optional[str] = ''
10197
type_value: type[Any] = Field(default=None, init_var=False)
10298
type_hint: str = Field(default=None, init_var=False)
103-
required: Optional[bool] = None
99+
required: bool = False
104100

105101
def model_post_init(self, _: Any):
106102
self.py_name = (

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

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@
1717
from typing import Any, Dict, List, Optional, Union
1818

1919
from fastapi.encoders import jsonable_encoder
20-
from fastapi.openapi.models import Operation, Parameter, Schema
20+
from fastapi.openapi.models import Operation
21+
from fastapi.openapi.models import Parameter
22+
from fastapi.openapi.models import Schema
2123

22-
from ..common.common import ApiParameter, PydocHelper, to_snake_case
24+
from ..common.common import ApiParameter
25+
from ..common.common import PydocHelper
26+
from ..common.common import to_snake_case
2327

2428

2529
class OperationParser:
@@ -76,7 +80,9 @@ def _process_operation_parameters(self):
7680
description = param.description or ''
7781
location = param.in_ or ''
7882
schema = param.schema_ or {} # Use schema_ instead of .schema
79-
schema.description = description if schema.description is None and description != '' else schema.description
83+
schema.description = (
84+
description if not schema.description else schema.description
85+
)
8086
required = param.required
8187

8288
self.params.append(
@@ -85,7 +91,7 @@ def _process_operation_parameters(self):
8591
param_location=location,
8692
param_schema=schema,
8793
description=description,
88-
required=required
94+
required=required,
8995
)
9096
)
9197

@@ -233,7 +239,7 @@ def get_json_schema(self) -> Dict[str, Any]:
233239
}
234240
return {
235241
'properties': properties,
236-
'required': [p.py_name for p in self.params if p.required is not False],
242+
'required': [p.py_name for p in self.params if p.required],
237243
'title': f"{self.operation.operationId or 'unnamed'}_Arguments",
238244
'type': 'object',
239245
}

0 commit comments

Comments
 (0)