You can then use code completion suggestions to add additional parameters if needed.Īlternatively, you can create new requests using an intention right from the JavaScript or TypeScript file. If there is one, grab a direct link to the spec file and add that URL in the IDE Preferences/Settings.Īs you may already know, WebStorm has a built-in HTTP client that you can use to test REST APIs.įrom the OpenAPI spec file, you can quickly generate new requests in the format that the HTTP Client understands by clicking on the icon next to the method. If you’re using APIs of some 3rd-party service, you can check if there’s a community-maintained OpenAPI spec for it in the openapi-directory repository on GitHub (in the APIs folder). For that, go to Preferences/Settings | Languages and Frameworks | OpenAPI Specification, click the plus icon, and then paste the link to the JSON or YAML file. Having an OpenAPI spec right in your project is not the only way to benefit from these completion suggestions – you can also specify a URL where the spec is available. We’re planning to add support for Express methods soon. when using methods like get() or post() from the axios library.Once you have a spec file anywhere in your project, you’ll be able to see suggestions for these APIs in your JavaScript and TypeScript code.Ĭurrently, they are shown in two situations: The most important part of the spec file is the paths section that lists available endpoints and their supported HTTP methods. This documentation is interactive, and you can test the endpoints right from this preview. Switch between editing and preview modes using the icons in the top right corner of the editor. If you already have an OpenAPI spec, you can see some docs built with Swagger UI right in the IDE. WebStorm will show you the names of sections with a short description in the code completion popup, and the IDE will also check that the file has all the required sections. To create a new API spec in your project, use the File | New… menu or the New… popup in the Project View, and then select OpenAPI Specification. Install it from the plugin repository or from the Marketplace tab in IDE Settings | Plugins. To get started, we’ll need to install the OpenAPI Specifications plugin. In this blog post, we’ll have a look at how WebStorm can help you create and edit API docs, write code with API calls, and test the calls. If you aren’t already familiar with it, Swagger is a set of tools that helps you create docs for APIs (their website has a wealth of information that you’re welcome to check out), while OpenAPI is a format for describing the endpoints of the REST API. If you’re working on a RESTful application and either developing REST APIs or using them in your code, you might already know about OpenAPI and Swagger.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |