OpenAPI Go Definitions
A VS Code extension that enables jump-to-definition from OpenAPI operationId fields to their corresponding Go function implementations.
Features
- Jump to Definition: Ctrl/Cmd+Click on an
operationId value in OpenAPI YAML or JSON files to navigate directly to the Go function definition
- Workspace-wide Search: Automatically searches all Go files in your workspace
- Configurable: Customize which Go files are searched using glob patterns
Usage
- Open an OpenAPI specification file (YAML or JSON)
- Find an
operationId field, for example:
paths:
/workflow:
post:
operationId: invokeWorkflow
- Hold Ctrl (Windows/Linux) or Cmd (Mac) and click on
invokeWorkflow
- The extension will jump to the Go function definition
Configuration
Configure the extension through VS Code settings:
openapi-go-definitions.goSourcePaths: Array of glob patterns for Go source files to search (default: ["**/*.go"])
Example settings.json:
{
"openapi-go-definitions.goSourcePaths": [
"internal/**/*.go",
"pkg/**/*.go",
"cmd/**/*.go"
]
}
Installation
From Source
- Clone this repository
- Run
npm install
- Run
npm run compile
- Press F5 to open a new VS Code window with the extension loaded
Package and Install
- Install vsce:
npm install -g @vscode/vsce
- Package the extension:
vsce package
- Install the .vsix file:
code --install-extension openapi-go-definitions-0.0.1.vsix
Requirements
- VS Code 1.80.0 or higher
- Go source files in your workspace
How It Works
The extension:
- Detects when you click on an
operationId value in YAML or JSON files
- Extracts the operation ID name
- Searches configured Go files for function definitions matching that name
- Provides the location for VS Code's "Go to Definition" feature
YAML
operationId: functionName
JSON
"operationId": "functionName"
Limitations
- Only searches for function definitions at the top level (not nested functions)
- Requires exact name matching between operationId and Go function name
- Does not support type aliases or indirect function references
License
MIT
| |