Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
896d989
ParserService
savannahostrowski Jan 7, 2026
25a1539
Process decorators
savannahostrowski Jan 8, 2026
e67c9ba
Extract routers
savannahostrowski Jan 8, 2026
b640dc6
Import extractor
savannahostrowski Jan 8, 2026
a1e063e
Include router extractor
savannahostrowski Jan 8, 2026
471aecc
Single file works
savannahostrowski Jan 8, 2026
7e3f0aa
Add import resolver
savannahostrowski Jan 8, 2026
1e338b4
Okay it works
savannahostrowski Jan 8, 2026
1e80fd5
Fix up UI
savannahostrowski Jan 8, 2026
e6ebbe9
Handle dynamic paths
savannahostrowski Jan 9, 2026
299f522
Add entrypoint setting and order alphabetically
savannahostrowski Jan 9, 2026
da7a596
Add tests
savannahostrowski Jan 9, 2026
78c59a2
Big refactor
savannahostrowski Jan 12, 2026
968f6ba
More cleanup
savannahostrowski Jan 12, 2026
ba8eaf4
Clean up command palette registration
savannahostrowski Jan 12, 2026
271680f
Fix packaging
savannahostrowski Jan 12, 2026
ad1ad45
Fix publisher name
savannahostrowski Jan 12, 2026
f46fe81
Clean up esbuild
savannahostrowski Jan 13, 2026
0218981
Clean up command palette
savannahostrowski Jan 13, 2026
00284a9
Add string extraction helper
savannahostrowski Jan 13, 2026
cc8f9d0
Remove router prefix menu
savannahostrowski Jan 13, 2026
298f265
Clean up esbuild
savannahostrowski Jan 14, 2026
d9685f7
Add support for namespace package
savannahostrowski Jan 14, 2026
502fa95
Clean up fixtures
savannahostrowski Jan 14, 2026
3a4bb8b
Refactor tests
savannahostrowski Jan 14, 2026
4a638d7
extension.ts cleanup
savannahostrowski Jan 14, 2026
7a233eb
Remove non-dynamic prefix stripping
savannahostrowski Jan 14, 2026
2041ca8
Add test
savannahostrowski Jan 14, 2026
d16a812
Fix test
savannahostrowski Jan 14, 2026
138190d
Clean up extractors
savannahostrowski Jan 14, 2026
082959b
Even more cleanup
savannahostrowski Jan 14, 2026
daa7acc
More TS syntactic sugar
savannahostrowski Jan 14, 2026
b048d67
Restructure test files
savannahostrowski Jan 14, 2026
b99e2be
Fix memory leak on deactivation
savannahostrowski Jan 14, 2026
ee8c75c
Add filewatching
savannahostrowski Jan 12, 2026
66f1a3c
Add code lenses in test files
savannahostrowski Jan 13, 2026
5d96fea
Clean up
savannahostrowski Jan 13, 2026
efa8909
Update to use showTestCodeLenses
savannahostrowski Jan 13, 2026
0e06f2f
Cleanup readme
savannahostrowski Jan 13, 2026
f9ba6c3
Simplify pathMatchesEndpoint
savannahostrowski Jan 13, 2026
c8c3bbc
Add tests
savannahostrowski Jan 13, 2026
0305082
Add helper
savannahostrowski Jan 13, 2026
fa4eb17
Rename files
savannahostrowski Jan 13, 2026
374f2d4
Fix registration for code lens
savannahostrowski Jan 13, 2026
f31c219
Refactor to consolidate endpoint/router/route into goToLocation
savannahostrowski Jan 13, 2026
a167b10
Use vscode.open for tree view to simplify
savannahostrowski Jan 13, 2026
c08c565
Revert and use comments
savannahostrowski Jan 13, 2026
38b03c4
Fix comments in extension.ts
savannahostrowski Jan 14, 2026
e654537
Bump version
savannahostrowski Jan 14, 2026
bad44a1
Add go to router
savannahostrowski Jan 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ src/**
**/*.ts
**/tsconfig.json
esbuild.js
node_modules/**
bun.lockb
node_modules/**
!node_modules/web-tree-sitter/**
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# FastAPI VS Code Extension

A VS Code extension for FastAPI development.
A VS Code extension for FastAPI development that discovers and displays your API endpoints in a tree view.

## Features

- Hello World command (example)
- Automatic discovery of FastAPI routes and routers
- Tree view showing all endpoints organized by router
- Click to navigate to route definitions from the endpoint explorer
- Supports `include_router` chains with prefix resolution
- CodeLens in test files to jump from test client calls to routes

## Settings

| Setting | Description | Default |
|---------|-------------|---------|
| `fastapi.entryPoint` | Path to the main FastAPI application file (e.g., `src/main.py`). If not set, the extension searches common locations: `main.py`, `app/main.py`, `api/main.py`, `src/main.py`, `backend/app/main.py`. | `""` (auto-detect) |
| `fastapi.showTestCodeLenses` | Show CodeLens links above test client calls (e.g., `client.get('/items')`) to navigate to the corresponding route definition. | `true` |

**Note:** Currently the extension discovers one FastAPI app per workspace folder. If you have multiple apps, use separate workspace folders or configure `fastapi.entryPoint` to point to your primary app.

## Development

Expand Down
18 changes: 14 additions & 4 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 30 additions & 6 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,51 @@
import { copyFileSync, globSync, mkdirSync } from "node:fs"
import path from "node:path"
import esbuild from "esbuild"

const production = process.argv.includes("--production")
const watch = process.argv.includes("--watch")

function copyWasmFiles() {
const wasmDestDir = path.join(import.meta.dirname, "dist", "wasm")
mkdirSync(wasmDestDir, { recursive: true })

const wasmFiles = [
["web-tree-sitter", "web-tree-sitter.wasm"],
["tree-sitter-python", "tree-sitter-python.wasm"],
]

for (const [pkg, file] of wasmFiles) {
const src = path.join(import.meta.dirname, "node_modules", pkg, file)
copyFileSync(src, path.join(wasmDestDir, file))
console.log(`Copied ${file} -> dist/wasm/`)
}
}

async function main() {
copyWasmFiles()

const entryPoints = ["src/extension.ts"]
if (!production) {
entryPoints.push(...globSync("src/test/**/*.test.ts"))
}

