Skip to content

[VSCode] Add right-click context menu to load OpenAPI descriptions from YAML files #6676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 17, 2025

This PR implements the ability to load OpenAPI descriptions directly from the VS Code file explorer by right-clicking on YAML files, as requested in the original issue.

Changes Made

New Command Implementation

  • Added LoadOpenApiDescriptionFromFileCommand that handles loading OpenAPI descriptions from file URIs
  • Includes intelligent OpenAPI detection by checking for openapi: or swagger: keywords in YAML content
  • Validates files using the existing getKiotaTree function to ensure they are valid OpenAPI specifications
  • Provides user-friendly error messages and confirmation dialogs for edge cases

VS Code Integration

  • Added context menu entry for .yaml and .yml files in the file explorer
  • Command appears as "Load in Kiota API Explorer" when right-clicking on YAML files
  • Integrates seamlessly with the existing OpenApiTreeProvider and follows established patterns

User Experience Improvements

  • Detects non-OpenAPI YAML files and offers the option to load them anyway
  • Warns users about losing current changes before loading a new description
  • Shows success messages and offers to generate client code after loading
  • Respects existing user preferences (e.g., "show generate message" setting)

Technical Details

  • Command ID: kiota.openApiExplorer.loadOpenApiDescriptionFromFile
  • Menu condition: resourceExtname =~ /\.(yaml|yml)$/ (matches both .yaml and .yml files)
  • Includes comprehensive error handling and telemetry tracking
  • Added unit tests to verify command functionality and OpenAPI detection logic

Example Usage

  1. Open VS Code with a workspace containing OpenAPI YAML files
  2. Right-click on any .yaml or .yml file in the file explorer
  3. Select "Load in Kiota API Explorer" from the context menu
  4. The OpenAPI description loads automatically into the API Explorer view
  5. User can then select endpoints and generate client code as usual

This enhancement eliminates the need to manually browse for files through the existing search dialog when working with local OpenAPI specifications.

Fixes #4733.

Warning

Firewall rules blocked me from connecting to one or more addresses

I tried to connect to the following addresses, but was blocked by firewall rules:

  • update.code.visualstudio.com
    • Triggering command: node /home/REDACTED/work/kiota/kiota/vscode/node_modules/.bin/vscode-test (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits June 17, 2025 14:28
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
Co-authored-by: baywet <7905502+baywet@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] [VSCode] It should be possible to load an OpenAPI description from the right-click [VSCode] Add right-click context menu to load OpenAPI descriptions from YAML files Jun 17, 2025
@Copilot Copilot AI requested a review from baywet June 17, 2025 14:40
Copilot finished work on behalf of baywet June 17, 2025 14:40
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.

[VSCode] It should be possible to load an OpenAPI description from the right-click
2 participants