Expand Authors Top

If you have a few years of experience in the Java ecosystem and you’d like to share that with the community, have a look at our Contribution Guidelines.

November Discount Launch 2022 – Top
We’re finally running a Black Friday launch. All Courses are 30% off until next Friday:

>> GET ACCESS NOW

Expanded Audience – Frontegg – Security (partner)
announcement - icon User management is very complex, when implemented properly. No surprise here.

Not having to roll all of that out manually, but instead integrating a mature, fully-fledged solution - yeah, that makes a lot of sense.
That's basically what Frontegg is - User Management for your application. It's focused on making your app scalable, secure and enjoyable for your users.
From signup to authentication, it supports simple scenarios all the way to complex and custom application logic.

Have a look:

>> Elegant User Management, Tailor-made for B2B SaaS

NPI – Lightrun – Spring (partner)

We rely on other people’s code in our own work. Every day. It might be the language you’re writing in, the framework you’re building on, or some esoteric piece of software that does one thing so well you never found the need to implement it yourself.

The problem is, of course, when things fall apart in production - debugging the implementation of a 3rd party library you have no intimate knowledge of is, to say the least, tricky. It’s difficult to understand what talks to what and, specifically, which part of the underlying library is at fault.

Lightrun is a new kind of debugger.

It's one geared specifically towards real-life production environments. Using Lightrun, you can drill down into running applications, including 3rd party dependencies, with real-time logs, snapshots, and metrics. No hotfixes, redeployments, or restarts required.

Learn more in this quick, 5-minute Lightrun tutorial:

>> The Essential List of Spring Boot Annotations and Their Use Cases

 1. Overview

In this article, we'll see how to import Swagger APIs to Postman.

2. Swagger and OpenAPI

Swagger is an open-source set of rules, specifications, and tools for developing and describing REST APIs. However, post-2021, OpenAPI refers to the industry-standard specifications, whereas Swagger refers to the tooling.

3. Postman

Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration. We can use Postman to test our API without writing any code.

We can use either the standalone app or the browser extension.

4. Application

We can work with any existing application, or we can create a simple application from scratch that exposes REST APIs.

4.1. Maven Dependencies

We need to add a couple of dependencies for using Swagger with the Swagger-UI:

<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>3.0.0</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>3.0.0</version>
</dependency>

4.2. Java Configuration

Swagger can be as easy to configure as:

@Configuration
public class SpringFoxConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
          .select()
          .apis(RequestHandlerSelectors.any())
          .paths(PathSelectors.any())
          .build();
    }
}

When we start the application, we can check the Swagger-UI and find the REST API description per controller:

Swagger-UI

 

We can also check the API docs that are generated for our REST APIs:

Swagger-API_Docs

5. Importing into Postman

There are multiple ways to import the APIs into Postman, but in most cases, it requires that the Swagger or OpenAPI definition be available in some text format (for example, JSON).

We can open Postman and navigate to the APIs option on the left, then click on Import to see the different options available:

Postman API Import

5.1. Importing File

If we have a Swagger JSON file available, we can import it via the file option in Postman:

Postman API Import File

 

If we have the Swagger-UI link, we can directly use the link to import the API into Postman.

Copy the API link from Swagger-UI as below:

Swagger Copy Link

And import it via the same link from Postman:

Postman API Import Link

 

5.3. Importing via Raw Text

We can also just paste the JSON as raw text to import the APIs:

Postman API Import Raw Text

 

5.4. Importing via Code Repository

To import APIs from repositories, we need to be logged in to Postman. To import from GitHub, as an example, let's follow the below steps:

  1. Navigate to the Code Repository tab.
  2. Click on GitHub.
  3. Confirm the GitHub account and authorize postmanlabs to access repositories. Once done, return to the Postman application for further steps.
  4. On Postman, select the organization, repository, and branch and click Continue.
  5. Confirm the APIs we need to import and click Import.

6. Conclusion

In this article, we've looked into different ways to import our REST APIs into Postman.

November Discount Launch 2022 – Bottom
We’re finally running a Black Friday launch. All Courses are 30% off until next Friday:

>> GET ACCESS NOW

Generic footer banner
Comments are closed on this article!