A Visual Studio Code extension that provides YAML syntax highlighting and indentation guides for @openapi tags in JSDoc comments.
- YAML Syntax Highlighting: Full syntax highlighting for YAML content in @openapiblocks- Keys, strings, numbers, booleans, and colons all properly colored
- Matches VS Code's standard YAML file colors
 
- Indentation Guides: Visual guides showing YAML structure
- Vertical lines at each indentation level
- Active guide highlighting (brighter line for current cursor position)
- Starts from the base declaration (API route)
 
- Smart Key Detection: Properly highlights API paths (/api/users), response codes (200,404), and all YAML keys
- Multi-language Support: Works with JavaScript (.js,.cjs,.mjs), TypeScript (.ts), JSX (.jsx), and TSX (.tsx) files
- Customizable Colors: Configure colors for light and dark themes separately via VS Code settings
- Real-time Updates: Colors and guides update instantly as you type and when you move your cursor
Simply write your OpenAPI/Swagger documentation in JSDoc comments using the @openapi tag:
/**
 * @openapi
 * /api/users:
 *   get:
 *     summary: Get all users
 *     tags:
 *       - Users
 *     responses:
 *       200:
 *         description: Success
 *         content:
 *           application/json:
 *             schema:
 *               type: array
 *               items:
 *                 type: object
 */
router.get('/api/users', async (req, res) => {
  // Implementation
});The extension works with various JSDoc formats:
/**
 * User endpoint handler
 * @openapi
 * /api/user/{id}:
 *   get:
 *     parameters:
 *       - name: id
 *         in: path
 *         required: true
 *         schema:
 *           type: integer
 */
static async myEndpointHandler(req, res) {
  // Your code here
}- Clone this repository
- Open the folder in VS Code
- Press F5to open a new Extension Development Host window
- Test the extension with your JavaScript/TypeScript files
npm install -g vsce
vsce packageThen install the .vsix file:
- Open VS Code
- Go to Extensions view (Ctrl+Shift+X)
- Click the "..." menu and select "Install from VSIX..."
- Select the generated .vsixfile
You can customize the colors for both light and dark themes through VS Code settings:
- Open Settings (Ctrl+,orCmd+,)
- Search for "JSDoc OpenAPI"
- Configure colors for each element:
- jsdocOpenapi.colors.light.key- YAML keys (default:- #0000FF)
- jsdocOpenapi.colors.light.string- String values (default:- #A31515)
- jsdocOpenapi.colors.light.number- Numbers (default:- #098658)
- jsdocOpenapi.colors.light.boolean- Booleans (default:- #0000FF)
- jsdocOpenapi.colors.light.colon- Colons (default:- #000000)
- jsdocOpenapi.colors.light.indentGuide- Indentation guides (default:- rgba(0, 0, 0, 0.18))
- jsdocOpenapi.colors.light.activeIndentGuide- Active guide (default:- rgba(0, 0, 0, 0.40))
- jsdocOpenapi.colors.dark.key- YAML keys (default:- #569CD6)
- jsdocOpenapi.colors.dark.string- String values (default:- #CE9178)
- jsdocOpenapi.colors.dark.number- Numbers (default:- #B5CEA8)
- jsdocOpenapi.colors.dark.boolean- Booleans (default:- #569CD6)
- jsdocOpenapi.colors.dark.colon- Colons (default:- #D4D4D4)
- jsdocOpenapi.colors.dark.indentGuide- Indentation guides (default:- rgba(255, 255, 255, 0.18))
- jsdocOpenapi.colors.dark.activeIndentGuide- Active guide (default:- rgba(255, 255, 255, 0.40))
- Visual Studio Code 1.60.0 or higher
- Built-in YAML language support (included with VS Code)
Open example.js and compare it side-by-side with example.yaml to see the matching syntax highlighting.
To test:
- Press F5to launch Extension Development Host
- Open example.jsin the new window
- Verify YAML content after @openapihas syntax highlighting and indentation guides
- Move your cursor through different indent levels to see active guide highlighting
- Reload the window: Press Ctrl+Shift+P→ "Developer: Reload Window"
- Check file type: Ensure file has .js,.ts,.cjs,.mjs,.jsx, or.tsxextension
- Inspect scopes: Use "Developer: Inspect Editor Tokens and Scopes" to verify source.yamlscope is present
This means the default JSDoc highlighting works but our grammar injection doesn't:
- Verify package.jsonand grammar file have matchingscopeName
- Check Extension Host output for errors (Ctrl+Shift+U→ "Extension Host")
- Restart the Extension Development Host (close and press F5again)
- Ensure each JSDoc line starts with *(space-asterisk-space)
- Check YAML indentation is consistent (use spaces, not tabs)
- Verify YAML syntax is valid
- The extension currently supports @openapitag. Other similar tags can be added by modifying the grammar file.
- Indentation guides assume 2-space indents (configurable via editor.tabSize)
Contributions are welcome! Please feel free to submit a Pull Request to the GitHub repository.
SimPleased - GitHub
GNU General Public License v3.0 or later (GPL-3.0-or-later)
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
See the LICENSE file for details.