kiota
kiota copied to clipboard
[VSCode] Add right-click context menu to load OpenAPI descriptions from YAML files
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
LoadOpenApiDescriptionFromFileCommandthat handles loading OpenAPI descriptions from file URIs - Includes intelligent OpenAPI detection by checking for
openapi:orswagger:keywords in YAML content - Validates files using the existing
getKiotaTreefunction 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
.yamland.ymlfiles in the file explorer - Command appears as "Load in Kiota API Explorer" when right-clicking on YAML files
- Integrates seamlessly with the existing
OpenApiTreeProviderand 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
- Open VS Code with a workspace containing OpenAPI YAML files
- Right-click on any
.yamlor.ymlfile in the file explorer - Select "Load in Kiota API Explorer" from the context menu
- The OpenAPI description loads automatically into the API Explorer view
- 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:
- Configure Actions setup steps to set up my environment, which run before the firewall is enabled
- Add the appropriate URLs or hosts to my firewall allow list
💡 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.