Skip to content

Instantly share code, notes, and snippets.

@cwiechmann
Last active May 13, 2019 08:55
Show Gist options
  • Save cwiechmann/dcc2879df96d6a11e665a068fe54b82d to your computer and use it in GitHub Desktop.
Save cwiechmann/dcc2879df96d6a11e665a068fe54b82d to your computer and use it in GitHub Desktop.

Just have your APIs as code

Before getting into the details, what I mean with APIs as code, I would like to provide a bit of context, why it might be worth to think about it.
We all know, companies today need to reduce manual tasks as much as possible to be efficient, so that they can focus on other more important tasks, which finally brings real value to a company. Instead of doing repeatable things over and over again.
Automation can and is already applied in many areas different areas. For instance by providing a Platform as a service, that allows developers to quickly build & create their applications fully automated. Or when in comes to required infrastrcture in the cloud or On-Premise, tools like Terraform or Chef are used and often name "Infrastructure as Code".
Since quite a while already software development companies are using CI/CD-Pipelines to automatically build, test & deploy software projects. This allows a quicker time-to-market, getting earlier feedback, more stable solutions and makes developers life easier.
And of course, not unusual today and especially when using a Microservice archicture, these applications are creating hundreds of APIs that provide data or business functions. At this stage, companies think about an API-Management solution to make some of these API securly externally available to be consumed by partners, apps, etc.

API-Centric architecture

Now, assume you would have a place to go, where you could easily discover and re-use all of these APIs that provide you useful Data & Functions, which has been develop by someone else. You, perhaps from a complete different business-department, can now discover & integrate these APIs in a Self-Service way into your Business-Projects to create new innovative use-cases, just by combining Data & Functions in a different way. And of course this is isn't limited to local applications, with such an API-Centric architecture, you can now easily combine them with APIs provided by Cloud-Applications, your partners, etc. It becomes a matter of integrating an APIs once into the API-Management platform to have it discoverable & re-usable.

This is what an API-Management platform is made for. It's the single place to go, to discover existing APIs, which are secured by corporate security policies which you can subscribe to them. API-Management takes care, that only allowed consumers are using APIs with the given quota. And as all API requests at runtime, are handled by the API-Management platform, you get a clear picture, about who is using which API/Service.

Two sides of the coin

But you can only discover APIs, that has been inserted before, hence the success of the API-Management solution heavily depends of the number of APIs discoverable by potential consumers.
Often, if not always, application developers are creating applications and belonging APIs for a dedicated business project and they are busy or even late with that. Therefore it is understable, that they don't wanna spend additional time on integrating their APIs into such platform using a manual process. For instance using a Web-UI, which get's even more painful when the API-Definition has still frequent changes, which is pretty common esp. in the initial phase.
Developers wanna stay in their comfort zone, using the tools they use everday and not learning how to register & maintain their APIs in a API-Management platform. For them it should a service which is easy to use for them and is integrated into their workflow.

An API as code triggers CI/CD

To me, it makes fully sense to deploy APIs into the API-Management platform, along with the piece of software, that exposes the API. With that, the API inside the API-Management system keeps in sync with the software providing that API. Of course in certain situations it is required to de-couple it, but this is something that can be implemented as part of the CI/CD process.
So, we need a simple CI/CD-process for APIs, that can be maintained by API-Developers alongside with their software projects.

When using the Axway API-Manager, Swagger-Promote provides you with that capability. As an API-Developer you just declare the API you want, put it into your version control system and Swagger-Promote, as part of the CI/CD-Process replicates the API into the API-Manager. It follows the apporach: Desired state vs. Actual state.

<<<<< Maybe an Image >>>>>

Once you have your API as code, things like staging them into

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment