Skip to main content

Version: 3.6.x

Publish Service Version

For version control of deployed APIs, leverage API7 Gateway for publishing service versions to different gateway groups, instead of in-place gateway group edits.

Typically, an API version is published first in test and staging environments before publishing in production environments. API7 Gateway manages this environmental separation through Gateway Groups, where an API belongs to a single Published Service with a shared Upstream.

This tutorial guides you in publishing the httpbin service to a gateway group on API7 Gateway. You will learn how to:

  1. Create a service manually and through an OpenAPI Specification file.
  2. Publish services by configuring upstream nodes and by using service discovery mechanisms.

Prerequisites

  1. Install API7 Enterprise.
  2. Have at least one gateway instance in your gateway group.

Add a Service Template with Routes

Add Manually

  1. Select Service Hub from the side navigation bar, then click Add Service.
  2. Select Add Manually.
  3. From the dialog box, do the following:
  • In the Service Type field, choose HTTP(Layer 7 Proxy).
  • In the Name field, enter httpbin.
  • Click Add.
  1. Inside the service, click Add Route.
  2. From the Add Route dialog box, do the following:
  • In the Name field, enter get-ip.
  • In the Path field, enter /ip.
  • In the Methods field, choose GET.
  • Click Add.

Import OpenAPI Specification

Both the dashboard and ADC support importing an OpenAPI v3.0 Specification.

Define your API in a YAML/JSON file as shown below:

OpenAPI.yaml
openapi: 3.1.0
info:
title: httpbin
description: "httpbin for the API7 Enterprise Getting Started guides."
version: 1.0.0
paths:
"/anything/*":
get:
tags:
- Anything
summary: Returns anything that is passed into the request.
operationId: get-ip
responses:
"200":
description: Successful Response
content:
application/json:
schema:
type: string
tags:
- name: Anything
description: Return anything that is passed in on the request.

Then, use it in API7 Gateway:

  1. Select Service Hub from the side navigation bar, then click Add Service.
  2. Select Import OpenAPI.
  3. From the dialog box, do the following:
  • Upload your YAML/JSON file.
  • Click Next.
  1. Confirm the following information:
  • Name: the title field in OpenAPI Specification.
  • Labels: the tag field in OpenAPI Specification.
  • Description: the description field in OpenAPI Specification.
  • Routes: the Paths field in OpenAPI Specification.
  • Click Add.

Publish Single Service to Gateway Group

  1. Select Service Hub from the side navigation bar and then select httpbin.
  2. Click Publish.
  3. From the dialog box, do the following:
  • In the Gateway Group field, select your target gateway group, for example, default.
  • In the New Version field, enter 1.0.0.
  • Click Publish.

:::Note

When publishing a service for the first time, configure the necessary service runtime configurations and enable the service to activate your APIs. For subsequent publications, the service status and runtime configurations will be inherited from the previous version.

:::

Configure Service Runtime Configurations

  1. After publishing, you will be redirected to the published service on the gateway group.
  2. Select the Upstreams from the side navigation bar.
  3. Click Add Node.
  4. From the Add Node dialog box, do the following:
  • In the Host field, enter httpbin.org.
  • In the Port field, enter 80.
  • In the Weight field, enter 100.
  • Click Add.
  1. Click Enable from the top header of the published service and confirm.

Validate the API

curl "http://127.0.0.1:9080/ip"

You should see the following response:

{
"origin": "127.0.0.1"
}

Additional Resources


API7.ai Logo

API Management for Modern Architectures with Edge, API Gateway, Kubernetes, and Service Mesh.

Product

API7 Cloud

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN PTE. LTD 2019 – 2025. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the

Apache Software Foundation