It's rare enough that we have down periods in SwaggerHub – there are always new features to build – but one sprint we were given time to work on personal projects for a few days, a sort of mini-hackathon.
Visual studio code extensions api code#
We already have a public API for anyone with a SwaggerHub account, so why not bring it onboard and into the IDE? At the time, the VS Code API seemed a bit much to get my head around for the sake of a hackathon (as it turned out later, I was right), so the idea didn’t come to light during that event. So, while brainstorming ideas for one of our yearly hackathons, I thought why not combine the two and write an extension for VS Code that would fully integrate with SwaggerHub. It didn’t take long before I abandoned this tack altogether and stuck to leaving SwaggerHub open on one screen, VS Code in another.ĭespite this being functional, I always thought there could be a better way.
Visual studio code extensions api download#
If I don’t want to lose context, I must download the YAML, open it in the editor and quickly find myself out of sync with any changes my fellow devs had made. But that’s always been a tedious affair in the past. You see, being a front-end developer on SwaggerHub who consumes SwaggerHub APIs, my natural inclination is to read, use, and work with those APIs in VS Code. That’s all preamble to the core conceit of this blog: VS Code and SwaggerHub. If I’m unsure about something, I can poke around at the open source innards and see what’s making things tick. It’s fast, it’s neat, and as a JavaScript developer, it’s also very handy that it’s written in JavaScript. Now as a front-end developer, my IDE of choice is Visual Studio Code. They’re everywhere! We use them ourselves to write the application that documents the very APIs we’re using! I’m a front-end developer for SwaggerHub, and this means my exposure to APIs comes primarily as a consumer – I help sculpt the result of our APIs by being a first-party user. Calls to subscribe return a Disposable which removes the event listener upon dispose.One of the best things about working with SwaggerHub is the exposure to APIs. EventsĮvents in the VS Code API are exposed as functions which you call with a listener-function to subscribe. This applies to event listening, commands, interacting with the UI, and various language contributions.įor instance, the setStatusBarMessage(value: string) function returns a Disposable which upon calling dispose removes the message again. The VS Code API uses the dispose pattern for resources that are obtained from VS Code. The cancellation token is usually the last parameter of a function call and optional. For instance, computing IntelliSense starts and the user continues to type making the result of that operation obsolete.ĪPIs that are exposed to such behavior will get passed a CancellationToken on which you can check for cancellation ( isCancellationRequested) or get notified when cancellation occurs ( onCancellationRequested). Often operations are started on volatile state which changes before operations can finish. When the use of a promise is optional, the API indicates this by returning or-types. In most cases the use of promises is optional and when VS Code calls into an extension, it can handle the result type as well as a Thenable of the result type. From extensions any type of promise can be returned, like ES6, WinJS, A+, etc.īeing independent of a specific promise library is expressed in the API by the Thenable-type. The VS Code API represents asynchronous operations with promises. The extension API of Visual Studio Code follows some guiding patterns and principles which are applied throughout the whole API.