Skip to content

OpenAPI Tool samples and tests#48315

Merged
jpalvarezl merged 4 commits intomainfrom
jpalvarezl/fix/sample_work
Mar 7, 2026
Merged

OpenAPI Tool samples and tests#48315
jpalvarezl merged 4 commits intomainfrom
jpalvarezl/fix/sample_work

Conversation

@jpalvarezl
Copy link
Member

This pull request introduces a new sample demonstrating how to integrate an OpenAPI tool with the Azure AI Agents SDK, allowing agents to call external APIs defined by OpenAPI specification files. The main changes include adding a sample Java file, providing a sample OpenAPI spec, and implementing a utility method for reading OpenAPI specs from JSON files.

OpenAPI Tool Integration Sample:

  • Added OpenApiSample.java demonstrating how to create an agent with an OpenAPI tool, load an OpenAPI spec from a file, and interact with the agent via conversation and response APIs.
  • Provided a sample OpenAPI specification file for the httpbin service at src/samples/resources/assets/httpbin_openapi.json.

Utility Improvements:

  • Added readSpecFromFile(Path path) static method to OpenApiFunctionDefinition, enabling easy loading of OpenAPI specs from JSON files for use in agent tool definitions.
  • Updated imports in OpenApiFunctionDefinition.java to support file reading and JSON parsing required by the new utility method.

Copilot AI review requested due to automatic review settings March 6, 2026 09:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds an OpenAPI-tool integration sample for Azure AI Agents and a helper for loading OpenAPI JSON specs from disk.

Changes:

  • Added a sample OpenAPI spec (httpbin) under sample resources.
  • Added OpenApiSample.java demonstrating creating an agent with an OpenAPI tool and invoking it via conversation/response APIs.
  • Added OpenApiFunctionDefinition.readSpecFromFile(Path) to load spec JSON into the Map<String, BinaryData> shape expected by the tool definition.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
sdk/ai/azure-ai-agents/src/samples/resources/assets/httpbin_openapi.json Adds a minimal httpbin OpenAPI spec used by the sample.
sdk/ai/azure-ai-agents/src/samples/java/com/azure/ai/agents/tools/OpenApiSample.java New runnable sample demonstrating OpenAPI tool integration end-to-end.
sdk/ai/azure-ai-agents/src/main/java/com/azure/ai/agents/models/OpenApiFunctionDefinition.java Adds a convenience method to load OpenAPI specs from JSON files.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 6, 2026

API Change Check

APIView identified API level changes in this PR and created the following API reviews

com.azure:azure-ai-agents

@jpalvarezl jpalvarezl enabled auto-merge (squash) March 6, 2026 10:50
@jpalvarezl jpalvarezl force-pushed the jpalvarezl/fix/sample_work branch from e7567cf to b8fb5b5 Compare March 6, 2026 12:37
@jpalvarezl jpalvarezl changed the title Updating samples and tests OpenAPI Tool samples and tests Mar 6, 2026
@jpalvarezl jpalvarezl merged commit 4c59db7 into main Mar 7, 2026
20 checks passed
@jpalvarezl jpalvarezl deleted the jpalvarezl/fix/sample_work branch March 7, 2026 00:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants