Add Service from API Definition
Once API development and deployment are complete, publish to API7 Enterprise Edition to leverage its capabilities.
Prerequisites
- Obtain a User Account with Super Admin or API Provider Role.
- Complete Plan Your API Definition.
- One OpenAPI specification corresponds to one service. This means all paths in the spec share the same upstream.
- Complete Deploy Your Upstreams on Server Nodes. If a real API backend is not deployed yet, use a mock server instead, complete Mock API Response for Testing.
- Learn key concept Services.
Import OpenAPI Specification to Add Service(Recommended)
At this time, OpenAPI 3.0 is the only supported version.
- Select Services , then click Add Service.
- Choose Upload OpenAPI 3.0 Spec.
- Upload YAML/JSON file, then click Next.
- Confirm the following information:
- service name(Title field in OpenAPI Specification)
- description(Description field in OpenAPI Specification)
- labels(Tags field in OpenAPI Specification)
- routes(Paths field in OpenAPI Spec).
Host and path prefix configuration are not needed in this tutorial. Click Next.
- Choose
HTTPS
as the Upstream Scheme. - Enter one upstream endpoint URL(If using a load balancer for your upstream servers, set its address as the Upstream URL) or use the mock server address as the Upstream URL. You can add more nodes later.
- Click Add.
- The default status of the service is
disabled
. Select Actions > Enable to make all routes of the service accessible.
Validate
curl "http://127.0.0.1:9080/pet/1"
You can see the response from upstream:
{
"name": "Dog",
"photoUrls": [
"https://example.com/dog-1.jpg",
"https://example.com/dog-2.jpg"
],
"id": 1,
"category": {
"id": 1,
"name": "pets"
},
"tags": [
{
"id": 1,
"name": "friendly"
},
{
"id": 2,
"name": "smart"
}
],
"status": "available"
}