Step 4 - Publish API v1.0

Before publishing our first API, we must understand what the DevOps (or API Dev) team provided us.

They provided us with an OpenAPI spec file (OASv3) via SwaggerHub. You can consult version 1.0 here: https://app.swaggerhub.com/apis/F5EMEASSA/API-Sentence-2022/v1

../../../_images/swaggerhub.png

Note

This is version 1.0 of the API, and in this version, as you can notice, the Colors micro-service is not yet available. This means that with this spec file, we will publish the API Sentence application without the Colors micro-service (e.g., a sample sentence might look like calm mouse of the mountain).


Create the API Services

  1. In NMS ACM UI, click on the Services menu on the left
  2. Create a new workspace. As you can notice, Infra team and API team have their separate workspaces
    • Name : sentence-app
  3. Click on Back to Workspaces and click on sentence-app workspace just created

Note

We will expose the API and document it on Dev-Portal at the same time.

Upload the OpenAPI Spec file

  1. Click on the API Docs tab

    ../../../_images/api-docs.png
  2. Click on Add API Doc and drag-drop the Swagger file, then click Save

    Note

    In Win10 RDP Jumphost, the Swagger file located on the desktop (oas-sentence-v1.yaml)

Expose the API proxy

  1. Click on API Proxies tab, and click Publish to Proxy

    • Backend Service

      • Name : sentence-svc
      • Service Target Hostname : 10.1.20.7 (this is the K3S Ingress IP Address)
      • Service Target Transport Protocol : HTTP
      • Service Target Port : 30511 (K8S Node Port)

    Note

    autocomplete may cause problems; if you copy and past over the port, it may be easier

    • API Proxy

      • Name : sentence-api
      • Use an OpenAPI Spec ? -> YES
      • API Spec : api-sentence-generator-v1
      • Gateway Proxy Hostname : api.sentence.com
    • Developer Portal

      • Check the box “Also publish API to developer portal” - This will push documentation in Developer Portal
      • Portal Proxy Hostname : dev.sentence.com
      • No Category
    • Click Publish

    • Click Back to workspace

../../../_images/publish-api-v131.png ../../../_images/edit-adv-config.png

Customize and finalize the configuration

The configuration still needs to be finished.

  • Define how the API Gateway will route the API requests per Version
  1. Edit the API Proxy just created (sentence-api) by clicking on the three dots on the top right of the row, then click Edit Proxy.

    ../../../_images/edit-proxy.png
  2. As you can notice, the first page (configuration) is what we just created previously. Click on Next

  3. Configure the Ingress as below

    • Append Rule : Prefix - version/basepath

    • Strip Base Path and Version before proxying the request : YES

    • Select Status : Latest

      ../../../_images/ingress.png
    • Click Next

  4. Click Next > Next then Save and Publish

Note

Congrats, your first API is exposed on the Nginx API Gateway and Documented in the Developer Portal.