Skip to content

Latest commit

 

History

History
103 lines (66 loc) · 6.58 KB

File metadata and controls

103 lines (66 loc) · 6.58 KB

Exercise 07 - Import an API using an OpenAPI specification

So far, we've seen how we can discover, copy, deploy and publish APIs available in the SAP Business Accelerator Hub to our SAP API Management instance. It is also possible to create APIs in SAP API Management, based on OpenAPI specifications. Many products/services available to us publish their API specification and this can ease our development/integration efforts.

At the end of this exercise, you'll have successfully used an OpenAPI specification to create an API and its resources in SAP API Management.

To be - Nager.Date API added
To be - Nager.Date API added

Public Holidays around the world

As mentioned in the API Management scenario, ITeLO has a global workforce, with many offices around the world. Every country has different public holidays and it is important to know which dates are public holidays in each location, for planning/HR purposes. Currently, different teams maintain this information in different ways, e.g. spreadsheets/consuming different API and the data is not consistent across the organisation. Our goal is to provide a single point of reference (API) that all the different applications in the organisation can use/refer to know the public holidays of the different locations. This will help to harmonise this important data across the organisation.

Nager.Date - Worldwide Public Holiday

Fortunately for us, there is a public service - https://date.nager.at/ - that can provide us with public holiday information for 110 countries. All the countries where ITeLO operates are included here so we are good to go.

👉 Visit the website of Nager.Date and check out the public holidays published for the country you are in, e.g. https://date.nager.at/PublicHoliday/Country/AU.

Public Holidays - Australia
Public Holidays - Australia

Nager.Date makes its data available via an API. If you visit the API documentation, you'll notice that it shows us a Swagger UI, and within the docs there is a link to its OpenAPI specification. We can use this specification to create the API in our instance of SAP API Management.

The OpenAPI specification for Nager.Date's API is also included in the assets folder of this exercise: ./assets/date.nager.at-openapi.json

🧭 Take some time to visit the Nager.Date's API documentation, get familiar with the resources available and try sending some requests.

Exploring Nager.Date API
Exploring Nager.Date API

Create API by importing OpenAPI specification in SAP API Management

Now that we are familiar with the API, let's proceed to make it available to our developers via SAP API Management.

👉 In SAP Integration Suite, navigate to Configure > APIs and click the Import button and select Nager.Date's OpenAPI specification.

Import Nager.Date's OpenAPI specification
Import Nager.Date's OpenAPI specification

We will manage this API in SAP API Management, this will allow us to change its behaviour which is something that we will do in a future exercise. No need to create a version as the API itself already has versioning.

👉 Set the following values to complete the creation of the API.

  • Overview tab:
    • Name: PublicHolidays_Nager_Date_API
    • Title: Public Holidays Worldwide
    • Host Alias: Select your host alias
    • API Base Path: /public-holidays
    • Description: Powered by Nager.Date - https://date.nager.at/
  • Target Endpoint tab:
    • URL: Replace https://localhost/ with https://date.nager.at/

Once you set the values above, deploy the API.

If you try testing any resources before deploying the API, you will get an authentication error in the response. Deploy the API first and then retry.

Exercise 07 - Publish the API in the API Business Hub Enterprise

In exercise 06 we went into detail on how to publish an API. Lets repeat the process here.

👉 Create a new Product, e.g. General Data, and associate the PublicHolidays_Nager_Date_API to it. Publish the product.

General Data - Product
General Data - Product

If we now visit the API Business Hub Enterprise, we will see our new product and API in it. You can test the API from here as well.

General Data > Public Holidays Worldwide API in API Business Hub Enterprise
General Data > Public Holidays Worldwide API in API Business Hub Enterprise

Summary

Exciting! We were able to import an OpenAPI specification and created an API from it. Many services publish OpenAPI specs which can ease how we can create API in SAP API Management.

Further reading


If you finish earlier than your fellow participants, you might like to ponder these questions. There isn't always a single correct answer and there are no prizes - they're just to give you something else to think about.

  1. Check out a huge list of free APIs that you might find useful.
  2. Apart from being able to import an OpenAPI specification, what other file type can you import? and what's included in it?
  3. There is a transport mechanism in SAP API Management... why would you export/import an API instead of using the transport mechanism available?

Next

Continue to 👉 Exercise 08 - Add an SAP SuccessFactors Employee Central API