const ctx = await esbuild.context({
entryPoints: [
"src/extension.ts",
"src/test/extension.test.ts",
"src/test/EndpointTreeProvider.test.ts",
],
entryPoints,
bundle: true,
format: "cjs",
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: "node",
target: "node20",
treeShaking: true,
outdir: "dist",
outbase: "src",
external: ["vscode"],
external: ["vscode", "web-tree-sitter"],
logLevel: "info",
define: {
"process.env.NODE_ENV": production ? '"production"' : '"development"',
__DIST_ROOT__: JSON.stringify(path.join(import.meta.dirname, "dist")),
},
})

Expand Down
138 changes: 81 additions & 57 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,82 @@
{
"name": "fastapi-vscode",
"displayName": "FastAPI Extension",
"description": "VS Code extension for FastAPI development",
"version": "0.0.1",
"publisher": "FastAPI Labs",
"engines": {
"vscode": "^1.85.0"
"version": "0.0.2",
"repository": {
"type": "git",
"url": "https://github.com/fastapi/fastapi-vscode"
},
"main": "./dist/extension.js",
"devDependencies": {
"@biomejs/biome": "^2.3.11",
"@types/bun": "latest",
"@types/mocha": "^10.0.10",
"@types/vscode": "^1.85.0",
"@vscode/test-cli": "^0.0.12",
"@vscode/test-electron": "^2.5.2",
"@vscode/vsce": "^3.7.1",
"esbuild": "^0.27.2",
"husky": "^9.1.7",
"lint-staged": "^16.2.7",
"typescript": "^5.0.0"
},
"categories": [
"Other"
],
"activationEvents": [
"workspaceContains:**/*.py"
],
"main": "./dist/extension.js",
"bugs": {
"url": "https://github.com/fastapi/fastapi-vscode/issues"
},
"categories": [
"Other"
],
"contributes": {
"commands": [
{
"command": "fastapi-vscode.refreshEndpoints",
"title": "Refresh Endpoints",
"category": "FastAPI",
"icon": "$(refresh)"
},
{
"command": "fastapi-vscode.goToEndpoint",
"title": "Go to Definition"
"command": "fastapi-vscode.toggleRouters",
"title": "Toggle Expand/Collapse Routers",
"category": "FastAPI",
"icon": "$(fold)"
},
{
"command": "fastapi-vscode.copyEndpointPath",
"title": "Copy Path"
"title": "Copy Endpoint Path",
"category": "FastAPI"
},
{
"command": "fastapi-vscode.goToRouter",
"title": "Go to Router Definition"
},
{
"command": "fastapi-vscode.copyRouterPrefix",
"title": "Copy Prefix"
"title": "Go to Router Definition",
"category": "FastAPI"
}
],
"menus": {
"commandPalette": [
{
"command": "fastapi-vscode.copyEndpointPath",
"when": "false"
},
{
"command": "fastapi-vscode.goToRouter",
"when": "false"
}
],
"view/title": [
{
"command": "fastapi-vscode.refreshEndpoints",
"when": "view == endpoint-explorer",
"group": "navigation"
"group": "navigation@1"
},
{
"command": "fastapi-vscode.toggleRouters",
"when": "view == endpoint-explorer",
"group": "navigation@2"
}
],
"view/item/context": [
{
"command": "fastapi-vscode.goToEndpoint",
"when": "view == endpoint-explorer && viewItem == route",
"group": "navigation"
},
{
"command": "fastapi-vscode.copyEndpointPath",
"when": "view == endpoint-explorer && viewItem == route",
Expand All @@ -61,11 +86,6 @@
"command": "fastapi-vscode.goToRouter",
"when": "view == endpoint-explorer && viewItem == router",
"group": "navigation"
},
{
"command": "fastapi-vscode.copyRouterPrefix",
"when": "view == endpoint-explorer && viewItem == router",
"group": "navigation"
}
]
},
Expand All @@ -85,45 +105,49 @@
"name": "Endpoint Explorer"
}
]
},
"configuration": {
"title": "FastAPI",
"properties": {
"fastapi.entryPoint": {
"type": "string",
"default": "",
"description": "Path to the main FastAPI application file (e.g., 'src/main.py'). If not set, the extension will search common locations."
},
"fastapi.showTestCodeLenses": {
"type": "boolean",
"default": true,
"description": "Show CodeLens links above test client calls (e.g., client.get('/items'), client.websocket('/ws')) to navigate to the corresponding route definition."
}
}
}
},
"description": "VS Code extension for FastAPI development",
"displayName": "FastAPI Extension",
"engines": {
"vscode": "^1.85.0"
},
"homepage": "https://github.com/fastapi/fastapi-vscode#readme",
"license": "MIT",
"lint-staged": {
"*.{ts,js,json}": [
"biome check --write"
]
},
"publisher": "FastAPILabs",
"scripts": {
"vscode:prepublish": "bun run esbuild.js --production",
"compile": "bun run esbuild.js",
"watch": "bun run esbuild.js --watch",
"package": "vsce package",
"publish:marketplace": "vsce publish",
"lint": "biome check --write --unsafe --no-errors-on-unmatched --files-ignore-unknown=true src/",
"pretest": "bun run compile",
"test": "vscode-test",
"prepare": "husky"
},
"devDependencies": {
"@biomejs/biome": "^2.3.11",
"@types/bun": "latest",
"@types/mocha": "^10.0.10",
"@types/vscode": "^1.85.0",
"@vscode/test-cli": "^0.0.12",
"@vscode/test-electron": "^2.5.2",
"@vscode/vsce": "^3.7.1",
"esbuild": "^0.27.2",
"husky": "^9.1.7",
"lint-staged": "^16.2.7"
},
"peerDependencies": {
"typescript": "^5"
},
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/fastapi/fastapi-vscode"
},
"bugs": {
"url": "https://github.com/fastapi/fastapi-vscode/issues"
},
"homepage": "https://github.com/fastapi/fastapi-vscode#readme",
"lint-staged": {
"*.{ts,js,json}": [
"biome check --write"
]
"dependencies": {
"tree-sitter-python": "^0.25.0",
"web-tree-sitter": "^0.26.3"
}
}
1 change: 0 additions & 1 deletion src/commands/index.ts

This file was deleted.

Loading