Skip to content

RestApiTool.from_parsed_operation_str drops required flags on parameters #8065

Closed

Description

@sumedh-aerram

Describe the bug
A RestApiTool restored with RestApiTool.from_parsed_operation_str(...) marks every parameter as optional. ApiParameter._serialize (openapi_tool/common/common.py) builds its dict by hand and leaves out required, so after a JSON round-trip every parameter falls back to required=False. The restored function declaration then has an empty required list, and RestApiTool.call's default-filling for required parameters no longer applies.

To reproduce (offline, on main)

from google.adk.tools.openapi_tool.openapi_spec_parser.openapi_spec_parser import OpenApiSpecParser
from google.adk.tools.openapi_tool.openapi_spec_parser.rest_api_tool import RestApiTool

spec = {'openapi': '3.0.0', 'info': {'title': 'demo', 'version': '1'},
        'servers': [{'url': 'https://example.test'}],
        'paths': {'/items/{id}': {'get': {
            'operationId': 'getItem',
            'parameters': [
                {'name': 'id', 'in': 'path', 'required': True, 'schema': {'type': 'string'}},
                {'name': 'tenant', 'in': 'query', 'required': True, 'schema': {'type': 'string'}}],
            'responses': {'200': {'description': 'OK'}}}}}}

parsed = OpenApiSpecParser().parse(spec)[0]
before = RestApiTool.from_parsed_operation(parsed)._operation_parser.get_json_schema()
after = RestApiTool.from_parsed_operation_str(
    parsed.model_dump_json(by_alias=True))._operation_parser.get_json_schema()
print('before:', before['required'])
print('after: ', after['required'])

Expected: before: ['id', 'tenant'] and after: ['id', 'tenant'].

Actual: after: [].

Environment: ADK main (2.14.0), Python 3.11, macOS. No model involved.

I'd like to send a fix: include required in ApiParameter._serialize (still loading older JSON without it), plus a round-trip test.

Activity

  1. added a commit that references this issue on Nov 11, 2026
    e5ffe9c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions