An OpenAPI Specification (OAS) is a description format for REST APIs. Swagger is a set of tools based on this specification for writing, documenting, and consuming REST APIs. For more information, see Swagger documentation.
- Build fast, responsive sites with Bootstrap. Quickly design and customize responsive mobile-first sites with Bootstrap, the world’s most popular front-end open source toolkit, featuring Sass variables and mixins, responsive grid system, extensive prebuilt components, and powerful JavaScript plugins.
- WebStorm 2020.3, the last major update of the year, is here! This update is packed with many long-awaited enhancements, including support for Tailwind CSS, the ability to sync your IDE theme with your OS settings, and Git staging.
PhpStorm 2020.3 is a major update that introduces support for PHP 8, PHPStan, Psalm, Tailwind CSS, Xdebug 3, and collaborative development via Code With Me. JetBrains PhpStorm March 26 at 1:49 AM. I have a folder with bootstrap files in it, and Bootstrap appears and is checked in the plugins page of settings. I created a new project using Bootstrap template, and then created an Index.html document. My goal is to play with Bootstrap in PHPStorm. I can't seem to get Bootstrap to make any changes by coding in the index.htm.
PhpStorm provides coding assistance for OpenAPI definitions in YAML and JSON files, and integration with Swagger Codegen for generating server stubs, client libraries (SDKs), and documentation based on your OpenAPI specification. In addition, you can create HTTP requests for the defined endpoints and execute them via the built-in HTTP Client.
Create an OpenAPI specification
PhpStorm recognizes a dedicated OpenAPI Specification file type with relevant coding assistance. These are regular YAML or JSON files with the definition of the OpenAPI specification version.
From the main menu, select File | New | OpenAPI Specification, or press Alt+Insert and select OpenAPI Specification.
Specify a name for the file and select the specification version and file format.
Depending on the format and version, the new OpenAPI specification file contains the following template:
If you start with an empty YAML or JSON file, you can type opnp
or swag
and press Tab to insert the corresponding live template.
Phpstorm Bootstrap Autocomplete
Add a remote OpenAPI specification
Endpoint URLs that you define in OpenAPI specifications in your project are available for code completion. If you are writing client code for an external specification, there is no need to add it as a file to your project for auto-completing endpoint URLs. You can add a link to the relevant remote specification.
In the Settings/Preferences dialog Ctrl+Alt+S, select Languages & Frameworks | OpenAPI Specifications.
Click in the Remote Specifications list and specify the URL of an OpenAPI specification file or find an OpenAPI specification on SwaggerHub.
Use to reload specifications that were modified.
To add private OpenAPI specifications, provide your API key.
To add OpenAPI specifications from a self-hosted SwaggerHub On-Premise instance, specify the URL of your instance.
Compare OpenAPI specifications
When there is a newer specification version, you probably want to compare it against the older version to make sure that they are compatible. One way is to look at the diffCtrl+D and compare lines that changed. However, not all changes are critical for compatibility. PhpStorm can compare the structure of OpenAPI specifications and create a summary of changed paths, parameters, responses, and any other elements that may break the compatibility.
In the Project tool window, select two OpenAPI specification files, right-click them and select Compare OpenAPI Specifications.
This generates a Markdown file with a summary of modified specification elements. The file opens in the editor with a preview panel that makes it easy to navigate the changes. It shows the changes in the file that you selected second compared to the first one.
Generate code from an OpenAPI specification
When you have a valid OpenAPI specification open, you can generate code from it by clicking :
Click , configure the necessary settings, then apply the changes and run the configuration. PhpStorm generates source code files in the specified location and shows a notification with options to open the files or import them into your project as a separate module.
Swagger Codegen run configuration
PhpStorm creates a Swagger Codegenrun configuration, which you can configure when you run code generation for the first time for a particular file. To modify the run configuration, open Run | Edit Configurations and select the necessary configuration, or click at the top of the editor when the corresponding OpenAPI specification file is open.
You can configure the following common options at the top of the Swagger Codegen run configuration:
Item | Description |
---|---|
Name | Specify a name for the run/debug configuration to quickly identify it when editing or running the configuration, for example, from the Run popup Alt+Shift+F10. |
Allow parallel run | Select to allow running multiple instances of this run configuration in parallel. By default, it is disabled, and when you start this configuration while another instance is still running, PhpStorm suggests to stop the running instance and start another one. This is helpful when a run/debug configuration consumes a lot of resources and there is no good reason to run multiple instances. |
Store as project file | Save the file with the run configuration settings to share it with other team members. The default location is .idea/runConfigurations. However, if you do not want to share the .idea directory, you can save the configuration to any other directory within the project. By default, it is disabled, and PhpStorm stores run configuration settings in .idea/workspace.xml. |
General Settings
Item | Description |
---|---|
Specification path | Path to the OpenAPI specification. |
Generate files to | Path to the directory for the generated files. |
Generator path | Path to the generator (the executable JAR file). You can either manually specify the path to a local generator or select to use the latest available version from Maven Central. |
Language | The target language of the generated code. |
Configure generator | Provide configuration parameters that depend on the target language.
For information about the configuration parameters, see the swagger-codegen/README.md. |
Advanced Settings
Item | Description |
---|---|
Custom templates path | Path to a directory with your Mustache templates. |
JRE | Java runtime to use for running Swagger Codegen. |
Show debug logs | Write debug messages to the log. |
Before launch
Add tasks to perform before starting the run configuration in the specified order. For example, you can run another configuration or an external tool first.
Item | Description |
---|---|
Show this page | Show this run configuration settings dialog before starting it. |
Activate tool window | Open the Run tool window when this configuration starts. If this is disabled, to open the tool window, select View | Tool Windows | RunAlt+4. |
Test your OpenAPI specification in the HTTP client
When working with OpenAPI Specification files, you can create HTTP requests to the specified endpoints and execute them via the built-in HTTP client.
Create an HTTP request to an endpoint
In an OpenAPI specification file, click in the editor gutter next to the endpoint definition.
Phpstorm Add Bootstrap
PhpStorm will create a new HTTP request and save it in the generated-requests.httpscratch file.
Rename an endpoint and its usages
Phpstorm Bootstrap Template
Use the Rename refactoring to rename the defined endpoint and its usages in HTTP requests simultaneously.
Phpstorm Bootstrap Examples
Do any of the following:
In an OpenAPI specification file, position the caret at the endpoint's definition you want to rename.
In an HTTP request file, position the caret at the URL path segment you want to rename.
Select Refactor | Rename from the main menu or the context menu, or press Shift+F6.
In the Rename dialog that opens, specify the new endpoint's name.
Preview and apply changes.
Phpstorm Bootstrap Project
PhpStorm will rename the endpoint and its usages.