top of page

Design APIs with Swagger and deploy in Apigee

Apigee is an API management platform, API Manager in short, this is the process of creating and publishing web APIs, enforcing their usage policies, controlling access, nurturing the subscriber community, collecting and analyzing usage statistics, and reporting on performance.

Swagger uses a standard format to describe a REST API, thus it can be used to design our REST API. Written in either JSON or YAML format, a swagger specification is machine readable, but is also easy for humans to read and understand.

The objective is to go through the process of designing with swagger, and later on creating and configuring a simple API proxy using the Apigee Edge management UI. Follow the link to get expert advice on Apigee Architecture.

Requirements

A Swagger specification for the desired API, if you don’t know how to create one you can find some guidelines in this presentation.

An Apigee Edge, API Manager, account. If you don't have one yet, you can sign up with the directions at Creating an Apigee Edge, API Manager, account.

cURL installed on your machine to make API calls from the command line; or a web browser.

Create the API Proxy using Apigee’s API Manager

An Apigee API Proxy often includes a transformation engines to orchestrate and modify the requests and responses on the fly. An Apigee API Proxy can also provide functionality such collecting analytics data and providing caching. An Apigee API Proxy can provide functionality to support authentication, authorization, security, audit and regulatory compliance.

1.Go to https://apigee.com/edge and log in. Apigee Edge UI, the API Manager user interface, was changed recently, you can always use the classic view.

2.Change to the organization you want. In the upper left, click your username, then click the name of the current organization to select from a list of organizations.

3.Click API Proxies in the main window to obtain a list of existing API proxies.

4. Click the add (+) API Proxy button.

5.In the Build a Proxy wizard, select Reverse proxy (most common), and click on Use Swagger.

6. Select your Swagger file either by uploading a file, or by using the url of your Swagger file.

7. Click Apply

8. Click Next

Configure the API Proxy using Apigee’s API Manager

1. Here is the difference with the previous post, because the configuration for the API Proxy is already taken from the Swagger file. So, depending on your swagger the values might be like:

Proxy Name: HelloAPI

Proxy Base Path: /hello

Description: Swagger sample for a mocked hello world

In the case that your Swagger is like:

swagger: '2.0'

info:

description: 'Swagger sample for a mocked hello world'

version: 1.0.0

title: Mock Target API

host: mymock.getsandbox.com

schemes:

- http

- https

2. Click next

3. Depending on your /paths elements you’ll see a set of flows with the configuration extracted from the given designed API.

4. Click Next.

5. On the Security page, select Pass through (none) as the security option, and click Next.

6. On the Virtual Hosts page, make sure all virtual hosts are selected and click Next.

7. On the Build page, make sure the test environment is selected, and click Build and Deploy.

8. On the Summary page, you see an acknowledgement that your new API proxy was created successfully and deployed to your test environment.

Test the Apigee API Proxy using Apigee and Curl

You can test your helloAPI API using cURL or a web browser.

In a terminal window, run the following cURL command. You should use your organization name in the URL.

curl http://<org_name>-test.apigee.net/hello

bottom of page