<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alex</title>
    <description>The latest articles on DEV Community by Alex (@li0lik).</description>
    <link>https://dev.to/li0lik</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F269205%2F5799d0ce-ca8e-4ed7-b280-27f51831ce1e.jpg</url>
      <title>DEV Community: Alex</title>
      <link>https://dev.to/li0lik</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/li0lik"/>
    <language>en</language>
    <item>
      <title>I built a VS Code Extension that mocks your OpenAPI spec locally — no Postman, no Docker, no Context switching</title>
      <dc:creator>Alex</dc:creator>
      <pubDate>Wed, 01 Jul 2026 14:56:52 +0000</pubDate>
      <link>https://dev.to/li0lik/i-built-a-vs-code-extension-that-mocks-your-openapi-spec-locally-no-postman-no-docker-no-16f6</link>
      <guid>https://dev.to/li0lik/i-built-a-vs-code-extension-that-mocks-your-openapi-spec-locally-no-postman-no-docker-no-16f6</guid>
      <description>&lt;p&gt;Every time I had to test an API endpoint while writing an OpenAPI spec, I had to leave VS Code, open Postman, configure the request, and then come back. And if I wanted to check whether my changes broke any contracts — that meant running a separate diff tool.&lt;/p&gt;

&lt;p&gt;I got tired of it. So I built Specter Mock.&lt;/p&gt;

&lt;p&gt;What It Does&lt;/p&gt;

&lt;p&gt;Specter Mock is a VS Code extension with three core features:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Local Mock Server&lt;/strong&gt;&lt;br&gt;
Open any OpenAPI .yaml or .json file, click the status bar — a local HTTP server starts on localhost:4010 instantly. No Docker, no CLI, no configuration.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; curl localhost:4010/pets
 &lt;span class="c"&gt;# → [{"id": 1, "name": "Rex"}, {"id": 2, "name": "Whiskers"}]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It reads the examples from your spec and serves them as real HTTP responses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Try It Panel&lt;/strong&gt;&lt;br&gt;
A built-in panel that lists all your endpoints with colored method badges. Click any endpoint, hit Send — you get the response right inside VS Code. GET, POST, PUT, DELETE — all work out of the box.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Breaking Change Diff&lt;/strong&gt;&lt;br&gt;
Every time you save your spec, Specter compares it against the last Git commit and shows breaking changes in the VS Code Problems panel:&lt;/p&gt;

&lt;p&gt;Removed endpoints → Error&lt;br&gt;
Removed parameters → Error&lt;br&gt;
New required parameters → Warning&lt;br&gt;
Changed response types → Error&lt;/p&gt;

&lt;p&gt;No manual diffing. No extra commands. Just save and see.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why I Built It&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The existing tools each solve one piece of the puzzle:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Postman&lt;/strong&gt; — great API client, but it's a separate app&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Prism&lt;/strong&gt; — powerful mock server, but CLI-only&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;42Crunch&lt;/strong&gt; — good editor, but no local mock server&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;oasdiff&lt;/strong&gt; — excellent diff tool, but you have to run it manually&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nobody combined all three into a single VS Code extension. So I did.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How It Works Under the Hood&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The mock server uses Node's built-in http module + @apidevtools/swagger-parser to dereference the spec and serve examples. No Prism dependency (I tried — it has ESM/CJS compatibility hell with newer faker versions).&lt;/p&gt;

&lt;p&gt;The diff runs simple-git to get the previous file version from HEAD, writes it to a temp file, parses both versions with swagger-parser, and compares paths, methods, parameters, and response schemas. Results go directly into vscode.DiagnosticCollection.&lt;/p&gt;

&lt;p&gt;The Try It panel is a Webview with plain HTML — no React, no bundler. Fetch requests go through the extension host (Node.js) to avoid CORS issues inside the webview sandbox.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Bundling Problem&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The trickiest part was bundling. I used esbuild, which is fast and simple. But &lt;em&gt;@stoplight/prism-http&lt;/em&gt; uses &lt;em&gt;jsonc-parser&lt;/em&gt; with a dynamic &lt;em&gt;require('./impl/format')&lt;/em&gt; in its UMD build — esbuild bundles everything into one file and breaks the relative path.&lt;/p&gt;

&lt;p&gt;The fix: &lt;em&gt;--packages=external&lt;/em&gt; flag. This tells esbuild not to bundle &lt;em&gt;node_modules&lt;/em&gt; — they stay as-is and load via native Node.js require. Bundle size dropped from 10.9mb to 20kb.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"compile"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"esbuild src/extension.ts --bundle --outfile=dist/extension.js --external:vscode --packages=external --platform=node --target=node18"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Install It&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Search "&lt;strong&gt;Specter Mock&lt;/strong&gt;" in VS Code Extensions, or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;code &lt;span class="nt"&gt;--install-extension&lt;/span&gt; li0lik.specter-mock
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;GitHub: &lt;a href="https://github.com/Li0lik/specter" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What's Next&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stateful mock scenarios (remember POST'd data for GET)&lt;/li&gt;
&lt;li&gt;Schema-based response generation (not just examples)&lt;/li&gt;
&lt;li&gt;OpenAPI linting in the Problems panel&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you work with OpenAPI specs daily, give it a try and let me know what you think. Issues and PRs welcome.&lt;/p&gt;

</description>
      <category>vscode</category>
      <category>openapi</category>
      <category>webdev</category>
      <category>typescript</category>
    </item>
  </channel>
</rss>
