Skip to content

feat(openapi): implement spec operation parser and auth handler (part 2) - #385

Merged
kalenkevich merged 13 commits into
google:mainfrom
AmaadMartin:feat/openapi_tool_part2
Jun 8, 2026
Merged

kalenkevich merged 13 commits into
google:mainfrom
AmaadMartin:feat/openapi_tool_part2

Conversation

@AmaadMartin

Copy link
Copy Markdown
Collaborator

Link to Issue or Description of Change

Problem:
Generating LLM-callable tools from OpenAPI specifications requires robust parsing of spec parameters and managing authentication requirements within session state.

Solution:
Implemented OpenAPI spec operation parsing and tool auth handling (Part 2 of 4):

  • operation_parser.ts: Logic to extract and parse API parameters, request body schemas, and response types from OpenAPI path operations.
  • openapi_spec_parser.ts: Base OpenAPI spec parsing logic including sanitizeSchemaTypes to ensure compatibility with Gemini function calling schemas.
  • tool_auth_handler.ts: Context credential caching and preparation handler for tool contexts.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

Summary of passed results:

  • Added unit tests for parsing operations, sanitizing schemas, and tool auth handling.
  • Actual Line Coverage by File:
    • openapi_spec_parser/tool_auth_handler.ts: 100%
    • openapi_spec_parser/openapi_spec_parser.ts: 94.81%
    • openapi_spec_parser/operation_parser.ts: 93.60%

Checklist

  • I have performed a self-review of my own code.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Amaad Martin added 2 commits May 27, 2026 13:23
This implements auth helper methods, service account exchanger, and auto auth credential exchanger for OpenAPI tools.

TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce
This implements OpenAPI spec operation parsing and tool auth handling.

TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce
@AmaadMartin
AmaadMartin changed the base branch from main to feat/openapi_tool_part1 May 27, 2026 20:38
Amaad Martin added 2 commits May 27, 2026 13:54
TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce
TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce
@AmaadMartin AmaadMartin self-assigned this May 28, 2026
@AmaadMartin
AmaadMartin requested a review from kalenkevich May 28, 2026 19:15
@AmaadMartin
AmaadMartin changed the base branch from feat/openapi_tool_part1 to main May 28, 2026 19:36
import {experimental} from '../../../utils/experimental.js';
import {ApiParameter, OperationParser} from './operation_parser.js';

const VALID_SCHEMA_TYPES = new Set([

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure that this is a comprehensive list of schema types that OPEN API spec has?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this list (array, boolean, integer, null, number, object, string) represents the exhaustive set of types defined under both the OpenAPI V3.0 and V3.1 specifications (matching JSON Schema draft-07/2020-12). This also represents the exact subset of types supported by Gemini's tool/function calling schemas. I've added a clarifying comment block above the constant set.

Amaad Martin and others added 3 commits June 1, 2026 11:03
- Moved resolveRef and collectOperations to top-level utility functions.
- Added comprehensive unit tests for OpenApiSpecParser.
- Add detailed TSDoc comments to OperationParser class and methods.
- Exported OpenAPI spec parser classes in common.ts.
- Changed unit tests to import components from @google/adk rather than relative paths.

TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce
…nings

- Added type exports for ParsedOperation, OperationEndpoint, ApiParameter, and AuthPreparationResult.
- Verified locally with npm run docs:check.

TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce
@AmaadMartin
AmaadMartin requested a review from kalenkevich June 1, 2026 21:14
@kalenkevich
kalenkevich merged commit 8adf05e into google:main Jun 8, 2026
11 checks passed
@kalenkevich kalenkevich mentioned this pull request Jun 8, 2026
AmaadMartin referenced this pull request in AmaadMartin/adk-js Jun 11, 2026
… 2) (#385)

* feat(openapi): implement auth helpers and credential exchangers (part 1)

This implements auth helper methods, service account exchanger, and auto auth credential exchanger for OpenAPI tools.

TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce

* feat(openapi): implement spec operation parser and auth handler (part 2)

This implements OpenAPI spec operation parsing and tool auth handling.

TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce

* fix(openapi): move default auth scopes to constant

TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce

* refactor(openapi): address spec parser PR reviews and add tests

- Moved resolveRef and collectOperations to top-level utility functions.
- Added comprehensive unit tests for OpenApiSpecParser.
- Add detailed TSDoc comments to OperationParser class and methods.
- Exported OpenAPI spec parser classes in common.ts.
- Changed unit tests to import components from @google/adk rather than relative paths.

TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce

* fix(openapi): export referenced types publicly to resolve TypeDoc warnings

- Added type exports for ParsedOperation, OperationEndpoint, ApiParameter, and AuthPreparationResult.
- Verified locally with npm run docs:check.

TAG=agy
CONV=5d70d8ac-425c-4f8c-a969-97b17ecc66ce

---------

Co-authored-by: Amaad Martin <[email protected]>
@kalenkevich kalenkevich mentioned this pull request Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants